From 1410765d5d08848609b651faef2816540a521109 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 15 Jan 2013 10:10:16 +0100 Subject: [PATCH] Added option to use hash as name for sent pictures --- res/values/non_localizable_custom.xml | 2 ++ src/org/linphone/ChatFragment.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml index 0db3a01c0..12e80b756 100644 --- a/res/values/non_localizable_custom.xml +++ b/res/values/non_localizable_custom.xml @@ -50,6 +50,8 @@ false false + true + false false diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index a54fde846..b7de1fa4e 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -634,6 +634,16 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } } + private long hashBitmap(Bitmap bmp){ + long hash = 31; // Random prime number + for(int x = 0; x < bmp.getWidth(); x++){ + for (int y = 0; y < bmp.getHeight(); y++){ + hash *= (bmp.getPixel(x,y) + 31); + } + } + return hash; + } + private String uploadImage(String filePath, Bitmap file, int compressorQuality, final int imageSize) { String fileName; if (filePath != null) { @@ -643,6 +653,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC fileName = getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())); } + if (getResources().getBoolean(R.bool.hash_images_as_name_before_upload)) { + fileName = String.valueOf(hashBitmap(file)) + ".jpg"; + } + String response = null; HttpURLConnection conn = null; try {