Updated linphone + fixes for file transfer UI
This commit is contained in:
parent
5d5dfecd0a
commit
d129af2a8e
2 changed files with 48 additions and 46 deletions
|
@ -259,16 +259,20 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
|
|
||||||
String externalBodyUrl = message.getExternalBodyUrl();
|
String externalBodyUrl = message.getExternalBodyUrl();
|
||||||
Content fileTransferContent = message.getFileTransferInformation();
|
Content fileTransferContent = message.getFileTransferInformation();
|
||||||
String appData = message.getAppdata();
|
|
||||||
if (externalBodyUrl != null) { // Incoming file transfer
|
|
||||||
if (appData != null) { // Download already done, just display the result
|
|
||||||
displayAttachedFile(message, holder);
|
|
||||||
} else { // Attachment not yet downloaded
|
|
||||||
holder.fileName.setVisibility(View.VISIBLE);
|
|
||||||
holder.fileName.setText(fileTransferContent.getName());
|
|
||||||
|
|
||||||
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
if (message.getAppdata() != null) { // Something to display
|
||||||
holder.fileTransferProgressBar.setVisibility(View.GONE);
|
displayAttachedFile(message, holder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (externalBodyUrl != null) { // Incoming file transfer not yet downloaded
|
||||||
|
holder.fileName.setVisibility(View.VISIBLE);
|
||||||
|
holder.fileName.setText(fileTransferContent.getName());
|
||||||
|
|
||||||
|
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
||||||
|
holder.fileTransferProgressBar.setVisibility(View.GONE);
|
||||||
|
if (message.getState() == ChatMessage.State.InProgress && message.getFileTransferFilepath() != null) { // Incoming file transfer in progress
|
||||||
|
holder.fileTransferAction.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
holder.fileTransferAction.setText(mContext.getString(R.string.accept));
|
holder.fileTransferAction.setText(mContext.getString(R.string.accept));
|
||||||
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -277,7 +281,6 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
v.setEnabled(false);
|
v.setEnabled(false);
|
||||||
String filename = message.getFileTransferInformation().getName();
|
String filename = message.getFileTransferInformation().getName();
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
||||||
message.setAppdata(file.getPath());
|
|
||||||
message.setListener(ChatEventsAdapter.this);
|
message.setListener(ChatEventsAdapter.this);
|
||||||
message.setFileTransferFilepath(file.getPath());
|
message.setFileTransferFilepath(file.getPath());
|
||||||
message.downloadFile();
|
message.downloadFile();
|
||||||
|
@ -288,26 +291,19 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (fileTransferContent != null) { // Outgoing file transfer
|
} else if (message.getState() == ChatMessage.State.InProgress && message.getFileTransferFilepath() != null) { // Outgoing file transfer in progress
|
||||||
if (appData != null) {
|
message.setListener(this); // add the listener for file upload progress display
|
||||||
displayAttachedFile(message, holder);
|
holder.messageSendingInProgress.setVisibility(View.GONE);
|
||||||
}
|
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
||||||
|
holder.fileTransferAction.setText(mContext.getString(R.string.cancel));
|
||||||
holder.fileTransferLayout.setVisibility(View.GONE);
|
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
||||||
if (message.getState() == ChatMessage.State.InProgress && message.getFileTransferFilepath() != null) { // Only for file transfer InProgress state
|
@Override
|
||||||
message.setListener(this); // add the listener for file upload progress display
|
public void onClick(View v) {
|
||||||
holder.messageSendingInProgress.setVisibility(View.GONE);
|
message.cancelFileTransfer();
|
||||||
holder.fileTransferLayout.setVisibility(View.VISIBLE);
|
notifyDataSetChanged();
|
||||||
holder.fileTransferAction.setText(mContext.getString(R.string.cancel));
|
}
|
||||||
holder.fileTransferAction.setOnClickListener(new View.OnClickListener() {
|
});
|
||||||
@Override
|
}
|
||||||
public void onClick(View v) {
|
|
||||||
message.cancelFileTransfer();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.bubbleLayout.setLayoutParams(layoutParams);
|
holder.bubbleLayout.setLayoutParams(layoutParams);
|
||||||
} else { // Event is not chat message
|
} else { // Event is not chat message
|
||||||
|
@ -405,19 +401,21 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
holder.fileName.setText(message.getFileTransferInformation().getName());
|
holder.fileName.setText(message.getFileTransferInformation().getName());
|
||||||
|
|
||||||
String appData = message.getAppdata();
|
String appData = message.getAppdata();
|
||||||
if (LinphoneUtils.isExtensionImage(appData)) {
|
if (appData != null) {
|
||||||
holder.messageImage.setVisibility(View.VISIBLE);
|
if (LinphoneUtils.isExtensionImage(appData)) {
|
||||||
loadBitmap(appData, holder.messageImage);
|
holder.messageImage.setVisibility(View.VISIBLE);
|
||||||
holder.messageImage.setTag(appData);
|
loadBitmap(appData, holder.messageImage);
|
||||||
} else {
|
holder.messageImage.setTag(appData);
|
||||||
holder.openFileButton.setVisibility(View.VISIBLE);
|
} else {
|
||||||
holder.openFileButton.setTag(appData);
|
holder.openFileButton.setVisibility(View.VISIBLE);
|
||||||
holder.openFileButton.setOnClickListener(new View.OnClickListener() {
|
holder.openFileButton.setTag(appData);
|
||||||
@Override
|
holder.openFileButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
openFile((String)v.getTag());
|
public void onClick(View v) {
|
||||||
}
|
openFile((String) v.getTag());
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +441,8 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
if (offset == total) {
|
if (offset == total) {
|
||||||
holder.fileTransferProgressBar.setVisibility(View.GONE);
|
holder.fileTransferProgressBar.setVisibility(View.GONE);
|
||||||
holder.fileTransferLayout.setVisibility(View.GONE);
|
holder.fileTransferLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
displayAttachedFile(message, holder);
|
displayAttachedFile(message, holder);
|
||||||
message.setFileTransferFilepath(null); // Not needed anymore, will help differenciate between InProgress states for file transfer / message sending
|
|
||||||
} else {
|
} else {
|
||||||
holder.fileTransferProgressBar.setVisibility(View.VISIBLE);
|
holder.fileTransferProgressBar.setVisibility(View.VISIBLE);
|
||||||
holder.fileTransferProgressBar.setProgress(offset * 100 / total);
|
holder.fileTransferProgressBar.setProgress(offset * 100 / total);
|
||||||
|
@ -452,7 +450,11 @@ public class ChatEventsAdapter extends ListSelectionAdapter implements ChatMessa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMsgStateChanged(ChatMessage msg, ChatMessage.State state) {
|
public void onMsgStateChanged(ChatMessage message, ChatMessage.State state) {
|
||||||
|
if (state == ChatMessage.State.FileTransferDone && !message.isOutgoing()) {
|
||||||
|
message.setAppdata(message.getFileTransferFilepath());
|
||||||
|
message.setFileTransferFilepath(null); // Not needed anymore, will help differenciate between InProgress states for file transfer / message sending
|
||||||
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 71c5088307a50a4bd424e63b27b2698381490eec
|
Subproject commit 52f13d34d0d9a687a25862ee56701a287933209d
|
Loading…
Reference in a new issue