Added option to use hash as name for sent pictures

This commit is contained in:
Sylvain Berfini 2013-01-15 10:10:16 +01:00
parent 55e3400a54
commit 1410765d5d
2 changed files with 16 additions and 0 deletions

View file

@ -50,6 +50,8 @@
<bool name="forbid_self_call">false</bool>
<bool name="disable_chat">false</bool>
<bool name="hash_images_as_name_before_upload">true</bool>
<bool name="disable_all_security_features_for_markets">false</bool> <!-- Disable TLS/SRTP/ZRTP -->
<bool name="disable_all_patented_codecs_for_markets">false</bool> <!-- Disable MPEG4/H264 -->

View file

@ -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 {