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) {
if (getFileBackend().useImageAsIs(uri)) {
Log.d(Config.LOGTAG, "using image as is");
final String compressPictures = getCompressPicturesPreference();
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);
return;
}
@ -590,6 +592,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return getPreferences().getBoolean("away_when_screen_off", false);
}
private String getCompressPicturesPreference() {
return getPreferences().getString("picture_compression", "auto");
}
private int getTargetPresence() {
if (xaOnSilentMode() && isPhoneSilenced()) {
return Presences.XA;

View File

@ -57,4 +57,16 @@
<item>voice</item>
<item>location</item>
</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>

View File

@ -287,7 +287,7 @@
<string name="pref_about_conversations_summary">Build and licensing information</string>
<string name="pref_about_message" translatable="false">
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
it under the terms of the GNU General Public License as published by
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_never">Notifications disabled</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>

View File

@ -22,7 +22,13 @@
android:key="auto_accept_file_size"
android:summary="@string/pref_accept_files_summary"
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
android:defaultValue="true"
android:key="confirm_messages"
@ -92,8 +98,8 @@
<CheckBoxPreference
android:defaultValue="false"
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
android:defaultValue="false"
android:key="use_larger_font"
@ -142,13 +148,13 @@
android:title="@string/pref_remove_trusted_certificates_title"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_connection_options"
android:key="connection_options">
android:key="connection_options"
android:title="@string/pref_connection_options">
<CheckBoxPreference
android:defaultValue="false"
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 android:title="@string/pref_input_options">
<CheckBoxPreference
@ -186,9 +192,9 @@
android:summary="@string/pref_keep_foreground_service_summary"
android:title="@string/pref_keep_foreground_service"/>
<eu.siacs.conversations.ui.ExportLogsPreference
android:key="export_logs"
android:title="@string/pref_export_logs"
android:summary="@string/pref_export_logs_summary"/>
android:key="export_logs"
android:summary="@string/pref_export_logs_summary"
android:title="@string/pref_export_logs"/>
</PreferenceCategory>
</PreferenceScreen>