fix sending uncompressed files

This commit is contained in:
Christian Schneppe 2020-01-31 14:29:55 +01:00
parent 83c976f2d7
commit b0d0f904a2
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
3 changed files with 5 additions and 16 deletions

View file

@ -572,10 +572,9 @@ public class XmppConnectionService extends Service {
public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) {
final String mimeType = MimeUtils.guessMimeTypeFromUri(this, uri);
final String compressPictures = getCompressPicturesPreference();
if ("never".equals(compressPictures)
|| ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri))
final boolean compressPictures = getCompressImageResolutionPreference() != 0;
if (!compressPictures
|| getFileBackend().useImageAsIs(uri)
|| (mimeType != null && mimeType.endsWith("/gif"))
|| getFileBackend().unusualBounds(uri)) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": not compressing picture. sending as file");
@ -1000,12 +999,8 @@ public class XmppConnectionService extends Service {
return getBooleanPreference(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, R.bool.away_when_screen_off);
}
private String getCompressPicturesPreference() {
return getPreferences().getString("picture_compression", getResources().getString(R.string.picture_compression));
}
public int getCompressImageResolutionPreference() {
switch (getPreferences().getString("image_compression", getResources().getString(R.string.picture_compression))) {
switch (getPreferences().getString("image_compression", getResources().getString(R.string.image_compression))) {
case "low":
return 720;
case "mid":
@ -1020,7 +1015,7 @@ public class XmppConnectionService extends Service {
}
public int getCompressImageSizePreference() {
switch (getPreferences().getString("image_compression", getResources().getString(R.string.picture_compression))) {
switch (getPreferences().getString("image_compression", getResources().getString(R.string.image_compression))) {
case "low":
return 209715; // 0.2 * 1024 * 1024 = 209715 (0.2 MiB)
case "mid":

View file

@ -3,7 +3,6 @@ package de.pixart.messenger.ui;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlertDialog.Builder;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
@ -973,10 +972,6 @@ public abstract class XmppActivity extends ActionBarActivity {
return false;
}
protected boolean neverCompressPictures() {
return getPreferences().getString("picture_compression", getResources().getString(R.string.picture_compression)).equals("never");
}
protected boolean manuallyChangePresence() {
return getBooleanPreference(SettingsActivity.MANUALLY_CHANGE_PRESENCE, R.bool.manually_change_presence);
}

View file

@ -63,7 +63,6 @@
<integer name="grace_period">144</integer>
<string name="default_resource" translatable="false">Phone</string>
<string name="notification_ringtone">content://settings/system/notification_sound</string>
<string name="picture_compression">auto</string>
<string name="image_compression">mid</string>
<string name="video_compression">mid</string>
<string name="quick_action">recent</string>