We decided not to show the picture in message's IMDN view as it takes too much space + fixed selector

This commit is contained in:
Sylvain Berfini 2018-03-28 15:39:53 +02:00
parent eca9abcdc6
commit e63759ee59
2 changed files with 2 additions and 67 deletions

View file

@ -855,6 +855,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
case CREATE_CHAT:
case GROUP_CHAT:
case INFO_GROUP_CHAT:
case MESSAGE_IMDN:
case CHAT:
chat_selected.setVisibility(View.VISIBLE);
break;

View file

@ -20,14 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
package org.linphone.chat;
import android.app.Fragment;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
@ -50,10 +43,6 @@ import org.linphone.core.Address;
import org.linphone.core.ChatMessage;
import org.linphone.core.ChatRoom;
import org.linphone.core.Core;
import org.linphone.mediastream.Log;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ImdnFragment extends Fragment {
private LayoutInflater mInflater;
@ -157,14 +146,7 @@ public class ImdnFragment extends Fragment {
if (appData != null) { // Something to display
mBubble.fileName.setVisibility(View.VISIBLE);
mBubble.fileName.setText(LinphoneUtils.getNameFromFilePath(appData));
if (LinphoneUtils.isExtensionImage(appData)) {
mBubble.messageImage.setVisibility(View.VISIBLE);
mBubble.messageImage.setImageBitmap(loadBitmap(appData));
mBubble.messageImage.setTag(appData);
} else {
mBubble.openFileButton.setVisibility(View.VISIBLE);
mBubble.openFileButton.setTag(appData);
}
// We purposely chose not to display the image
}
// TODO: real values
@ -190,52 +172,4 @@ public class ImdnFragment extends Fragment {
return view;
}
private Bitmap loadBitmap(String path) {
Bitmap bm = null;
Bitmap thumbnail = null;
if (LinphoneUtils.isExtensionImage(path)) {
if (path.startsWith("content")) {
try {
bm = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), Uri.parse(path));
} catch (FileNotFoundException e) {
Log.e(e);
} catch (IOException e) {
Log.e(e);
}
} else {
bm = BitmapFactory.decodeFile(path);
}
// Rotate the bitmap if possible/needed, using EXIF data
try {
android.graphics.Bitmap bm_tmp;
ExifInterface exif = new ExifInterface(path);
int pictureOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
Matrix matrix = new Matrix();
if (pictureOrientation == 6) {
matrix.postRotate(90);
} else if (pictureOrientation == 3) {
matrix.postRotate(180);
} else if (pictureOrientation == 8) {
matrix.postRotate(270);
}
bm_tmp = android.graphics.Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
if (bm_tmp != bm) {
bm.recycle();
bm = bm_tmp;
}
} catch (Exception e) {
Log.e(e);
}
if (bm != null) {
thumbnail = ThumbnailUtils.extractThumbnail(bm, 500, 500);
bm.recycle();
}
return thumbnail;
} else {
return BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.avatar);
}
}
}