Added spinner while downloading incoming file

This commit is contained in:
Sylvain Berfini 2019-02-21 09:08:16 +01:00
parent 548128ea48
commit a3c14faeb0
4 changed files with 22 additions and 19 deletions

View file

@ -181,7 +181,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private BroadcastReceiver mKeepAliveReceiver; private BroadcastReceiver mKeepAliveReceiver;
private BroadcastReceiver mHookReceiver; private BroadcastReceiver mHookReceiver;
private BroadcastReceiver mCallReceiver; private BroadcastReceiver mCallReceiver;
private BroadcastReceiver mNetworkReceiver;
private IntentFilter mKeepAliveIntentFilter; private IntentFilter mKeepAliveIntentFilter;
private IntentFilter mHookIntentFilter; private IntentFilter mHookIntentFilter;
private IntentFilter mCallIntentFilter; private IntentFilter mCallIntentFilter;
@ -669,13 +668,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.e("[Manager] Destroy Core Runtime Exception: " + e); Log.e("[Manager] Destroy Core Runtime Exception: " + e);
} finally { } finally {
try {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
mServiceContext.unregisterReceiver(mNetworkReceiver);
}
} catch (Exception e) {
Log.e("[Manager] unregister receiver exception: " + e);
}
try { try {
mServiceContext.unregisterReceiver(mHookReceiver); mServiceContext.unregisterReceiver(mHookReceiver);
} catch (Exception e) { } catch (Exception e) {

View file

@ -74,7 +74,7 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
public final LinearLayout background; public final LinearLayout background;
public final RelativeLayout avatarLayout; public final RelativeLayout avatarLayout;
public final ProgressBar sendInProgress; public final ProgressBar downloadInProgress, sendInProgress;
public final TextView timeText; public final TextView timeText;
public final ImageView outgoingImdn; public final ImageView outgoingImdn;
public final TextView messageText; public final TextView messageText;
@ -108,6 +108,7 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
background = view.findViewById(R.id.background); background = view.findViewById(R.id.background);
avatarLayout = view.findViewById(R.id.avatar_layout); avatarLayout = view.findViewById(R.id.avatar_layout);
downloadInProgress = view.findViewById(R.id.download_in_progress);
sendInProgress = view.findViewById(R.id.send_in_progress); sendInProgress = view.findViewById(R.id.send_in_progress);
timeText = view.findViewById(R.id.time); timeText = view.findViewById(R.id.time);
outgoingImdn = view.findViewById(R.id.imdn); outgoingImdn = view.findViewById(R.id.imdn);
@ -136,6 +137,7 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
outgoingImdn.setVisibility(View.GONE); outgoingImdn.setVisibility(View.GONE);
avatarLayout.setVisibility(View.GONE); avatarLayout.setVisibility(View.GONE);
sendInProgress.setVisibility(View.GONE); sendInProgress.setVisibility(View.GONE);
downloadInProgress.setVisibility(View.GONE);
pictures.setVisibility(View.GONE); pictures.setVisibility(View.GONE);
pictures.removeAllViews(); pictures.removeAllViews();
@ -176,6 +178,10 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
// Can't anchor incoming messages, setting this to align max width with LIME icon // Can't anchor incoming messages, setting this to align max width with LIME icon
bubbleLayout.setPadding( bubbleLayout.setPadding(
0, 0, (int) ImageUtils.dpToPixels(LinphoneActivity.instance(), 16), 0); 0, 0, (int) ImageUtils.dpToPixels(LinphoneActivity.instance(), 16), 0);
if (status == ChatMessage.State.InProgress) {
downloadInProgress.setVisibility(View.VISIBLE);
}
} }
if (contact == null) { if (contact == null) {
@ -221,12 +227,9 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
LayoutInflater.from(mContext) LayoutInflater.from(mContext)
.inflate(R.layout.chat_bubble_content, null, false); .inflate(R.layout.chat_bubble_content, null, false);
if (c.isFile() if (c.isFile() || (c.isFileTransfer() && message.isOutgoing())) {
|| (c.isFileTransfer() // If message is outgoing, even if content
&& message // is file transfer we have the file available
.isOutgoing())) { // If message is outgoing, even if content
// is file transfer we have the file
// available
String filePath = c.getFilePath(); String filePath = c.getFilePath();
View v; View v;

View file

@ -455,8 +455,8 @@ public class ChatMessagesFragment extends Fragment
if (message.getAppdata() != null && !message.isOutgoing()) { if (message.getAppdata() != null && !message.isOutgoing()) {
File file = new File(message.getAppdata()); File file = new File(message.getAppdata());
if (file.exists()) { if (file.exists()) {
file.delete(); // Delete downloaded file from incoming message that will // Delete downloaded file from incoming message that will be deleted
// be deleted file.delete();
} }
} }
} }

View file

@ -109,6 +109,15 @@
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/download_in_progress"
android:visibility="gone"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_toRightOf="@id/background"
android:layout_alignBottom="@id/background"
android:indeterminateTint="@color/colorA" />
<RelativeLayout <RelativeLayout
android:id="@+id/message_sender_avatar" android:id="@+id/message_sender_avatar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -160,8 +169,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:indeterminateTint="@color/colorA" android:indeterminateTint="@color/colorA" />
android:src="@drawable/imdn_received" />
</RelativeLayout> </RelativeLayout>