diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-11-19 22:50:12 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-11-19 22:50:12 +0100 |
commit | 82c15b653c3902a144000079911d69e9b6ce33e0 (patch) | |
tree | 324933be899871debda3692b9b6b34660a46512a /src/main | |
parent | 508e5b589f3e9b8b5208d322b9ff9dc9fff8056a (diff) |
set preference switch to enable, disable or do automatic video compression
automatic = SDK >= Lollipop & video size >= 10 MB (default)
never = never compress videos
always = SDK >= Lollipop
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 17 | ||||
-rw-r--r-- | src/main/res/values/arrays.xml | 12 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/main/res/xml/preferences.xml | 9 |
4 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 92b288494..e41943597 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -544,6 +544,8 @@ public class XmppConnectionService extends Service { File f = new File(FileUtils.getPath(this, uri)); long filesize = f.length(); String path = f.toString(); + final String compressVideos = getCompressVideoPreference(); + boolean sendVideoAsIs = false; final Integer NOTIFICATION_ID = (int) (new Date().getTime()/1000); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext()); @@ -572,7 +574,16 @@ public class XmppConnectionService extends Service { + "_komp.mp4"); final String compressed_path = compressed_file.toString(); final Uri compressed_uri = Uri.fromFile(compressed_file); - if (filesize > Config.VIDEO_MAX_SIZE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + if ("never".equals(compressVideos)) { + sendVideoAsIs = true; + } else if ("always".equals(compressVideos) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + sendVideoAsIs = false; + } else if ("auto".equals(compressVideos) && filesize > Config.VIDEO_MAX_SIZE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + sendVideoAsIs = false; + } else { + sendVideoAsIs = true; + } + if (!sendVideoAsIs){ CompressVideo = new VideoCompressor(path, compressed_path, new Interface() { @Override public void videocompressed(boolean result) { @@ -878,6 +889,10 @@ public class XmppConnectionService extends Service { return getPreferences().getString("picture_compression", "auto"); } + private String getCompressVideoPreference() { + return getPreferences().getString("video_compression", "auto"); + } + private Presence.Status getTargetPresence() { if (xaOnSilentMode() && isPhoneSilenced()) { return Presence.Status.XA; diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index 46a1542eb..b6bd918c5 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -70,6 +70,18 @@ <item>@string/always</item> </string-array> + <string-array name="video_compression_values"> + <item>never</item> + <item>auto</item> + <item>always</item> + </string-array> + + <string-array name="video_compression_entries"> + <item>@string/never</item> + <item>@string/automatically</item> + <item>@string/always</item> + </string-array> + <string-array name="mam_prefs"> <item>@string/never</item> <item>@string/contacts</item> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index b7155abec..3bd18cfbf 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -584,6 +584,8 @@ <string name="notify_paused">Notifications paused</string> <string name="pref_picture_compression">Compress Pictures</string> <string name="pref_picture_compression_summary">Resize and compress pictures</string> + <string name="pref_video_compression">Compress Videos</string> + <string name="pref_video_compression_summary">Resize and compress Videos</string> <string name="always">Always</string> <string name="automatically">Automatically</string> <string name="battery_optimizations_enabled">Battery optimizations enabled</string> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 971dd1b2e..d88df7d38 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -115,6 +115,13 @@ android:key="picture_compression" android:summary="@string/pref_picture_compression_summary" android:title="@string/pref_picture_compression" /> + <ListPreference + android:defaultValue="auto" + android:entries="@array/video_compression_entries" + android:entryValues="@array/video_compression_values" + android:key="video_compression" + android:summary="@string/pref_video_compression_summary" + android:title="@string/pref_video_compression" /> </PreferenceScreen> <!--status--> <PreferenceScreen @@ -264,5 +271,5 @@ android:icon="@drawable/ic_help_black_24dp" android:summary="@string/pref_about_conversations_summary" android:title="@string/title_activity_about" /> - + </PreferenceScreen> |