let the user decide on whether or not to compress pictures

This commit is contained in:
Daniel Gultsch 2016-01-09 16:17:39 +01:00
parent 708d7c5b98
commit 4ab8fe13de
4 changed files with 41 additions and 13 deletions

View file

@ -414,8 +414,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} }
public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) { public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) {
if (getFileBackend().useImageAsIs(uri)) { final String compressPictures = getCompressPicturesPreference();
Log.d(Config.LOGTAG, "using image as is"); if ("never".equals(compressPictures)
|| ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri))) {
Log.d(Config.LOGTAG,conversation.getAccount().getJid().toBareJid()+ ": not compressing picture. sending as file");
attachFileToConversation(conversation, uri, callback); attachFileToConversation(conversation, uri, callback);
return; return;
} }
@ -590,6 +592,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return getPreferences().getBoolean("away_when_screen_off", false); return getPreferences().getBoolean("away_when_screen_off", false);
} }
private String getCompressPicturesPreference() {
return getPreferences().getString("picture_compression", "auto");
}
private int getTargetPresence() { private int getTargetPresence() {
if (xaOnSilentMode() && isPhoneSilenced()) { if (xaOnSilentMode() && isPhoneSilenced()) {
return Presences.XA; return Presences.XA;

View file

@ -57,4 +57,16 @@
<item>voice</item> <item>voice</item>
<item>location</item> <item>location</item>
</string-array> </string-array>
<string-array name="picture_compression_values">
<item>never</item>
<item>auto</item>
<item>always</item>
</string-array>
<string-array name="picture_compression_entries">
<item>@string/never</item>
<item>@string/automatically</item>
<item>@string/always</item>
</string-array>
</resources> </resources>

View file

@ -287,7 +287,7 @@
<string name="pref_about_conversations_summary">Build and licensing information</string> <string name="pref_about_conversations_summary">Build and licensing information</string>
<string name="pref_about_message" translatable="false"> <string name="pref_about_message" translatable="false">
Conversations • the very last word in instant messaging. Conversations • the very last word in instant messaging.
\n\nCopyright © 2014-2015 Daniel Gultsch \n\nCopyright © 2014-2016 Daniel Gultsch
\n\nThis program is free software: you can redistribute it and/or modify \n\nThis program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
@ -571,4 +571,8 @@
<string name="notify_only_when_highlighted">Notify only when highlighted</string> <string name="notify_only_when_highlighted">Notify only when highlighted</string>
<string name="notify_never">Notifications disabled</string> <string name="notify_never">Notifications disabled</string>
<string name="notify_paused">Notifications paused</string> <string name="notify_paused">Notifications paused</string>
<string name="pref_picture_compression">Compress Pictures</string>
<string name="pref_picture_compression_summary">Resize and compressed pictures</string>
<string name="always">Always</string>
<string name="automatically">Automatically</string>
</resources> </resources>

View file

@ -22,7 +22,13 @@
android:key="auto_accept_file_size" android:key="auto_accept_file_size"
android:summary="@string/pref_accept_files_summary" android:summary="@string/pref_accept_files_summary"
android:title="@string/pref_accept_files"/> android:title="@string/pref_accept_files"/>
<ListPreference
android:defaultValue="auto"
android:entries="@array/picture_compression_entries"
android:entryValues="@array/picture_compression_values"
android:key="picture_compression"
android:summary="@string/pref_picture_compression_summary"
android:title="@string/pref_picture_compression"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="confirm_messages" android:key="confirm_messages"
@ -92,8 +98,8 @@
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="use_white_background" android:key="use_white_background"
android:title="@string/pref_use_white_background" android:summary="@string/pref_use_white_background_summary"
android:summary="@string/pref_use_white_background_summary"/> android:title="@string/pref_use_white_background"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="use_larger_font" android:key="use_larger_font"
@ -142,13 +148,13 @@
android:title="@string/pref_remove_trusted_certificates_title"/> android:title="@string/pref_remove_trusted_certificates_title"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:title="@string/pref_connection_options" android:key="connection_options"
android:key="connection_options"> android:title="@string/pref_connection_options">
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="use_tor" android:key="use_tor"
android:title="@string/pref_use_tor" android:summary="@string/pref_use_tor_summary"
android:summary="@string/pref_use_tor_summary"/> android:title="@string/pref_use_tor"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_input_options"> <PreferenceCategory android:title="@string/pref_input_options">
<CheckBoxPreference <CheckBoxPreference
@ -187,8 +193,8 @@
android:title="@string/pref_keep_foreground_service"/> android:title="@string/pref_keep_foreground_service"/>
<eu.siacs.conversations.ui.ExportLogsPreference <eu.siacs.conversations.ui.ExportLogsPreference
android:key="export_logs" android:key="export_logs"
android:title="@string/pref_export_logs" android:summary="@string/pref_export_logs_summary"
android:summary="@string/pref_export_logs_summary"/> android:title="@string/pref_export_logs"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>