diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-12-14 22:03:33 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-12-14 22:04:42 +0100 |
commit | 155332f65b5fc5baaaff845f2c288056d7ae12ec (patch) | |
tree | f2d55cb9fe796c6dee67c02355706ddc7738df1f /src/main/java/de/pixart/messenger | |
parent | 7df333bf2a8aad44f082ac6a6a9ee49948ce36d7 (diff) |
limit video transcoding to api >= 18 and other api 16 fixes
Diffstat (limited to '')
5 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index ddc0e6ee8..5efadd3ff 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -21,6 +21,7 @@ import android.os.Environment; import android.os.ParcelFileDescriptor; import android.provider.MediaStore; import android.provider.OpenableColumns; +import android.support.annotation.RequiresApi; import android.support.v4.content.FileProvider; import android.system.Os; import android.system.StructStat; @@ -1158,7 +1159,12 @@ public class FileBackend { if (dimensions != null) { return dimensions; } - int rotation = extractRotationFromMediaRetriever(metadataRetriever); + final int rotation; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + rotation = extractRotationFromMediaRetriever(metadataRetriever); + } else { + rotation = 0; + } boolean rotated = rotation == 90 || rotation == 270; int height; try { @@ -1179,6 +1185,7 @@ public class FileBackend { return rotated ? new Dimensions(width, height) : new Dimensions(height, width); } + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) private static int extractRotationFromMediaRetriever(MediaMetadataRetriever metadataRetriever) { String r = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION); try { diff --git a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java index 1581638ae..d2f623c45 100644 --- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java +++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java @@ -3,6 +3,7 @@ package de.pixart.messenger.services; import android.net.Uri; import android.os.Build; import android.os.ParcelFileDescriptor; +import android.support.annotation.RequiresApi; import android.util.Log; import net.ypresto.androidtranscoder.MediaTranscoder; @@ -54,7 +55,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod } public boolean isVideoMessage() { - return this.isVideoMessage; + return this.isVideoMessage && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; } private void processAsFile() { @@ -89,6 +90,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod } } + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) private void processAsVideo() throws FileNotFoundException { Log.d(Config.LOGTAG, "processing file as video"); mXmppConnectionService.startForcingForegroundNotification(); @@ -161,7 +163,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod @Override public void run() { - if (isVideoMessage) { + if (this.isVideoMessage()) { try { processAsVideo(); } catch (FileNotFoundException e) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index d87377b72..e5ad20447 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1764,7 +1764,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke case ATTACHMENT_CHOICE_CHOOSE_FILE: chooser = true; intent.setType("*/*"); - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setAction(Intent.ACTION_GET_CONTENT); break; diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index f1eaf4b61..40cd5ee09 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -276,6 +276,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio private void openBatteryOptimizationDialogIfNeeded() { if (hasAccountWithoutPush() && isOptimizingBattery() + && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.battery_optimizations_enabled); diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index ca7f0285a..bb579b8f1 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -1251,7 +1251,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private void showOsOptimizationWarning(boolean showBatteryWarning, boolean showDataSaverWarning) { this.binding.osOptimization.setVisibility(showBatteryWarning || showDataSaverWarning ? View.VISIBLE : View.GONE); - if (showDataSaverWarning) { + if (showDataSaverWarning && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { this.binding.osOptimizationHeadline.setText(R.string.data_saver_enabled); this.binding.osOptimizationBody.setText(R.string.data_saver_enabled_explained); this.binding.osOptimizationDisable.setText(R.string.allow); @@ -1265,7 +1265,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat Toast.makeText(EditAccountActivity.this, R.string.device_does_not_support_data_saver, Toast.LENGTH_SHORT).show(); } }); - } else if (showBatteryWarning) { + } else if (showBatteryWarning && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { this.binding.osOptimizationDisable.setText(R.string.disable); this.binding.osOptimizationHeadline.setText(R.string.battery_optimizations_enabled); this.binding.osOptimizationBody.setText(R.string.battery_optimizations_enabled_explained); |