fixed crash and photo upload
This commit is contained in:
@@ -24,6 +24,10 @@ public class MediaImageEncoder {
|
||||
return compressBitmap(bitmap, file, CompressFormat.JPEG, quality);
|
||||
}
|
||||
|
||||
public static boolean needToCompress() {
|
||||
return Preferences.getPreferences().getBoolean("compressPhotos", true);
|
||||
}
|
||||
|
||||
private static boolean compressBitmapNative(Bitmap bitmap, File file, int quality) {
|
||||
if (MediaNative.isX86() || MediaNative.isAsus() || Build.VERSION.SDK_INT < 24) {
|
||||
Log.e(MediaImageEncoder.class.getSimpleName(), "JPEG turbo not supported on this device!");
|
||||
@@ -53,12 +57,8 @@ public class MediaImageEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean needToSkipCompression() {
|
||||
return !Preferences.getPreferences().getBoolean("compressPhotos", true);
|
||||
}
|
||||
|
||||
public static boolean encodeJpeg(Bitmap bitmap, File file) {
|
||||
return encodePicture(bitmap, file, Preferences.compress(90));
|
||||
return encodePicture(bitmap, file, Preferences.compress(85));
|
||||
}
|
||||
|
||||
public static boolean encodeJpegWithoutCompression(Bitmap bitmap, File file) {
|
||||
@@ -66,10 +66,6 @@ public class MediaImageEncoder {
|
||||
}
|
||||
|
||||
public static boolean encodeJpeg(Bitmap bitmap, File file, int quality) {
|
||||
if (bitmap != null && !bitmap.isRecycled() && bitmap.getWidth() * bitmap.getHeight() != 0) {
|
||||
return compressBitmapNative(bitmap, file, quality);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return encodePicture(bitmap, file, Preferences.compress(85));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class TogglesHook {
|
||||
case FEATURE_MILKSHAKE_FORCE_DISABLED, FEATURE_MILKSHAKE_ACTIVATION_DISABLED -> !milkshake();
|
||||
case AB_NEWS_VIDEO_LAYOUT_TEXT, FEATURE_COMPACT_REPOST, EXPERIMENT_NEWS_VIDEO_LAYOUT_TEXT ->
|
||||
postsredesign();
|
||||
case FEATURE_IMAGE_QUALITY_UPGRADE -> MediaImageEncoder.needToSkipCompression();
|
||||
case FEATURE_IMAGE_QUALITY_UPGRADE -> !MediaImageEncoder.needToCompress();
|
||||
case FEATURE_MENU_GAMES_CAROUSEL -> miniapps();
|
||||
case FEATURE_TRAFFIC_SAVER -> !disableForceTrafficSaver();
|
||||
default -> true;
|
||||
|
||||
@@ -356,6 +356,6 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static int compress(int origquality) {
|
||||
return MediaImageEncoder.needToSkipCompression() ? 100 : origquality;
|
||||
return MediaImageEncoder.needToCompress() ? origquality : 100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ public class VTSettings extends TrackedMaterialPreferenceToolbarFragment {
|
||||
getPreferenceScreen(),
|
||||
"",
|
||||
requireContext().getString(R.string.vtlmedia),
|
||||
getValAsString(R.string.sett_compress_photos, MediaImageEncoder.needToSkipCompression()),
|
||||
getValAsString(R.string.sett_compress_photos, MediaImageEncoder.needToCompress()),
|
||||
R.drawable.ic_media_outline_28,
|
||||
preference -> {
|
||||
NavigatorUtils.switchFragment(requireContext(), MediaFragment.class);
|
||||
|
||||
@@ -119,13 +119,6 @@
|
||||
.method protected w()Ljava/lang/String;
|
||||
.locals 3
|
||||
|
||||
invoke-static {}, Lcom/vk/medianative/MediaImageEncoder;->needToCompress()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-eqz v0, :cond_0
|
||||
|
||||
.line 2
|
||||
iget-object v0, p0, Lcom/vtosters/lite/upload/l/PhotoUploadTask;->l:Lcom/vtosters/lite/upload/UploadCompressStrategy;
|
||||
|
||||
iget-object v1, p0, Lcom/vtosters/lite/upload/l/HTTPFileUploadTask;->f:Ljava/lang/String;
|
||||
@@ -138,11 +131,5 @@
|
||||
|
||||
move-result-object v0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:cond_0
|
||||
const/4 v0, 0x0
|
||||
|
||||
:goto_0
|
||||
return-object v0
|
||||
.end method
|
||||
|
||||
Reference in New Issue
Block a user