Added cancel for file upload and fix crash when clicking on sent picture

This commit is contained in:
Sylvain Berfini 2015-03-17 10:46:07 +01:00
parent a60126947e
commit a2747d3734
2 changed files with 11 additions and 3 deletions

View file

@ -105,6 +105,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
private LinphoneCoreListenerBase mListener; private LinphoneCoreListenerBase mListener;
private ByteArrayOutputStream mDownloadedImageStream; private ByteArrayOutputStream mDownloadedImageStream;
private int mDownloadedImageStreamSize; private int mDownloadedImageStreamSize;
private LinphoneChatMessage currentMessageInFileTransferUploadState;
public static boolean isInstanciated() { public static boolean isInstanciated() {
return instance != null; return instance != null;
@ -173,9 +174,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
cancelUpload.setOnClickListener(new View.OnClickListener() { cancelUpload.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
uploadLayout.setVisibility(View.GONE); if (currentMessageInFileTransferUploadState != null) {
textLayout.setVisibility(View.VISIBLE); uploadLayout.setVisibility(View.GONE);
progressBar.setProgress(0); textLayout.setVisibility(View.VISIBLE);
progressBar.setProgress(0);
currentMessageInFileTransferUploadState.cancelFileTransfer();
currentMessageInFileTransferUploadState = null;
}
} }
}); });
@ -507,6 +512,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
textLayout.setVisibility(View.GONE); textLayout.setVisibility(View.GONE);
chatRoom.sendChatMessage(message); chatRoom.sendChatMessage(message);
currentMessageInFileTransferUploadState = message;
} else { } else {
Log.e("Error, bitmap factory can't read " + path); Log.e("Error, bitmap factory can't read " + path);
} }
@ -641,6 +647,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
uploadLayout.setVisibility(View.GONE); uploadLayout.setVisibility(View.GONE);
textLayout.setVisibility(View.VISIBLE); textLayout.setVisibility(View.VISIBLE);
progressBar.setProgress(0); progressBar.setProgress(0);
currentMessageInFileTransferUploadState = null;
} }
invalidate(); invalidate();
} }

View file

@ -200,6 +200,7 @@ public class BubbleChat {
} }
} else { } else {
bm = BitmapFactory.decodeFile(appData); bm = BitmapFactory.decodeFile(appData);
appData = "file://" + appData;
} }
if (bm != null) { if (bm != null) {