aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java7
-rw-r--r--src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java13
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java8
-rw-r--r--src/main/res/values/arrays.xml4
-rw-r--r--src/main/res/values/strings.xml2
5 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 2703f0538..705e5489b 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -294,9 +294,12 @@ public class FileBackend {
}
File file = new File(path);
long size = file.length();
- if (size == 0 || size >= mXmppConnectionService.getCompressImageSizePreference()) {
+ if ((size == 0 || size >= mXmppConnectionService.getCompressImageSizePreference()) && mXmppConnectionService.getCompressImageSizePreference() != 0) {
return false;
}
+ if (mXmppConnectionService.getCompressImageResolutionPreference() == 0 && mXmppConnectionService.getCompressImageSizePreference() == 0 ) {
+ return true;
+ }
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
@@ -450,7 +453,7 @@ public class FileBackend {
throw new FileCopyException(R.string.error_compressing_image);
}
os.flush();
- targetSizeReached = file.length() <= mXmppConnectionService.getCompressImageSizePreference() || quality <= 50;
+ targetSizeReached = (file.length() <= mXmppConnectionService.getCompressImageSizePreference() && mXmppConnectionService.getCompressImageSizePreference() != 0) || quality <= 50;
quality -= 5;
}
scaledBitmap.recycle();
diff --git a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
index 192d9221d..993de3bc6 100644
--- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
+++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
@@ -49,12 +49,11 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService, uri);
this.isVideoMessage = !getFileBackend().useFileAsIs(uri)
&& (mimeType != null && mimeType.startsWith("video/")
- && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
+ && (mXmppConnectionService.getCompressVideoBitratePreference() != 0 && mXmppConnectionService.getCompressVideoResolutionPreference() != 0))
&& originalFileSize > autoAcceptFileSize;
-
}
- public boolean isVideoMessage() {
+ boolean isVideoMessage() {
return this.isVideoMessage && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
}
@@ -110,8 +109,12 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
mXmppConnectionService.stopForcingForegroundNotification();
throw new AssertionError(e);
} catch (ExecutionException e) {
- mXmppConnectionService.stopForcingForegroundNotification();
- Log.d(Config.LOGTAG, "ignoring execution exception. Should get handled by onTranscodeFiled() instead", e);
+ if (e.getCause() instanceof Error) {
+ mXmppConnectionService.stopForcingForegroundNotification();
+ processAsFile();
+ } else {
+ Log.d(Config.LOGTAG, "ignoring execution exception. Should get handled by onTranscodeFiled() instead", e);
+ }
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index f36321b04..98e330ad0 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -893,6 +893,8 @@ public class XmppConnectionService extends Service {
return 1920;
case "high":
return 3840;
+ case "uncompressed":
+ return 0;
default:
return 3840;
}
@@ -906,6 +908,8 @@ public class XmppConnectionService extends Service {
return 524288; // 0.5 * 1024 * 1024 = 524288 (0.5 MiB)
case "high":
return 1048576; // 1 * 1024 * 1024 = 1048576 (1 MiB)
+ case "uncompressed":
+ return 0;
default:
return 524288;
}
@@ -919,6 +923,8 @@ public class XmppConnectionService extends Service {
return 360;
case "high":
return 720;
+ case "uncompressed":
+ return 0;
default:
return 360;
}
@@ -932,6 +938,8 @@ public class XmppConnectionService extends Service {
return 500000;
case "high":
return 2000000;
+ case "uncompressed":
+ return 0;
default:
return 500000;
}
diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml
index 93da9bac4..de2e0355c 100644
--- a/src/main/res/values/arrays.xml
+++ b/src/main/res/values/arrays.xml
@@ -58,24 +58,28 @@
<item>low</item>
<item>mid</item>
<item>high</item>
+ <item>uncompressed</item>
</string-array>
<string-array name="image_compression_entries">
<item>@string/image_low</item>
<item>@string/image_mid</item>
<item>@string/image_high</item>
+ <item>@string/image_original</item>
</string-array>
<string-array name="video_compression_values">
<item>low</item>
<item>mid</item>
<item>high</item>
+ <item>uncompressed</item>
</string-array>
<string-array name="video_compression_entries">
<item>@string/video_low</item>
<item>@string/video_mid</item>
<item>@string/video_high</item>
+ <item>@string/video_original</item>
</string-array>
<string-array name="mam_prefs">
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 015a2a6c6..5d0160b7a 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -506,6 +506,7 @@
<string name="video_low">low (144p)</string>
<string name="video_mid">middle (360p)</string>
<string name="video_high">high (720p)</string>
+ <string name="video_original">Original (uncompressed)</string>
<string name="always">Always</string>
<string name="battery_optimizations_enabled">Battery optimizations enabled</string>
<string name="battery_optimizations_enabled_explained">Your device is doing some heavy battery optimizations on Pix-Art Messenger that might lead to delayed notifications or even message loss.\nIt is recommended to disable those.</string>
@@ -681,6 +682,7 @@
<string name="image_low">low (720p)</string>
<string name="image_mid">middle (1920p)</string>
<string name="image_high">high (3840p)</string>
+ <string name="image_original">original (uncompressed)</string>
<string name="last_seen_just_away">recently</string>
<string name="send_message">Send message</string>
<string name="send_failed_resend">delivery failed, resending…</string>