From 46fdef05ba19a87739a7fbffdc9fad1d1c45cd9c Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 9 Jul 2018 13:47:11 +0200 Subject: [PATCH 001/247] Feature #9774: Management of group calls --- .../fcm/ChatAdvancedNotificationBuilder.java | 4 +- .../megachat/ChatActivityLollipop.java | 2 +- .../lollipop/megachat/calls/CallService.java | 2 +- .../megachat/calls/ChatCallActivity.java | 55 ++++++++++++------- .../calls/LocalCameraCallFragment.java | 18 +++++- .../LocalCameraCallFullScreenFragment.java | 18 +++++- .../MegaListChatLollipopAdapter.java | 1 - 7 files changed, 71 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java b/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java index 2f29c8d2f1c..ed58fc2aff1 100644 --- a/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java +++ b/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java @@ -760,7 +760,7 @@ public void checkQueuedCalls(){ MegaChatCall call = megaChatApi.getChatCall(handleList.get(i)); if(call!=null){ log("Call ChatID: "+call.getChatid()+" Status: "+call.getStatus()); - if((call.getStatus()>=MegaChatCall.CALL_STATUS_IN_PROGRESS) && (call.getStatus()=MegaChatCall.CALL_STATUS_IN_PROGRESS) && (call.getStatus() Date: Fri, 13 Jul 2018 11:09:26 +0200 Subject: [PATCH 002/247] Feature#9775- Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 2 ++ .../app/lollipop/megachat/calls/LocalCameraCallFragment.java | 2 +- .../megachat/calls/LocalCameraCallFullScreenFragment.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 56a672ac6c4..49dfb65857b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1168,6 +1168,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ updateSubTitle(); } + updateRemoteVideoStatus(); + updateRemoteAudioStatus(); } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ log("Remote flags have changed"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java index b9c199c8e87..c6970ff8cda 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java @@ -52,7 +52,7 @@ public void onCreate (Bundle savedInstanceState){ } Bundle args = getArguments(); - this.chatId = args.getInt("chatId", -1); + this.chatId = args.getLong("chatId", -1); super.onCreate(savedInstanceState); log("after onCreate called super"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java index 3d4021d7873..1a037486161 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java @@ -52,7 +52,7 @@ public void onCreate (Bundle savedInstanceState){ } Bundle args = getArguments(); - this.chatId = args.getInt("chatId", -1); + this.chatId = args.getLong("chatId", -1); super.onCreate(savedInstanceState); log("after onCreate called super"); From 928631d8f398680475127d3a881be948526773c4 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 13 Jul 2018 14:35:16 +0200 Subject: [PATCH 003/247] Feature#9775- Group calls UI --- .../megachat/calls/ChatCallActivity.java | 171 +++++++++--------- .../RemoteCameraCallFullScreenFragment.java | 160 ++++++++++++++++ .../main/res/layout/activity_calls_chat.xml | 27 ++- ...ragment_remote_camera_call_full_screen.xml | 15 ++ 4 files changed, 282 insertions(+), 91 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java create mode 100644 app/src/main/res/layout/fragment_remote_camera_call_full_screen.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 49dfb65857b..d0dcf4ebe82 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -103,7 +103,7 @@ import static android.view.View.GONE; import static mega.privacy.android.app.utils.Util.context; -public class ChatCallActivity extends AppCompatActivity implements MegaChatRequestListenerInterface,View.OnTouchListener, MegaChatCallListenerInterface, MegaChatVideoListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback { +public class ChatCallActivity extends AppCompatActivity implements MegaChatRequestListenerInterface,View.OnTouchListener, MegaChatCallListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback { DatabaseHandler dbH = null; ChatItemPreferences chatPrefs = null; @@ -114,14 +114,8 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque public static int REMOTE_VIDEO_ENABLED = 1; public static int REMOTE_VIDEO_DISABLED = 0; - private LocalCameraCallFragment localCameraFragment; - private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; - float widthScreenPX, heightScreenPX; - ViewGroup parent; - ViewGroup parentFS; - // flagMyAvatar if true - small avatar circle is contact's avatar // flagMyAvatar if false - small avatar circle is my avatar boolean flagMyAvatar; @@ -178,13 +172,20 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FloatingActionButton hangFAB; FloatingActionButton answerCallFAB; - SurfaceView remoteSurfaceView; - MegaSurfaceRenderer remoteRenderer; AudioManager audioManager; MediaPlayer thePlayer; FrameLayout fragmentContainerLocalCamera; FrameLayout fragmentContainerLocalCameraFS; + FrameLayout fragmentContainerRemoteCameraFS; + + ViewGroup parent; + ViewGroup parentFS; + ViewGroup parentRemoteFS; + + private LocalCameraCallFragment localCameraFragment; + private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; + private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; float heightFAB; @@ -523,13 +524,10 @@ protected void onCreate(Bundle savedInstanceState) { hangFAB.setVisibility(GONE); shake = AnimationUtils.loadAnimation(this, R.anim.shake); - - remoteSurfaceView = (SurfaceView)findViewById(R.id.surface_remote_video); - remoteRenderer = new MegaSurfaceRenderer(remoteSurfaceView); rtcAudioManager = AppRTCAudioManager.create(getApplicationContext()); - remoteSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT); - parent = (ViewGroup) findViewById(R.id.parentLayout); + //Local camera small + parent = (ViewGroup) findViewById(R.id.parent_layout); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)fragmentContainerLocalCamera.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); @@ -539,16 +537,27 @@ protected void onCreate(Bundle savedInstanceState) { parent.setVisibility(View.GONE); fragmentContainerLocalCamera.setVisibility(View.GONE); - parentFS = (ViewGroup) findViewById(R.id.parentLayoutFS); + //Local camera Full Screen + parentFS = (ViewGroup) findViewById(R.id.parent_layout_local_camera_FS); fragmentContainerLocalCameraFS = (FrameLayout) findViewById(R.id.fragment_container_local_cameraFS); RelativeLayout.LayoutParams paramsFS = (RelativeLayout.LayoutParams)fragmentContainerLocalCameraFS.getLayoutParams(); paramsFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); paramsFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); fragmentContainerLocalCameraFS.setLayoutParams(paramsFS); - parentFS.setVisibility(View.GONE); fragmentContainerLocalCameraFS.setVisibility(View.GONE); + //Remote camera Full Screen + parentRemoteFS = (ViewGroup) findViewById(R.id.parent_layout_remote_camera_FS); + fragmentContainerRemoteCameraFS = (FrameLayout) findViewById(R.id.fragment_container_remote_cameraFS); + RelativeLayout.LayoutParams paramsRemoteFS = (RelativeLayout.LayoutParams)fragmentContainerRemoteCameraFS.getLayoutParams(); + paramsRemoteFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); + paramsRemoteFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); + fragmentContainerRemoteCameraFS.setLayoutParams(paramsRemoteFS); + fragmentContainerRemoteCameraFS.setOnTouchListener(new OnDragTouchListener(fragmentContainerRemoteCameraFS, parentRemoteFS)); + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + Bundle extras = getIntent().getExtras(); if (extras != null) { @@ -944,8 +953,8 @@ public void onPause(){ @Override protected void onResume() { - this.width=0; - this.height=0; +// this.width=0; +// this.height=0; super.onResume(); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); @@ -961,7 +970,7 @@ protected void onResume() { public void onDestroy(){ if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); +// megaChatApi.removeChatVideoListener(chatId, userHandle, this); } if (customHandler != null){ @@ -989,7 +998,7 @@ public void onBackPressed() { if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); +// megaChatApi.removeChatVideoListener(chatId, userHandle, this); } if (customHandler != null){ @@ -1323,48 +1332,6 @@ public Bitmap createDefaultAvatar(){ int height = 0; Bitmap bitmap; - @Override - public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) - { - if((width == 0) || (height == 0)){ - return; - } - - if (this.width != width || this.height != height) { - this.width = width; - this.height = height; - - SurfaceHolder holder = remoteSurfaceView.getHolder(); - if (holder != null) { - int viewWidth = remoteSurfaceView.getWidth(); - int viewHeight = remoteSurfaceView.getHeight(); - if ((viewWidth != 0) && (viewHeight != 0)) { - int holderWidth = viewWidth < width ? viewWidth : width; - int holderHeight = holderWidth * viewHeight / viewWidth; - if (holderHeight > viewHeight) { - holderHeight = viewHeight; - holderWidth = holderHeight * viewWidth / viewHeight; - } - this.bitmap = remoteRenderer.CreateBitmap(width, height); - holder.setFixedSize(holderWidth, holderHeight); - } - else{ - this.width = -1; - this.height = -1; - } - } - } - - if (bitmap != null) { - bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. - // The renderer has been modified a bit and an update of WebRTC could break our app - remoteRenderer.DrawBitmap(false); - } - } - - @Override public void onClick(View v) { log("onClick"); @@ -1385,8 +1352,6 @@ public void onClick(View v) { } } - // surfaceView.setVisibility(View.VISIBLE); -// start_camera(); if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){ ((MegaApplication) getApplication()).sendSignalPresenceActivity(); } @@ -1744,43 +1709,79 @@ public void updateRemoteVideoStatus(){ log("updateRemoteVideoStatus"); if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ + if(userSession!=null && userSession.hasVideo()){ log("Video remote connected"); isRemoteVideo = REMOTE_VIDEO_ENABLED; - contactAvatarLayout.setVisibility(View.GONE); - contactAvatarLayout.setOnTouchListener(null); - remoteSurfaceView.setOnTouchListener(this); - log("Register remote video listener"); - megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); - } - else{ + if (contactAvatarLayout.getVisibility() == View.VISIBLE) { + + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, userHandle); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); + + contactAvatarLayout.setVisibility(GONE); + contactAvatarLayout.setOnTouchListener(null); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + + } else { + log("No needed to refresh"); + } + + }else{ log("Video remote NOT connected"); + isRemoteVideo = REMOTE_VIDEO_DISABLED; + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { + remoteCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(remoteCameraFragmentFS); + remoteCameraFragmentFS = null; + } contactAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setOnTouchListener(this); - remoteSurfaceView.setOnTouchListener(null); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); } - } - else{ + }else{ log("Change on remote video"); if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ + isRemoteVideo = REMOTE_VIDEO_DISABLED; + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { + remoteCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(remoteCameraFragmentFS); + remoteCameraFragmentFS = null; + } contactAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setOnTouchListener(this); - remoteSurfaceView.setOnTouchListener(null); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); - } - else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ + + }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ + isRemoteVideo = REMOTE_VIDEO_ENABLED; - contactAvatarLayout.setVisibility(View.GONE); - contactAvatarLayout.setOnTouchListener(null); - remoteSurfaceView.setOnTouchListener(this); - megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); + if (contactAvatarLayout.getVisibility() == View.VISIBLE) { + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, userHandle); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); + + contactAvatarLayout.setVisibility(GONE); + contactAvatarLayout.setOnTouchListener(null); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + + } else { + log("No needed to refresh"); + } } } } + public void updateRemoteAudioStatus(){ log("updateRemoteAudioStatus"); supportInvalidateOptionsMenu(); @@ -1845,7 +1846,7 @@ public boolean onTouch(View view, MotionEvent event){ switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: - if((view.getId() == R.id.surface_remote_video) || (view.getId() == R.id.call_chat_contact_image_layout)){ + if(view.getId() == R.id.call_chat_contact_image_layout){ if(aB.isShowing()){ hideActionBar(); hideFABs(); @@ -1911,7 +1912,7 @@ public void run() { // @Override // public void run() { // milliseconds = milliseconds +1000; -// log("***********milliseconds: "+milliseconds); +// log("milliseconds: "+milliseconds); // SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss", Locale.getDefault()); // final String strDate = formatter.format(new Date(milliseconds)); // diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java new file mode 100644 index 00000000000..08fc3ebe8b7 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -0,0 +1,160 @@ +package mega.privacy.android.app.lollipop.megachat.calls; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.PixelFormat; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewGroup; + +import java.nio.ByteBuffer; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; + + +public class RemoteCameraCallFullScreenFragment extends Fragment implements MegaChatVideoListenerInterface { + + int width = 0; + int height = 0; + Bitmap bitmap; + MegaChatApiAndroid megaChatApi; + Context context; + long chatId; + long userHandle; + + public SurfaceView remoteFullScreenSurfaceView; + MegaSurfaceRenderer remoteRenderer; + + public static RemoteCameraCallFullScreenFragment newInstance(long chatId, long userHandle) { + log("newInstance"); + RemoteCameraCallFullScreenFragment f = new RemoteCameraCallFullScreenFragment(); + + Bundle args = new Bundle(); + args.putLong("chatId", chatId); + args.putLong("userHandle",userHandle); + f.setArguments(args); + return f; + } + + @Override + public void onCreate (Bundle savedInstanceState){ + log("onCreate"); + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); + } + + Bundle args = getArguments(); + this.chatId = args.getLong("chatId", -1); + this.userHandle = args.getLong("userHandle", -1); + log("**** 1 userHandle: "+userHandle); + + super.onCreate(savedInstanceState); + log("after onCreate called super"); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + log("onCreateView"); + + if (!isAdded()) { + return null; + } + + View v = inflater.inflate(R.layout.fragment_remote_camera_call_full_screen, container, false); + + remoteFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_remote_video); + remoteFullScreenSurfaceView.setZOrderMediaOverlay(true); + SurfaceHolder remoteSurfaceHolder = remoteFullScreenSurfaceView.getHolder(); + remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView); + log("**** 2 userHandle: "+userHandle); + megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); + + return v; + } + + @Override + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) + { + if((width == 0) || (height == 0)){ + return; + } + + if (this.width != width || this.height != height) { + this.width = width; + this.height = height; + + SurfaceHolder holder = remoteFullScreenSurfaceView.getHolder(); + if (holder != null) { + int viewWidth = remoteFullScreenSurfaceView.getWidth(); + int viewHeight = remoteFullScreenSurfaceView.getHeight(); + if ((viewWidth != 0) && (viewHeight != 0)) { + int holderWidth = viewWidth < width ? viewWidth : width; + int holderHeight = holderWidth * viewHeight / viewWidth; + if (holderHeight > viewHeight) { + holderHeight = viewHeight; + holderWidth = holderHeight * viewWidth / viewHeight; + } + this.bitmap = remoteRenderer.CreateBitmap(width, height); + holder.setFixedSize(holderWidth, holderHeight); + } + else{ + this.width = -1; + this.height = -1; + } + } + } + + if (bitmap != null) { + bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); + + // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. + // The renderer has been modified a bit and an update of WebRTC could break our app + remoteRenderer.DrawBitmap(false); + } + } + + + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; + } + + @Override + public void onDestroy(){ + megaChatApi.removeChatVideoListener(chatId, userHandle, this); + super.onDestroy(); + } + @Override + public void onResume() { + log("onResume"); + this.width=0; + this.height=0; + super.onResume(); + } + + public void setVideoFrame(boolean visible){ + if(visible){ + remoteFullScreenSurfaceView.setVisibility(View.VISIBLE); + } + else{ + remoteFullScreenSurfaceView.setVisibility(View.GONE); + } + } + + private static void log(String log) { + Util.log("RemoteCameraCallFullScreenFragment", log); + } +} diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index d1933e8f74a..467051be79f 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -34,7 +34,7 @@ - - + android:layout_alignParentEnd="true" + android:background="@android:color/transparent"> + + + + + + + + + + + + + + \ No newline at end of file From b6b469b3979f63562b63ecb0cafe577f39f9e3c2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 13 Jul 2018 15:01:50 +0200 Subject: [PATCH 004/247] Feature#9775- Group calls UI --- .../megachat/calls/ChatCallActivity.java | 76 ++++++++++++------- .../RemoteCameraCallFullScreenFragment.java | 12 ++- .../main/res/layout/activity_calls_chat.xml | 3 + 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index d0dcf4ebe82..5aa96e7e019 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -103,7 +103,7 @@ import static android.view.View.GONE; import static mega.privacy.android.app.utils.Util.context; -public class ChatCallActivity extends AppCompatActivity implements MegaChatRequestListenerInterface,View.OnTouchListener, MegaChatCallListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback { +public class ChatCallActivity extends AppCompatActivity implements MegaChatRequestListenerInterface, MegaChatCallListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback { DatabaseHandler dbH = null; ChatItemPreferences chatPrefs = null; @@ -1337,6 +1337,10 @@ public void onClick(View v) { log("onClick"); switch (v.getId()) { + case R.id.call_chat_contact_image_layout:{ + remoteCameraClick(); + break; + } case R.id.video_fab:{ if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ @@ -1720,8 +1724,9 @@ public void updateRemoteVideoStatus(){ ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); ft.commitNowAllowingStateLoss(); +// contactAvatarLayout.setOnTouchListener(null); + contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); - contactAvatarLayout.setOnTouchListener(null); parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); @@ -1742,7 +1747,7 @@ public void updateRemoteVideoStatus(){ remoteCameraFragmentFS = null; } contactAvatarLayout.setVisibility(View.VISIBLE); - contactAvatarLayout.setOnTouchListener(this); + contactAvatarLayout.setOnClickListener(this); } }else{ log("Change on remote video"); @@ -1758,7 +1763,7 @@ public void updateRemoteVideoStatus(){ remoteCameraFragmentFS = null; } contactAvatarLayout.setVisibility(View.VISIBLE); - contactAvatarLayout.setOnTouchListener(this); + contactAvatarLayout.setOnClickListener(this); }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ @@ -1769,8 +1774,8 @@ public void updateRemoteVideoStatus(){ ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); ft.commitNowAllowingStateLoss(); + contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); - contactAvatarLayout.setOnTouchListener(null); parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); @@ -1838,34 +1843,47 @@ public void onSensorChanged(SensorEvent event) { } } - @Override - public boolean onTouch(View view, MotionEvent event){ - - final int X = (int) event.getRawX(); - final int Y = (int) event.getRawY(); - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_DOWN: - if(view.getId() == R.id.call_chat_contact_image_layout){ - if(aB.isShowing()){ - hideActionBar(); - hideFABs(); - }else{ - showActionBar(); - showInitialFABConfiguration(); - } - } - break; + public void remoteCameraClick(){ + + if(aB.isShowing()){ + hideActionBar(); + hideFABs(); + }else{ + showActionBar(); + showInitialFABConfiguration(); + } - case MotionEvent.ACTION_MOVE: - break; - default: - return false; - } - return true; } +// @Override +// public boolean onTouch(View view, MotionEvent event){ +// +// final int X = (int) event.getRawX(); +// final int Y = (int) event.getRawY(); +// +// switch (event.getAction() & MotionEvent.ACTION_MASK) { +// case MotionEvent.ACTION_DOWN: +// if((view.getId() == R.id.parent_layout_remote_camera_FS)||(view.getId() == R.id.call_chat_contact_image_layout)){ +// if(aB.isShowing()){ +// hideActionBar(); +// hideFABs(); +// }else{ +// showActionBar(); +// showInitialFABConfiguration(); +// } +// } +// break; +// +// case MotionEvent.ACTION_MOVE: +// break; +// +// default: +// return false; +// } +// return true; +// } + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index 08fc3ebe8b7..620c9cf8f43 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -16,13 +16,14 @@ import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; +import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaChatApiJava; import nz.mega.sdk.MegaChatVideoListenerInterface; -public class RemoteCameraCallFullScreenFragment extends Fragment implements MegaChatVideoListenerInterface { +public class RemoteCameraCallFullScreenFragment extends Fragment implements MegaChatVideoListenerInterface, View.OnClickListener { int width = 0; int height = 0; @@ -56,8 +57,6 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); - log("**** 1 userHandle: "+userHandle); - super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -73,11 +72,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_remote_camera_call_full_screen, container, false); remoteFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_remote_video); + remoteFullScreenSurfaceView.setOnClickListener(this); remoteFullScreenSurfaceView.setZOrderMediaOverlay(true); SurfaceHolder remoteSurfaceHolder = remoteFullScreenSurfaceView.getHolder(); remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView); - log("**** 2 userHandle: "+userHandle); megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); return v; @@ -157,4 +156,9 @@ public void setVideoFrame(boolean visible){ private static void log(String log) { Util.log("RemoteCameraCallFullScreenFragment", log); } + + @Override + public void onClick(View v) { + ((ChatCallActivity)context).remoteCameraClick(); + } } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 467051be79f..b4a0225b6ba 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -54,6 +54,9 @@ android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentRight="true" + android:clickable="true" + android:focusable="true" + android:focusableInTouchMode="true" android:layout_alignParentEnd="true" android:background="@android:color/transparent"> Date: Fri, 13 Jul 2018 15:04:05 +0200 Subject: [PATCH 005/247] Feature#9775- Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 1 - app/src/main/res/layout/activity_calls_chat.xml | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 5aa96e7e019..111cad18b68 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1724,7 +1724,6 @@ public void updateRemoteVideoStatus(){ ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); ft.commitNowAllowingStateLoss(); -// contactAvatarLayout.setOnTouchListener(null); contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); parentRemoteFS.setVisibility(View.VISIBLE); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index b4a0225b6ba..467051be79f 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -54,9 +54,6 @@ android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentRight="true" - android:clickable="true" - android:focusable="true" - android:focusableInTouchMode="true" android:layout_alignParentEnd="true" android:background="@android:color/transparent"> Date: Tue, 17 Jul 2018 13:35:13 +0200 Subject: [PATCH 006/247] Feature #9774: Management of group calls --- .../megachat/ChatActivityLollipop.java | 31 +- .../megachat/calls/ChatCallActivity.java | 364 ++++++++++-------- 2 files changed, 208 insertions(+), 187 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 75587ecfee8..27ea8a99a44 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1531,6 +1531,16 @@ public boolean onPrepareOptionsMenu(Menu menu){ inviteMenuItem.setVisible(false); } else{ + int callsInProgress = megaChatApi.getNumCalls(); + if(megaChatApi.getNumCalls()<=0){ + callMenuItem.setVisible(true); + videoMenuItem.setVisible(true); + } + else{ + callMenuItem.setVisible(false); + videoMenuItem.setVisible(false); + } + int permission = chatRoom.getOwnPrivilege(); log("Permission in the chat: "+permission); if(chatRoom.isGroup()){ @@ -1580,10 +1590,6 @@ else if(permission==MegaChatRoom.PRIV_RO) { clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); } - - callMenuItem.setVisible(false); - videoMenuItem.setVisible(false); - contactInfoMenuItem.setTitle(getString(R.string.group_chat_info_label)); contactInfoMenuItem.setVisible(true); } @@ -1599,8 +1605,6 @@ else if(permission==MegaChatRoom.PRIV_RO) { clearHistoryMenuItem.setVisible(true); contactInfoMenuItem.setTitle(getString(R.string.contact_properties_activity)); contactInfoMenuItem.setVisible(true); - callMenuItem.setVisible(true); - videoMenuItem.setVisible(true); } leaveMenuItem.setVisible(false); } @@ -1634,18 +1638,11 @@ public boolean onOptionsItemSelected(MenuItem item) { } case R.id.cab_menu_call_chat:{ - - if (chatRoom.isGroup()) - { - showSnackbar("Coming soon...!"); - } - else - { - startVideo = false; - if(checkPermissionsCall()){ - startCall(); - } + startVideo = false; + if(checkPermissionsCall()){ + startCall(); } + break; } case R.id.cab_menu_video_chat:{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 111cad18b68..1057e61ae82 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -11,7 +11,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.Typeface; import android.hardware.Sensor; @@ -43,9 +42,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -63,7 +59,6 @@ import android.widget.TextView; import java.io.File; -import java.nio.ByteBuffer; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; @@ -93,7 +88,6 @@ import nz.mega.sdk.MegaChatRequestListenerInterface; import nz.mega.sdk.MegaChatRoom; import nz.mega.sdk.MegaChatSession; -import nz.mega.sdk.MegaChatVideoListenerInterface; import nz.mega.sdk.MegaError; import nz.mega.sdk.MegaRequest; import nz.mega.sdk.MegaRequestListenerInterface; @@ -187,13 +181,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; - float heightFAB; - - String fullName = ""; - String email = ""; - long userHandle = -1; - MegaChatSession userSession = null; - private SensorManager mSensorManager; private Sensor mSensor; @@ -242,26 +229,32 @@ public boolean onPrepareOptionsMenu(Menu menu) { log("onPrepareOptionsMenu"); remoteAudioIcon = menu.findItem(R.id.info_remote_audio); - if(callChat!=null && userSession!=null){ - if(userSession.hasAudio()){ - log("Audio remote connected"); - remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_up_white)); + if(chat.isGroup()){ + remoteAudioIcon.setVisible(false); + } + else{ + MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); + + if(callChat!=null && userSession!=null){ + if(userSession.hasAudio()){ + log("Audio remote connected"); + remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_up_white)); + } + else{ + log("Audio remote NOT connected"); + remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_off_white)); + } } else{ - log("Audio remote NOT connected"); - remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_off_white)); + log("callChat is Null"); } + remoteAudioIcon.setVisible(true); + remoteAudioIcon.setEnabled(false); } - else{ - log("callChat is Null"); - } - - remoteAudioIcon.setEnabled(false); return super.onPrepareOptionsMenu(menu); } - @Override public boolean onOptionsItemSelected(MenuItem item) { log("onOptionsItemSelected"); @@ -287,44 +280,25 @@ public boolean onOptionsItemSelected(MenuItem item) { public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - flagMyAvatar = false; - setProfileMyAvatar(); - flagContactAvatar = true; - setProfileContactAvatar(); - - stopAudioSignals(); - updateLocalVideoStatus(); - updateLocalAudioStatus(); - updateRemoteAudioStatus(); - updateRemoteVideoStatus(); - startClock(); - } - - public void setCallInfo(){ - log("setCallInfo"); - - fullName = chat.getTitle(); - email = chat.getPeerEmail(0); - userHandle = chat.getPeerHandle(0); - userSession = callChat.getMegaChatSession(userHandle); + if(chat.isGroup()){ - if (fullName.trim() != null) { - if (fullName.trim().isEmpty()) { - log("1 - Put email as fullname"); - String[] splitEmail = email.split("[@._]"); - fullName = splitEmail[0]; - } - } else { - log("2 - Put email as fullname"); - String[] splitEmail = email.split("[@._]"); - fullName = splitEmail[0]; + } + else{ + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + flagMyAvatar = false; + setProfileMyAvatar(); + flagContactAvatar = true; + setProfileContactAvatar(); + updateLocalVideoStatus(); + updateLocalAudioStatus(); + updateRemoteAudioStatus(-1); + updateRemoteVideoStatus(-1); } - aB.setTitle(fullName); - updateSubTitle(); + stopAudioSignals(); + startClock(); } public void updateSubTitle(){ @@ -335,21 +309,26 @@ public void updateSubTitle(){ aB.setSubtitle(getString(R.string.call_starting)); } else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - if(userSession!=null){ - sessionStatus = userSession.getStatus(); - log("sessionStatus: "+sessionStatus); - if(sessionStatus==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - startClock(); + if(chat.isGroup()){ + startClock(); + } + else{ + MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); + if(userSession!=null){ + sessionStatus = userSession.getStatus(); + log("sessionStatus: "+sessionStatus); + if(sessionStatus==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + startClock(); + } + else{ + aB.setSubtitle(getString(R.string.chat_connecting)); + } } else{ - aB.setSubtitle(getString(R.string.chat_connecting)); + log("Error getting the session of the user"); + aB.setSubtitle(null); } } - else{ - log("Error getting the session of the user"); - aB.setSubtitle(null); - } - } else{ aB.setSubtitle(null); @@ -375,7 +354,9 @@ protected void onNewIntent(Intent intent) { chat = megaChatApi.getChatRoom(chatId); callChat = megaChatApi.getChatCall(chatId); - setCallInfo(); + aB.setTitle(chat.getTitle()); + updateSubTitle(); + updateScreenStatusInProgress(); log("Start call Service"); @@ -616,20 +597,12 @@ protected void onCreate(Bundle savedInstanceState) { int callStatus = callChat.getStatus(); log("The status of the callChat is: " + callStatus); - setCallInfo(); + aB.setTitle(chat.getTitle()); + updateSubTitle(); if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - - contactAvatarLayout.setVisibility(View.VISIBLE); - flagMyAvatar = true; - setProfileMyAvatar(); - flagContactAvatar = false; - setProfileContactAvatar(); - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); @@ -645,6 +618,20 @@ protected void onCreate(Bundle savedInstanceState) { vibrator.vibrate(pattern, 0); } } + + if(chat.isGroup()){ + + } + else{ + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + + contactAvatarLayout.setVisibility(View.VISIBLE); + flagMyAvatar = true; + setProfileMyAvatar(); + flagContactAvatar = false; + setProfileContactAvatar(); + } } else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ updateScreenStatusInProgress(); @@ -652,12 +639,6 @@ else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ else{ log("Outgoing call"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - flagMyAvatar = false; - setProfileMyAvatar(); - flagContactAvatar = true; - setProfileContactAvatar(); int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -668,7 +649,20 @@ else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ thePlayer.setLooping(true); thePlayer.start(); } + updateLocalVideoStatus(); + + if(chat.isGroup()){ + + } + else{ + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + flagMyAvatar = false; + setProfileMyAvatar(); + flagContactAvatar = true; + setProfileContactAvatar(); + } } } } @@ -745,9 +739,9 @@ public void setProfileContactAvatar(){ Bitmap bitmap = null; File avatar = null; if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), email + ".jpg"); + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), chat.getPeerEmail(0) + ".jpg"); } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), email + ".jpg"); + avatar = new File(context.getCacheDir().getAbsolutePath(), chat.getPeerEmail(0) + ".jpg"); } if (avatar.exists()) { @@ -1122,34 +1116,24 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { answerCallFAB.setOnTouchListener(null); videoFAB.setOnTouchListener(null); videoFAB.setOnClickListener(this); - flagMyAvatar = true; - setProfileMyAvatar(); - flagContactAvatar = false; - setProfileContactAvatar(); - if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(localCameraFragmentFS); - localCameraFragmentFS = null; - contactAvatarLayout.setVisibility(View.VISIBLE); - parentFS.setVisibility(View.GONE); - fragmentContainerLocalCameraFS.setVisibility(View.GONE); - } - - updateLocalVideoStatus(); - updateRemoteVideoStatus(); + updateSubTitle(); stopAudioSignals(); rtcAudioManager.start(null); showInitialFABConfiguration(); - updateSubTitle(); + break; } case MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION:{ log("Terminating call of chat: "+chatId); + if(chat.isGroup()){ + long userHandle = call.getPeerSessionStatusChange(); + log(userHandle+": finished the participation on the call"); + } + break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ @@ -1172,19 +1156,37 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("Session status have changed"); - userSession = callChat.getMegaChatSession(userHandle); - log("Status of the session: "+userSession.getStatus()); - if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ - updateSubTitle(); + + if(chat.isGroup()){ + long userHandle = call.getPeerSessionStatusChange(); + + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log(userHandle+": joined the group call - create fragment!"); + } + updateRemoteVideoStatus(userHandle); + updateRemoteAudioStatus(userHandle); + } + else{ + if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ + updateSubTitle(); + } + updateRemoteVideoStatus(-1); + updateRemoteAudioStatus(-1); } - updateRemoteVideoStatus(); - updateRemoteAudioStatus(); } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ log("Remote flags have changed"); - userSession = callChat.getMegaChatSession(userHandle); - updateRemoteVideoStatus(); - updateRemoteAudioStatus(); + if(chat.isGroup()){ + updateRemoteVideoStatus(call.getPeerSessionStatusChange()); + updateRemoteAudioStatus(call.getPeerSessionStatusChange()); + } + else{ + if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ + updateRemoteVideoStatus(-1); + updateRemoteAudioStatus(-1); + } + } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("Local flags have changed"); @@ -1709,86 +1711,108 @@ public void updateLocalAudioStatus(){ } } - public void updateRemoteVideoStatus(){ + public void updateRemoteVideoStatus(long userHandle){ log("updateRemoteVideoStatus"); + if(chat.isGroup()){ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession!=null && userSession.hasVideo()) { + log(userHandle+": Video remote connected"); + }else { + log(userHandle+": Video remote NOT connected"); + } + } + else{ + MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); - if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ + if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ - if(userSession!=null && userSession.hasVideo()){ - log("Video remote connected"); - isRemoteVideo = REMOTE_VIDEO_ENABLED; - if (contactAvatarLayout.getVisibility() == View.VISIBLE) { + if(userSession!=null && userSession.hasVideo()){ + log("Video remote connected"); + isRemoteVideo = REMOTE_VIDEO_ENABLED; + if (contactAvatarLayout.getVisibility() == View.VISIBLE) { - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, userHandle); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); - contactAvatarLayout.setOnClickListener(null); - contactAvatarLayout.setVisibility(GONE); - parentRemoteFS.setVisibility(View.VISIBLE); - fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + contactAvatarLayout.setOnClickListener(null); + contactAvatarLayout.setVisibility(GONE); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); - } else { - log("No needed to refresh"); - } + } else { + log("No needed to refresh"); + } - }else{ - log("Video remote NOT connected"); + }else{ + log("Video remote NOT connected"); - isRemoteVideo = REMOTE_VIDEO_DISABLED; - parentRemoteFS.setVisibility(View.GONE); - fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + isRemoteVideo = REMOTE_VIDEO_DISABLED; + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); if (remoteCameraFragmentFS != null) { remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); remoteCameraFragmentFS = null; } - contactAvatarLayout.setVisibility(View.VISIBLE); - contactAvatarLayout.setOnClickListener(this); - } - }else{ - log("Change on remote video"); - if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ - - isRemoteVideo = REMOTE_VIDEO_DISABLED; - parentRemoteFS.setVisibility(View.GONE); - fragmentContainerRemoteCameraFS.setVisibility(View.GONE); - if (remoteCameraFragmentFS != null) { - remoteCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(remoteCameraFragmentFS); - remoteCameraFragmentFS = null; + contactAvatarLayout.setVisibility(View.VISIBLE); + contactAvatarLayout.setOnClickListener(this); } - contactAvatarLayout.setVisibility(View.VISIBLE); - contactAvatarLayout.setOnClickListener(this); + }else{ + log("Change on remote video"); + if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ - }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ + isRemoteVideo = REMOTE_VIDEO_DISABLED; + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { + remoteCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(remoteCameraFragmentFS); + remoteCameraFragmentFS = null; + } + contactAvatarLayout.setVisibility(View.VISIBLE); + contactAvatarLayout.setOnClickListener(this); - isRemoteVideo = REMOTE_VIDEO_ENABLED; - if (contactAvatarLayout.getVisibility() == View.VISIBLE) { - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, userHandle); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); + }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ - contactAvatarLayout.setOnClickListener(null); - contactAvatarLayout.setVisibility(GONE); - parentRemoteFS.setVisibility(View.VISIBLE); - fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + isRemoteVideo = REMOTE_VIDEO_ENABLED; + if (contactAvatarLayout.getVisibility() == View.VISIBLE) { + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); - } else { - log("No needed to refresh"); + contactAvatarLayout.setOnClickListener(null); + contactAvatarLayout.setVisibility(GONE); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + + } else { + log("No needed to refresh"); + } } } } } - - public void updateRemoteAudioStatus(){ + public void updateRemoteAudioStatus(long userHandle){ log("updateRemoteAudioStatus"); - supportInvalidateOptionsMenu(); + if(chat.isGroup()){ + if(chat.isGroup()){ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession!=null && userSession.hasAudio()) { + log(userHandle+": Audio remote connected"); + }else { + log(userHandle+": Audio remote NOT connected"); + } + } + } + else{ + supportInvalidateOptionsMenu(); + } } @Override From a10ebb729e1b3c05aa3a98e8a5f6f2cacddf9cdb Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 17 Jul 2018 14:13:01 +0200 Subject: [PATCH 007/247] Feature #9774: Management of group calls --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1057e61ae82..899a9cd17c2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -311,6 +311,8 @@ public void updateSubTitle(){ else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ if(chat.isGroup()){ startClock(); + int totalParticipants = callChat.getNumParticipants() + 1; + log("update subtitle: "+totalParticipants +" of "+chat.getPeerCount()); } else{ MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); @@ -1163,6 +1165,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); + updateSubTitle(); } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); From d1422d29c4725d906ea8d0d9da9fe3d90fb1b686 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 17 Jul 2018 14:51:07 +0200 Subject: [PATCH 008/247] Feature #9774: Management of group calls --- .../megachat/ChatActivityLollipop.java | 34 ++++++++++++++++--- app/src/main/res/layout/activity_chat.xml | 4 +-- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 27ea8a99a44..bb1262bf4be 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -253,6 +253,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha RelativeLayout rLPickFileStorageButton; RelativeLayout callInProgressLayout; + TextView callInProgressText; EmojiconEditText textChat; ImageButton sendIcon; @@ -608,6 +609,7 @@ protected void onCreate(Bundle savedInstanceState) { callInProgressLayout = (RelativeLayout) findViewById(R.id.call_in_progress_layout); callInProgressLayout.setVisibility(View.GONE); + callInProgressText = (TextView) findViewById(R.id.call_in_progress_text); rLKeyboardButton.setOnClickListener(this); rLMediaButton.setOnClickListener(this); @@ -2224,13 +2226,18 @@ public void onClick(View v) { case R.id.call_in_progress_layout:{ log("onClick:call_in_progress_layout"); - Intent intent = new Intent(this, ChatCallActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); + if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + megaChatApi.answerChatCall(idChat, false, null); + } + else{ + Intent intent = new Intent(this, ChatCallActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setAction(Long.toString(System.currentTimeMillis())); - intent.putExtra("chatHandle", idChat); - startActivity(intent); + intent.putExtra("chatHandle", idChat); + startActivity(intent); + } break; - } case R.id.send_message_icon_chat:{ log("onClick:send_message_icon_chat"); @@ -6400,6 +6407,12 @@ protected void onResume(){ if(callInProgress != null){ if((callInProgress.getStatus() >= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){ callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); + callInProgressLayout.setOnClickListener(this); + } + else if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); callInProgressLayout.setOnClickListener(this); } else{ @@ -6771,6 +6784,17 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); } + else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + long openCallChatId = MegaApplication.getOpenCallChatId(); + log("openCallId: "+openCallChatId); + if(openCallChatId!=-1){ + Intent intent = new Intent(this, ChatCallActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); +// intent.setAction(Long.toString(System.currentTimeMillis())); + intent.putExtra("chatHandle", idChat); + startActivity(intent); + } + } } } diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index e502214d044..75528a5eae0 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -411,13 +411,13 @@ android:background="@color/accentColor"> + android:layout_centerHorizontal="true"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1c90e3789d5..88139ea784e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1983,4 +1983,6 @@ %d items were not restored successfully %d items restored successfully + Tap to return to the call + Tap to join to the call From 27aec530f9292bed44370302e6ff737fa4d40061 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Wed, 18 Jul 2018 11:08:04 +0200 Subject: [PATCH 009/247] Feature #9774: Management of group calls --- .../android/app/lollipop/megachat/ChatActivityLollipop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index bb1262bf4be..b9a1723e50e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2228,7 +2228,7 @@ public void onClick(View v) { MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ - megaChatApi.answerChatCall(idChat, false, null); + megaChatApi.startChatCall(idChat, false, null); } else{ Intent intent = new Intent(this, ChatCallActivity.class); From d34578c51da04963627280a202915d30421ab346 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 18 Jul 2018 11:27:02 +0200 Subject: [PATCH 010/247] Feature #9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 32 +++++ .../megachat/calls/ColorFragment.java | 110 ++++++++++++++++++ .../main/res/layout/activity_calls_chat.xml | 14 +++ app/src/main/res/layout/fragment_color.xml | 15 +++ 4 files changed, 171 insertions(+) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java create mode 100644 app/src/main/res/layout/fragment_color.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 899a9cd17c2..6c27dcf3ae5 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -173,6 +173,11 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FrameLayout fragmentContainerLocalCameraFS; FrameLayout fragmentContainerRemoteCameraFS; + //pruebas colores: + ViewGroup parentColorFS; + private ColorFragment colorFragmentFS = null; + FrameLayout fragmentContainerColorFS; + ViewGroup parent; ViewGroup parentFS; ViewGroup parentRemoteFS; @@ -541,6 +546,16 @@ protected void onCreate(Bundle savedInstanceState) { parentRemoteFS.setVisibility(View.GONE); fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + //Colors FULL SCREEN: + parentColorFS = (ViewGroup) findViewById(R.id.parent_layout_group_call_camera_FS); + fragmentContainerColorFS = (FrameLayout) findViewById(R.id.fragment_container_group_call_cameraFS); + RelativeLayout.LayoutParams paramsColorFS = (RelativeLayout.LayoutParams)fragmentContainerColorFS.getLayoutParams(); + paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); + paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); + fragmentContainerColorFS.setLayoutParams(paramsColorFS); + parentColorFS.setVisibility(View.GONE); + fragmentContainerColorFS.setVisibility(View.GONE); + Bundle extras = getIntent().getExtras(); if (extras != null) { @@ -1720,8 +1735,25 @@ public void updateRemoteVideoStatus(long userHandle){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null && userSession.hasVideo()) { log(userHandle+": Video remote connected"); + if(colorFragmentFS == null){ + colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); + ft.commitNowAllowingStateLoss(); + parentColorFS.setVisibility(View.VISIBLE); + fragmentContainerColorFS.setVisibility(View.VISIBLE); + } + }else { log(userHandle+": Video remote NOT connected"); + + parentColorFS.setVisibility(View.GONE); + fragmentContainerColorFS.setVisibility(View.GONE); + if (colorFragmentFS != null) { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(colorFragmentFS); + colorFragmentFS = null; + } } } else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java new file mode 100644 index 00000000000..39d249551e1 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java @@ -0,0 +1,110 @@ +package mega.privacy.android.app.lollipop.megachat.calls; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; +import android.graphics.PixelFormat; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatApiJava; + + +public class ColorFragment extends Fragment { + int width = 0; + int height = 0; + MegaChatApiAndroid megaChatApi; + Context context; + long chatId; + long userHandle; + int color; + + public RelativeLayout remoteFullScreenSurfaceView; + + public static ColorFragment newInstance(long chatId, long userHandle, int color) { + log("newInstance"); + ColorFragment f = new ColorFragment(); + + Bundle args = new Bundle(); + args.putLong("chatId", chatId); + args.putLong("userHandle",userHandle); + args.putInt("color",color); + f.setArguments(args); + return f; + } + + @Override + public void onCreate (Bundle savedInstanceState){ + log("onCreate"); + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); + } + + Bundle args = getArguments(); + this.chatId = args.getLong("chatId", -1); + this.userHandle = args.getLong("userHandle", -1); + this.color = args.getInt("color",0); + super.onCreate(savedInstanceState); + log("after onCreate called super"); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + log("onCreateView"); + + if (!isAdded()) { + return null; + } + + View v = inflater.inflate(R.layout.fragment_color, container, false); + + remoteFullScreenSurfaceView = (RelativeLayout)v.findViewById(R.id.surface_remote_video); + + if(color == 1){ + remoteFullScreenSurfaceView.setBackgroundColor(Color.BLUE); + }else if (color == 2){ + remoteFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); + }else if (color == 3){ + remoteFullScreenSurfaceView.setBackgroundColor(Color.GREEN); + }else{ + remoteFullScreenSurfaceView.setBackgroundColor(Color.MAGENTA); + } + + return v; + } + + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; + } + + @Override + public void onDestroy(){ + super.onDestroy(); + } + @Override + public void onResume() { + log("onResume"); + this.width=0; + this.height=0; + super.onResume(); + } + + private static void log(String log) { + Util.log("ColorFragment", log); + } + + +} diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 467051be79f..0fb70a9b89d 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -62,6 +62,20 @@ android:layout_height="match_parent" android:background="@android:color/transparent"/> + + + diff --git a/app/src/main/res/layout/fragment_color.xml b/app/src/main/res/layout/fragment_color.xml new file mode 100644 index 00000000000..c15594a28c7 --- /dev/null +++ b/app/src/main/res/layout/fragment_color.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file From 877e4f911816520c155a2ebc02ff1382fcc41e52 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 18 Jul 2018 15:45:14 +0200 Subject: [PATCH 011/247] Feature #9775-Group calls UI --- .../megachat/ChatActivityLollipop.java | 16 +- .../megachat/calls/ChatCallActivity.java | 298 ++++----- .../main/res/layout/activity_calls_chat.xml | 580 +++++++++--------- 3 files changed, 441 insertions(+), 453 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index bb1262bf4be..532f81f8307 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1648,17 +1648,9 @@ public boolean onOptionsItemSelected(MenuItem item) { break; } case R.id.cab_menu_video_chat:{ - - if (chatRoom.isGroup()) - { - showSnackbar("Coming soon...!"); - } - else - { - startVideo = true; - if(checkPermissionsCall()){ - startCall(); - } + startVideo = true; + if(checkPermissionsCall()){ + startCall(); } break; } @@ -2224,8 +2216,6 @@ public void onClick(View v) { // break; // } case R.id.call_in_progress_layout:{ - log("onClick:call_in_progress_layout"); - MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ megaChatApi.answerChatCall(idChat, false, null); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 6c27dcf3ae5..9a137ffc139 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -60,6 +60,7 @@ import java.io.File; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Locale; import java.util.TimeZone; import java.util.Timer; @@ -135,6 +136,8 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque boolean avatarRequested = false; + ArrayList peersOnCall = new ArrayList<>(); + Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; @@ -147,7 +150,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque //my avatar RelativeLayout myAvatarLayout; - RelativeLayout myImageBorder; RoundedImageView myImage; TextView myInitialLetter; @@ -155,7 +157,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout contactAvatarLayout; RoundedImageView contactImage; TextView contactInitialLetter; - RelativeLayout contactImageBorder; static ChatCallActivity chatCallActivityActivity = null; @@ -173,13 +174,13 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FrameLayout fragmentContainerLocalCameraFS; FrameLayout fragmentContainerRemoteCameraFS; - //pruebas colores: - ViewGroup parentColorFS; - private ColorFragment colorFragmentFS = null; - FrameLayout fragmentContainerColorFS; +// //pruebas colores: +// ViewGroup parentColorFS; +// private ColorFragment colorFragmentFS = null; +// FrameLayout fragmentContainerColorFS; - ViewGroup parent; - ViewGroup parentFS; + ViewGroup parentLocal; + ViewGroup parentLocalFS; ViewGroup parentRemoteFS; private LocalCameraCallFragment localCameraFragment; @@ -287,7 +288,8 @@ public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress"); if(chat.isGroup()){ - + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; } else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -306,14 +308,22 @@ public void updateScreenStatusInProgress(){ startClock(); } + public void updateNumberOfPeers(){ + if(chat.isGroup()){ + int totalParticipants = callChat.getNumParticipants(); + //redesign of screens: + + + } + } + public void updateSubTitle(){ log("updateSubTitle"); int sessionStatus = -1; if(callChat.getStatus()<=MegaChatCall.CALL_STATUS_RING_IN){ aB.setSubtitle(getString(R.string.call_starting)); - } - else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + }else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ if(chat.isGroup()){ startClock(); int totalParticipants = callChat.getNumParticipants() + 1; @@ -471,6 +481,8 @@ protected void onCreate(Bundle savedInstanceState) { aB.setTitle(" "); myChrono = new Chronometer(context); + peersOnCall.add(megaChatApi.getMyUserHandle()); + linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); @@ -515,24 +527,24 @@ protected void onCreate(Bundle savedInstanceState) { rtcAudioManager = AppRTCAudioManager.create(getApplicationContext()); //Local camera small - parent = (ViewGroup) findViewById(R.id.parent_layout); + parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)fragmentContainerLocalCamera.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); fragmentContainerLocalCamera.setLayoutParams(params); - fragmentContainerLocalCamera.setOnTouchListener(new OnDragTouchListener(fragmentContainerLocalCamera,parent)); - parent.setVisibility(View.GONE); + fragmentContainerLocalCamera.setOnTouchListener(new OnDragTouchListener(fragmentContainerLocalCamera,parentLocal)); + parentLocal.setVisibility(View.GONE); fragmentContainerLocalCamera.setVisibility(View.GONE); //Local camera Full Screen - parentFS = (ViewGroup) findViewById(R.id.parent_layout_local_camera_FS); + parentLocalFS = (ViewGroup) findViewById(R.id.parent_layout_local_camera_FS); fragmentContainerLocalCameraFS = (FrameLayout) findViewById(R.id.fragment_container_local_cameraFS); RelativeLayout.LayoutParams paramsFS = (RelativeLayout.LayoutParams)fragmentContainerLocalCameraFS.getLayoutParams(); paramsFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); paramsFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); fragmentContainerLocalCameraFS.setLayoutParams(paramsFS); - parentFS.setVisibility(View.GONE); + parentLocalFS.setVisibility(View.GONE); fragmentContainerLocalCameraFS.setVisibility(View.GONE); //Remote camera Full Screen @@ -546,15 +558,15 @@ protected void onCreate(Bundle savedInstanceState) { parentRemoteFS.setVisibility(View.GONE); fragmentContainerRemoteCameraFS.setVisibility(View.GONE); - //Colors FULL SCREEN: - parentColorFS = (ViewGroup) findViewById(R.id.parent_layout_group_call_camera_FS); - fragmentContainerColorFS = (FrameLayout) findViewById(R.id.fragment_container_group_call_cameraFS); - RelativeLayout.LayoutParams paramsColorFS = (RelativeLayout.LayoutParams)fragmentContainerColorFS.getLayoutParams(); - paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); - paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); - fragmentContainerColorFS.setLayoutParams(paramsColorFS); - parentColorFS.setVisibility(View.GONE); - fragmentContainerColorFS.setVisibility(View.GONE); +// //Colors FULL SCREEN: +// parentColorFS = (ViewGroup) findViewById(R.id.parent_layout_group_call_camera_FS); +// fragmentContainerColorFS = (FrameLayout) findViewById(R.id.fragment_container_group_call_cameraFS); +// RelativeLayout.LayoutParams paramsColorFS = (RelativeLayout.LayoutParams)fragmentContainerColorFS.getLayoutParams(); +// paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); +// paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); +// fragmentContainerColorFS.setLayoutParams(paramsColorFS); +// parentColorFS.setVisibility(View.GONE); +// fragmentContainerColorFS.setVisibility(View.GONE); Bundle extras = getIntent().getExtras(); if (extras != null) { @@ -570,20 +582,18 @@ protected void onCreate(Bundle savedInstanceState) { this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } - myAvatarLayout = (RelativeLayout) findViewById(R.id.call_chat_my_image_layout); - myAvatarLayout.setVisibility(View.VISIBLE); - + myAvatarLayout = (RelativeLayout) findViewById(R.id.call_chat_my_image_rl); + myAvatarLayout.setVisibility(View.GONE); myImage = (RoundedImageView) findViewById(R.id.call_chat_my_image); - myImageBorder = (RelativeLayout) findViewById(R.id.call_chat_my_image_rl); - myInitialLetter = (TextView) findViewById(R.id.call_chat_my_image_initial_letter); - contactAvatarLayout = (RelativeLayout) findViewById(R.id.call_chat_contact_image_layout); + contactAvatarLayout = (RelativeLayout) findViewById(R.id.call_chat_contact_image_rl); + contactAvatarLayout.setVisibility(View.GONE); contactImage = (RoundedImageView) findViewById(R.id.call_chat_contact_image); contactInitialLetter = (TextView) findViewById(R.id.call_chat_contact_image_initial_letter); videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); //Contact's avatar chatId = extras.getLong("chatHandle", -1); @@ -637,23 +647,25 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; } else{ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; setProfileMyAvatar(); flagContactAvatar = false; setProfileContactAvatar(); } - } - else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("CALL_STATUS_IN_PROGRESS"); updateScreenStatusInProgress(); - } - else{ + + }else{ log("Outgoing call"); int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); @@ -667,19 +679,29 @@ else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ thePlayer.start(); } - updateLocalVideoStatus(); - if(chat.isGroup()){ + log("***** is Group"); + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + myAvatarLayout.setVisibility(View.GONE); + flagMyAvatar = false; + setProfileMyAvatar(); - } - else{ + + }else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; flagMyAvatar = false; setProfileMyAvatar(); flagContactAvatar = true; setProfileContactAvatar(); + myAvatarLayout.setVisibility(View.VISIBLE); + } + + updateLocalVideoStatus(); + + } } } @@ -696,6 +718,7 @@ public void onRequestStart(MegaApiJava api, MegaRequest request) { @Override public void onRequestUpdate(MegaApiJava api, MegaRequest request) { + log("onRequestUpdate"); } @@ -710,6 +733,8 @@ public void onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e) { public void onRequestTemporaryError(MegaApiJava api, MegaRequest request, MegaError e) {} public void createDefaultAvatar(long userHandle, String fullName) { + log("createDefaultAvatar"); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); @@ -827,6 +852,8 @@ public void setProfileContactAvatar(){ } public void createMyDefaultAvatar() { + log("createMyDefaultAvatar"); + String myFullName = megaChatApi.getMyFullname(); String myFirstLetter=myFullName.charAt(0) + ""; myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); @@ -846,7 +873,7 @@ public void createMyDefaultAvatar() { } else{ log("Default color to the avatar"); - p.setColor(context.getResources().getColor(R.color.lollipop_primary_color)); + p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); } int radius; @@ -958,12 +985,16 @@ protected void hideFABs(){ @Override public void onPause(){ + log("onPause"); + mSensorManager.unregisterListener(this); super.onPause(); } @Override protected void onResume() { + log("onResume"); + // this.width=0; // this.height=0; super.onResume(); @@ -979,6 +1010,8 @@ protected void onResume() { @Override public void onDestroy(){ + log("onDestroy"); + if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); // megaChatApi.removeChatVideoListener(chatId, userHandle, this); @@ -1026,16 +1059,20 @@ public void onBackPressed() { @Override public void onRequestStart(MegaChatApiJava api, MegaChatRequest request) { - log("Type: "+request.getType()); + log("onRequestStart: "+request.getType()); } @Override public void onRequestUpdate(MegaChatApiJava api, MegaChatRequest request) { + log("onRequestUpdate: "+request.getType()); + } @Override public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaChatError e) { + log("onRequestFinish: "+request.getType()); + if(request.getType() == MegaChatRequest.TYPE_HANG_CHAT_CALL){ MegaApplication.activityPaused(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -1119,6 +1156,7 @@ public void onRequestTemporaryError(MegaChatApiJava api, MegaChatRequest request @Override public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { + log("onChatCallUpdate() "); if(call.getChatid()==chatId){ log("onChatCallUpdate: "+call.getStatus()); @@ -1128,6 +1166,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { int callStatus = callChat.getStatus(); switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ + log("onChatCallUpdate() - CALL_STATUS_IN_PROGRESS"); videoFAB.setOnClickListener(null); answerCallFAB.setOnTouchListener(null); @@ -1145,6 +1184,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION:{ + log("onChatCallUpdate() - CALL_STATUS_TERMINATING_USER_PARTICIPATION"); + log("Terminating call of chat: "+chatId); if(chat.isGroup()){ long userHandle = call.getPeerSessionStatusChange(); @@ -1154,6 +1195,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ + log("onChatCallUpdate() - CALL_STATUS_DESTROYED"); + log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); stopAudioSignals(); @@ -1357,7 +1400,7 @@ public void onClick(View v) { log("onClick"); switch (v.getId()) { - case R.id.call_chat_contact_image_layout:{ + case R.id.call_chat_contact_image_rl:{ remoteCameraClick(); break; } @@ -1415,6 +1458,8 @@ public void onClick(View v) { } public boolean checkPermissions(){ + log("checkPermissions() "); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean hasCameraPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED); @@ -1435,6 +1480,8 @@ public boolean checkPermissions(){ } public void showInitialFABConfiguration(){ + log("showInitialFABConfiguration() "); + if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ relativeCall.setVisibility(View.VISIBLE); linearArrowCall.setVisibility(GONE); @@ -1446,8 +1493,8 @@ public void showInitialFABConfiguration(){ relativeVideo.setVisibility(View.VISIBLE); linearArrowVideo.setVisibility(GONE); videoFAB.setVisibility(View.VISIBLE); - videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); - videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); microFAB.setVisibility(GONE); @@ -1651,54 +1698,51 @@ public void updateLocalVideoStatus(){ int callStatus = callChat.getStatus(); if (callChat.hasLocalVideo()) { - log("Video local connected"); - if (myAvatarLayout.getVisibility() == View.VISIBLE) { - videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); - videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); - - if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - if(localCameraFragmentFS == null){ - localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); - ftFS.commitNowAllowingStateLoss(); - } - contactAvatarLayout.setVisibility(GONE); - parentFS.setVisibility(View.VISIBLE); - fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); - }else{ + if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + if(localCameraFragmentFS == null){ + localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); + ftFS.commitNowAllowingStateLoss(); + } + contactAvatarLayout.setVisibility(GONE); + parentLocalFS.setVisibility(View.VISIBLE); + fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); + + }else{ + if(localCameraFragment == null){ localCameraFragment = LocalCameraCallFragment.newInstance(chatId); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); ft.commitNowAllowingStateLoss(); - - myAvatarLayout.setVisibility(GONE); - parent.setVisibility(View.VISIBLE); - fragmentContainerLocalCamera.setVisibility(View.VISIBLE); } - } else { - log("No needed to refresh"); + myAvatarLayout.setVisibility(GONE); + parentLocal.setVisibility(View.VISIBLE); + fragmentContainerLocalCamera.setVisibility(View.VISIBLE); } + + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); + } else { log("Video local NOT connected"); if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - parentFS.setVisibility(View.GONE); + parentLocalFS.setVisibility(View.GONE); fragmentContainerLocalCameraFS.setVisibility(View.GONE); if (localCameraFragmentFS != null) { localCameraFragmentFS.setVideoFrame(false); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); localCameraFragmentFS = null; - } contactAvatarLayout.setVisibility(View.VISIBLE); }else{ - parent.setVisibility(View.GONE); + parentLocal.setVisibility(View.GONE); fragmentContainerLocalCamera.setVisibility(View.GONE); if (localCameraFragment != null) { localCameraFragment.setVideoFrame(false); @@ -1710,7 +1754,7 @@ public void updateLocalVideoStatus(){ } videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); } } @@ -1719,13 +1763,13 @@ public void updateLocalAudioStatus(){ if(callChat.hasLocalAudio()){ log("Audio local connected"); - microFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); - microFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_record_audio_w)); + microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); + microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); }else{ log("Audio local NOT connected"); microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - microFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_mic_off)); + microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); } } @@ -1735,25 +1779,48 @@ public void updateRemoteVideoStatus(long userHandle){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null && userSession.hasVideo()) { log(userHandle+": Video remote connected"); - if(colorFragmentFS == null){ - colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); +// if(colorFragmentFS == null){ +// colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); +// ft.commitNowAllowingStateLoss(); +// parentColorFS.setVisibility(View.VISIBLE); +// fragmentContainerColorFS.setVisibility(View.VISIBLE); +// } + if(remoteCameraFragmentFS == null) { + + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); ft.commitNowAllowingStateLoss(); - parentColorFS.setVisibility(View.VISIBLE); - fragmentContainerColorFS.setVisibility(View.VISIBLE); + + contactAvatarLayout.setOnClickListener(null); + contactAvatarLayout.setVisibility(GONE); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); } }else { log(userHandle+": Video remote NOT connected"); - parentColorFS.setVisibility(View.GONE); - fragmentContainerColorFS.setVisibility(View.GONE); - if (colorFragmentFS != null) { +// parentColorFS.setVisibility(View.GONE); +// fragmentContainerColorFS.setVisibility(View.GONE); +// if (colorFragmentFS != null) { +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(colorFragmentFS); +// colorFragmentFS = null; +// } + + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { + remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(colorFragmentFS); - colorFragmentFS = null; + ft.remove(remoteCameraFragmentFS); + remoteCameraFragmentFS = null; } + contactAvatarLayout.setVisibility(View.VISIBLE); + contactAvatarLayout.setOnClickListener(this); } } else{ @@ -1852,6 +1919,8 @@ public void updateRemoteAudioStatus(long userHandle){ @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + log("onRequestPermissionsResult() "); + super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case Constants.REQUEST_CAMERA: { @@ -1913,37 +1982,7 @@ public void remoteCameraClick(){ } - -// @Override -// public boolean onTouch(View view, MotionEvent event){ -// -// final int X = (int) event.getRawX(); -// final int Y = (int) event.getRawY(); -// -// switch (event.getAction() & MotionEvent.ACTION_MASK) { -// case MotionEvent.ACTION_DOWN: -// if((view.getId() == R.id.parent_layout_remote_camera_FS)||(view.getId() == R.id.call_chat_contact_image_layout)){ -// if(aB.isShowing()){ -// hideActionBar(); -// hideFABs(); -// }else{ -// showActionBar(); -// showInitialFABConfiguration(); -// } -// } -// break; -// -// case MotionEvent.ACTION_MOVE: -// break; -// -// default: -// return false; -// } -// return true; -// } - - - + @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {} @@ -1974,33 +2013,6 @@ public void run() { } }; - -// private void startClock(){ -// -// timer = new Timer(); -// MyTimerTask myTimerTask = new MyTimerTask(); -// -// timer.schedule(myTimerTask, 0, 1000); -// } -// -// private class MyTimerTask extends TimerTask { -// -// @Override -// public void run() { -// milliseconds = milliseconds +1000; -// log("milliseconds: "+milliseconds); -// SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss", Locale.getDefault()); -// final String strDate = formatter.format(new Date(milliseconds)); -// -// runOnUiThread(new Runnable(){ -// -// @Override -// public void run() { -// aB.setSubtitle(strDate); -// }}); -// } -// } - private class MyRingerTask extends TimerTask { @Override diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 0fb70a9b89d..76ba81587cb 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -1,38 +1,32 @@ - - - - - - - - - - - - - + + + android:fitsSystemWindows="true"> - + android:layout_height="match_parent"> + + android:layout_height="match_parent" + android:background="@color/black"> - + + + + - + android:scaleType="fitCenter" + android:layout_centerInParent="true" + rounded:border_color="#4DFFFFFF" + rounded:border_width="3dp" + rounded:corner_radius="60dp" /> + - - + + + + + + + + + + + + + + + + - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - - - - - - + android:background="@drawable/shape_call_chat"> + + + + + - - + + + - + + - - - - + - - - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:src="@drawable/ic_expand" + android:layout_centerInParent="true" + android:layout_marginTop="10dp"/> + + + + + + app:pressedTranslationZ="12dp"/> - - - - + android:layout_centerHorizontal="true" + android:orientation="vertical" + android:gravity="bottom" + android:visibility="gone" + android:background="@android:color/transparent"> + + + + + + - - - + + + + + + + + + From ac0f1687995a4e8bf5cc6c38ef0fd61825824a3e Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 19 Jul 2018 11:58:51 +0200 Subject: [PATCH 012/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 512 ++++++++++++++---- .../main/res/layout/activity_calls_chat.xml | 62 +-- 2 files changed, 401 insertions(+), 173 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 9a137ffc139..ca7a7a00ae7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -141,6 +141,8 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; + RelativeLayout smallElementsIndividualCallLayout; + RelativeLayout bigElementsIndividualCallLayout; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -483,6 +485,12 @@ protected void onCreate(Bundle savedInstanceState) { peersOnCall.add(megaChatApi.getMyUserHandle()); + smallElementsIndividualCallLayout = (RelativeLayout) findViewById(R.id.small_elements_individual_call); + smallElementsIndividualCallLayout.setVisibility(GONE); + + bigElementsIndividualCallLayout = (RelativeLayout) findViewById(R.id.big_elements_individual_call); + bigElementsIndividualCallLayout.setVisibility(GONE); + linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); @@ -558,16 +566,6 @@ protected void onCreate(Bundle savedInstanceState) { parentRemoteFS.setVisibility(View.GONE); fragmentContainerRemoteCameraFS.setVisibility(View.GONE); -// //Colors FULL SCREEN: -// parentColorFS = (ViewGroup) findViewById(R.id.parent_layout_group_call_camera_FS); -// fragmentContainerColorFS = (FrameLayout) findViewById(R.id.fragment_container_group_call_cameraFS); -// RelativeLayout.LayoutParams paramsColorFS = (RelativeLayout.LayoutParams)fragmentContainerColorFS.getLayoutParams(); -// paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE); -// paramsColorFS.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE); -// fragmentContainerColorFS.setLayoutParams(paramsColorFS); -// parentColorFS.setVisibility(View.GONE); -// fragmentContainerColorFS.setVisibility(View.GONE); - Bundle extras = getIntent().getExtras(); if (extras != null) { @@ -627,6 +625,17 @@ protected void onCreate(Bundle savedInstanceState) { aB.setTitle(chat.getTitle()); updateSubTitle(); + if(chat.isGroup()){ + smallElementsIndividualCallLayout.setVisibility(View.GONE); + bigElementsIndividualCallLayout.setVisibility(View.GONE); + + }else{ + smallElementsIndividualCallLayout.setVisibility(View.VISIBLE); + bigElementsIndividualCallLayout.setVisibility(View.VISIBLE); + + + } + if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); @@ -680,7 +689,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("***** is Group"); + log("is Group"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; myAvatarLayout.setVisibility(View.GONE); @@ -1234,6 +1243,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); + updateLocalVideoStatus(); + updateLocalAudioStatus(); } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ @@ -1253,12 +1264,15 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("Local flags have changed"); updateLocalAudioStatus(); updateLocalVideoStatus(); + } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_RINGING_STATUS)){ log("CHANGE_TYPE_RINGING_STATUS"); + } else{ log("CHANGE_TYPE_RINGING_STATUS: "+call.getChanges()); + } } } @@ -1693,69 +1707,223 @@ public void onSwipeBottom() {} } } +// public void updateLocalVideoStatus(){ +// log("updateLocalVideoStatus: "); +// int callStatus = callChat.getStatus(); +// if(callChat !=null){ +// if (callChat.hasLocalVideo()) { +// log("Video local connected"); +// +// if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ +// contactAvatarLayout.setVisibility(GONE); +// parentLocal.setVisibility(GONE); +// parentLocalFS.setVisibility(View.VISIBLE); +// fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); +// if(localCameraFragmentFS == null){ +// localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); +// ftFS.commitNowAllowingStateLoss(); +// } +// +// +// }else{ +// +// myAvatarLayout.setVisibility(GONE); +// parentLocalFS.setVisibility(GONE); +// parentLocal.setVisibility(View.VISIBLE); +// fragmentContainerLocalCamera.setVisibility(View.VISIBLE); +// +// if(localCameraFragment == null){ +// localCameraFragment = LocalCameraCallFragment.newInstance(chatId); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); +// ft.commitNowAllowingStateLoss(); +// } +// +// +// } +// +// videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); +// videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); +// +// } else { +// log("Video local NOT connected"); +// +// if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ +// +// +// if (localCameraFragmentFS != null) { +// localCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(localCameraFragmentFS); +// localCameraFragmentFS = null; +// } +// contactAvatarLayout.setVisibility(View.VISIBLE);// +// parentLocalFS.setVisibility(View.GONE); +// fragmentContainerLocalCameraFS.setVisibility(View.GONE); +// +// }else{ +// +// if (localCameraFragment != null) { +// localCameraFragment.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(localCameraFragment); +// localCameraFragment = null; +// } +// myAvatarLayout.setVisibility(View.VISIBLE); +// parentLocal.setVisibility(View.GONE); +// fragmentContainerLocalCamera.setVisibility(View.GONE); +// } +// +// videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); +// videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); +// } +// +// +// } +// +// } + + public void updateLocalVideoStatus(){ log("updateLocalVideoStatus: "); int callStatus = callChat.getStatus(); - if (callChat.hasLocalVideo()) { - log("Video local connected"); + if(chat.isGroup()){ + log("is group"); + if(callChat !=null){ + if (callChat.hasLocalVideo()) { + log("Video local connected"); - if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - if(localCameraFragmentFS == null){ - localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); - ftFS.commitNowAllowingStateLoss(); - } - contactAvatarLayout.setVisibility(GONE); - parentLocalFS.setVisibility(View.VISIBLE); - fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); + if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + contactAvatarLayout.setVisibility(GONE); + parentLocal.setVisibility(GONE); + parentLocalFS.setVisibility(View.VISIBLE); + fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); + if(localCameraFragmentFS == null){ + localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); + ftFS.commitNowAllowingStateLoss(); + } - }else{ - if(localCameraFragment == null){ - localCameraFragment = LocalCameraCallFragment.newInstance(chatId); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); - ft.commitNowAllowingStateLoss(); + }else{ + + myAvatarLayout.setVisibility(GONE); + parentLocalFS.setVisibility(GONE); + parentLocal.setVisibility(View.VISIBLE); + fragmentContainerLocalCamera.setVisibility(View.VISIBLE); + if(localCameraFragment == null){ + localCameraFragment = LocalCameraCallFragment.newInstance(chatId); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); + ft.commitNowAllowingStateLoss(); + } + } + + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); + + }else { + log("Video local NOT connected"); + + if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + if (localCameraFragmentFS != null) { + localCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(localCameraFragmentFS); + localCameraFragmentFS = null; + } + contactAvatarLayout.setVisibility(View.VISIBLE); + parentLocalFS.setVisibility(View.GONE); + fragmentContainerLocalCameraFS.setVisibility(View.GONE); + + }else{ + if (localCameraFragment != null) { + localCameraFragment.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(localCameraFragment); + localCameraFragment = null; + } + myAvatarLayout.setVisibility(View.VISIBLE); + parentLocal.setVisibility(View.GONE); + fragmentContainerLocalCamera.setVisibility(View.GONE); + } + + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); + videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); } - myAvatarLayout.setVisibility(GONE); - parentLocal.setVisibility(View.VISIBLE); - fragmentContainerLocalCamera.setVisibility(View.VISIBLE); + } + }else{ + log("is individual"); + + if (callChat.hasLocalVideo()) { + log("Video local connected"); + videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); + videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); + + if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + if(localCameraFragmentFS == null){ + localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); + ftFS.commitNowAllowingStateLoss(); + } + contactAvatarLayout.setVisibility(GONE); + parentLocalFS.setVisibility(View.VISIBLE); + fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); - videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); - videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); + }else{ + if(localCameraFragment == null){ + localCameraFragment = LocalCameraCallFragment.newInstance(chatId); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); + ft.commitNowAllowingStateLoss(); + } - } else { - log("Video local NOT connected"); - - if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - parentLocalFS.setVisibility(View.GONE); - fragmentContainerLocalCameraFS.setVisibility(View.GONE); - if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(localCameraFragmentFS); - localCameraFragmentFS = null; - } - contactAvatarLayout.setVisibility(View.VISIBLE); + myAvatarLayout.setVisibility(GONE); + parentLocal.setVisibility(View.VISIBLE); + fragmentContainerLocalCamera.setVisibility(View.VISIBLE); + } - }else{ - parentLocal.setVisibility(View.GONE); - fragmentContainerLocalCamera.setVisibility(View.GONE); - if (localCameraFragment != null) { - localCameraFragment.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(localCameraFragment); - localCameraFragment = null; + }else { + log("Video local NOT connected"); + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); + videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); + + if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + + if (localCameraFragmentFS != null) { + localCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(localCameraFragmentFS); + localCameraFragmentFS = null; + + } + contactAvatarLayout.setVisibility(View.VISIBLE); + parentLocalFS.setVisibility(View.GONE); + fragmentContainerLocalCameraFS.setVisibility(View.GONE); + + + }else{ + if (localCameraFragment != null) { + localCameraFragment.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(localCameraFragment); + localCameraFragment = null; + } + myAvatarLayout.setVisibility(View.VISIBLE); + parentLocal.setVisibility(View.GONE); + fragmentContainerLocalCamera.setVisibility(View.GONE); } - myAvatarLayout.setVisibility(View.VISIBLE); - } - videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); + } } + + } public void updateLocalAudioStatus(){ @@ -1779,48 +1947,8 @@ public void updateRemoteVideoStatus(long userHandle){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null && userSession.hasVideo()) { log(userHandle+": Video remote connected"); -// if(colorFragmentFS == null){ -// colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); -// ft.commitNowAllowingStateLoss(); -// parentColorFS.setVisibility(View.VISIBLE); -// fragmentContainerColorFS.setVisibility(View.VISIBLE); -// } - if(remoteCameraFragmentFS == null) { - - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); - - contactAvatarLayout.setOnClickListener(null); - contactAvatarLayout.setVisibility(GONE); - parentRemoteFS.setVisibility(View.VISIBLE); - fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); - } - }else { log(userHandle+": Video remote NOT connected"); - -// parentColorFS.setVisibility(View.GONE); -// fragmentContainerColorFS.setVisibility(View.GONE); -// if (colorFragmentFS != null) { -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(colorFragmentFS); -// colorFragmentFS = null; -// } - - parentRemoteFS.setVisibility(View.GONE); - fragmentContainerRemoteCameraFS.setVisibility(View.GONE); - if (remoteCameraFragmentFS != null) { - remoteCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(remoteCameraFragmentFS); - remoteCameraFragmentFS = null; - } - contactAvatarLayout.setVisibility(View.VISIBLE); - contactAvatarLayout.setOnClickListener(this); } } else{ @@ -1832,17 +1960,27 @@ public void updateRemoteVideoStatus(long userHandle){ log("Video remote connected"); isRemoteVideo = REMOTE_VIDEO_ENABLED; if (contactAvatarLayout.getVisibility() == View.VISIBLE) { - - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); + if(remoteCameraFragmentFS == null){ + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); + } contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); +// if(localCameraFragmentFS != null){ +// localCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(localCameraFragmentFS); +// localCameraFragmentFS = null; +// parentLocalFS.setVisibility(View.GONE); +// fragmentContainerLocalCameraFS.setVisibility(View.GONE); +// } + } else { log("No needed to refresh"); } @@ -1851,8 +1989,7 @@ public void updateRemoteVideoStatus(long userHandle){ log("Video remote NOT connected"); isRemoteVideo = REMOTE_VIDEO_DISABLED; - parentRemoteFS.setVisibility(View.GONE); - fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); @@ -1861,14 +1998,14 @@ public void updateRemoteVideoStatus(long userHandle){ } contactAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setOnClickListener(this); + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); } }else{ - log("Change on remote video"); if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ isRemoteVideo = REMOTE_VIDEO_DISABLED; - parentRemoteFS.setVisibility(View.GONE); - fragmentContainerRemoteCameraFS.setVisibility(View.GONE); + if (remoteCameraFragmentFS != null) { remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); @@ -1877,21 +2014,36 @@ public void updateRemoteVideoStatus(long userHandle){ } contactAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setOnClickListener(this); + parentRemoteFS.setVisibility(View.GONE); + fragmentContainerRemoteCameraFS.setVisibility(View.GONE); }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ isRemoteVideo = REMOTE_VIDEO_ENABLED; if (contactAvatarLayout.getVisibility() == View.VISIBLE) { - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); + + if(remoteCameraFragmentFS == null){ + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); + } + contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); +// if(localCameraFragmentFS != null){ +// localCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(localCameraFragmentFS); +// localCameraFragmentFS = null; +// parentLocalFS.setVisibility(View.GONE); +// fragmentContainerLocalCameraFS.setVisibility(View.GONE); +// } + } else { log("No needed to refresh"); } @@ -1900,6 +2052,140 @@ public void updateRemoteVideoStatus(long userHandle){ } } +// public void updateRemoteVideoStatus(long userHandle){ +// log("updateRemoteVideoStatus"); +// if(chat.isGroup()){ +// MegaChatSession userSession = callChat.getMegaChatSession(userHandle); +// if(userSession!=null && userSession.hasVideo()) { +// log(userHandle+": Video remote connected"); +//// if(colorFragmentFS == null){ +//// colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); +//// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +//// ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); +//// ft.commitNowAllowingStateLoss(); +//// parentColorFS.setVisibility(View.VISIBLE); +//// fragmentContainerColorFS.setVisibility(View.VISIBLE); +//// } +// if(remoteCameraFragmentFS == null) { +// +// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); +// ft.commitNowAllowingStateLoss(); +// +// contactAvatarLayout.setOnClickListener(null); +// contactAvatarLayout.setVisibility(GONE); +// +// parentRemoteFS.setVisibility(View.VISIBLE); +// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); +// } +// +// }else { +// log(userHandle+": Video remote NOT connected"); +// +//// parentColorFS.setVisibility(View.GONE); +//// fragmentContainerColorFS.setVisibility(View.GONE); +//// if (colorFragmentFS != null) { +//// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +//// ft.remove(colorFragmentFS); +//// colorFragmentFS = null; +//// } +// +// +// if (remoteCameraFragmentFS != null) { +// remoteCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(remoteCameraFragmentFS); +// remoteCameraFragmentFS = null; +// } +// contactAvatarLayout.setVisibility(View.VISIBLE); +// contactAvatarLayout.setOnClickListener(this); +// parentRemoteFS.setVisibility(View.GONE); +// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); +// +// } +// } +// else{ +// MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); +// +// if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ +// +// if(userSession!=null && userSession.hasVideo()){ +// log("Video remote connected"); +// isRemoteVideo = REMOTE_VIDEO_ENABLED; +// if (contactAvatarLayout.getVisibility() == View.VISIBLE) { +// +// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); +// ft.commitNowAllowingStateLoss(); +// +// contactAvatarLayout.setOnClickListener(null); +// contactAvatarLayout.setVisibility(GONE);// +// parentRemoteFS.setVisibility(View.VISIBLE); +// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); +// +// } else { +// log("No needed to refresh"); +// } +// +// }else{ +// log("Video remote NOT connected"); +// +// isRemoteVideo = REMOTE_VIDEO_DISABLED; +// +// if (remoteCameraFragmentFS != null) { +// remoteCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(remoteCameraFragmentFS); +// remoteCameraFragmentFS = null; +// } +//// +// parentRemoteFS.setVisibility(View.GONE); +// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); +// contactAvatarLayout.setVisibility(View.VISIBLE); +// contactAvatarLayout.setOnClickListener(this); +// } +// }else{ +// log("Change on remote video"); +// if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ +// +// isRemoteVideo = REMOTE_VIDEO_DISABLED; +// +// if (remoteCameraFragmentFS != null) { +// remoteCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(remoteCameraFragmentFS); +// remoteCameraFragmentFS = null; +// } +//// +// parentRemoteFS.setVisibility(View.GONE); +// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); +// contactAvatarLayout.setVisibility(View.VISIBLE); +// contactAvatarLayout.setOnClickListener(this); +// +// }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ +// +// isRemoteVideo = REMOTE_VIDEO_ENABLED; +// if (contactAvatarLayout.getVisibility() == View.VISIBLE) { +// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); +// ft.commitNowAllowingStateLoss(); +// +// contactAvatarLayout.setOnClickListener(null); +// contactAvatarLayout.setVisibility(GONE);// +// parentRemoteFS.setVisibility(View.VISIBLE); +// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); +// +// } else { +// log("No needed to refresh"); +// } +// } +// } +// } +// } + public void updateRemoteAudioStatus(long userHandle){ log("updateRemoteAudioStatus"); if(chat.isGroup()){ diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 76ba81587cb..47439dc9e81 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -22,6 +22,7 @@ @@ -88,66 +89,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 6b0b17ed2be8c7a9e5826335e3324e4150a4e60d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 23 Jul 2018 09:55:05 +0200 Subject: [PATCH 013/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 290 ------------------ .../main/res/layout/activity_calls_chat.xml | 2 + 2 files changed, 2 insertions(+), 290 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index ca7a7a00ae7..1248d47d2e3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1707,83 +1707,6 @@ public void onSwipeBottom() {} } } -// public void updateLocalVideoStatus(){ -// log("updateLocalVideoStatus: "); -// int callStatus = callChat.getStatus(); -// if(callChat !=null){ -// if (callChat.hasLocalVideo()) { -// log("Video local connected"); -// -// if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ -// contactAvatarLayout.setVisibility(GONE); -// parentLocal.setVisibility(GONE); -// parentLocalFS.setVisibility(View.VISIBLE); -// fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); -// if(localCameraFragmentFS == null){ -// localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); -// ftFS.commitNowAllowingStateLoss(); -// } -// -// -// }else{ -// -// myAvatarLayout.setVisibility(GONE); -// parentLocalFS.setVisibility(GONE); -// parentLocal.setVisibility(View.VISIBLE); -// fragmentContainerLocalCamera.setVisibility(View.VISIBLE); -// -// if(localCameraFragment == null){ -// localCameraFragment = LocalCameraCallFragment.newInstance(chatId); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); -// ft.commitNowAllowingStateLoss(); -// } -// -// -// } -// -// videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); -// videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); -// -// } else { -// log("Video local NOT connected"); -// -// if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ -// -// -// if (localCameraFragmentFS != null) { -// localCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(localCameraFragmentFS); -// localCameraFragmentFS = null; -// } -// contactAvatarLayout.setVisibility(View.VISIBLE);// -// parentLocalFS.setVisibility(View.GONE); -// fragmentContainerLocalCameraFS.setVisibility(View.GONE); -// -// }else{ -// -// if (localCameraFragment != null) { -// localCameraFragment.setVideoFrame(false); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(localCameraFragment); -// localCameraFragment = null; -// } -// myAvatarLayout.setVisibility(View.VISIBLE); -// parentLocal.setVisibility(View.GONE); -// fragmentContainerLocalCamera.setVisibility(View.GONE); -// } -// -// videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); -// videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); -// } -// -// -// } -// -// } public void updateLocalVideoStatus(){ @@ -1793,67 +1716,6 @@ public void updateLocalVideoStatus(){ if(chat.isGroup()){ log("is group"); if(callChat !=null){ - if (callChat.hasLocalVideo()) { - log("Video local connected"); - - if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - contactAvatarLayout.setVisibility(GONE); - parentLocal.setVisibility(GONE); - parentLocalFS.setVisibility(View.VISIBLE); - fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); - if(localCameraFragmentFS == null){ - localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); - ftFS.commitNowAllowingStateLoss(); - } - - }else{ - - myAvatarLayout.setVisibility(GONE); - parentLocalFS.setVisibility(GONE); - parentLocal.setVisibility(View.VISIBLE); - fragmentContainerLocalCamera.setVisibility(View.VISIBLE); - if(localCameraFragment == null){ - localCameraFragment = LocalCameraCallFragment.newInstance(chatId); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); - ft.commitNowAllowingStateLoss(); - } - } - - videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this,R.color.accentColor))); - videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_videocam_white)); - - }else { - log("Video local NOT connected"); - - if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ - if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(localCameraFragmentFS); - localCameraFragmentFS = null; - } - contactAvatarLayout.setVisibility(View.VISIBLE); - parentLocalFS.setVisibility(View.GONE); - fragmentContainerLocalCameraFS.setVisibility(View.GONE); - - }else{ - if (localCameraFragment != null) { - localCameraFragment.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(localCameraFragment); - localCameraFragment = null; - } - myAvatarLayout.setVisibility(View.VISIBLE); - parentLocal.setVisibility(View.GONE); - fragmentContainerLocalCamera.setVisibility(View.GONE); - } - - videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - videoFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_video_off)); - } } @@ -1972,15 +1834,6 @@ public void updateRemoteVideoStatus(long userHandle){ parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); -// if(localCameraFragmentFS != null){ -// localCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(localCameraFragmentFS); -// localCameraFragmentFS = null; -// parentLocalFS.setVisibility(View.GONE); -// fragmentContainerLocalCameraFS.setVisibility(View.GONE); -// } - } else { log("No needed to refresh"); } @@ -2035,15 +1888,6 @@ public void updateRemoteVideoStatus(long userHandle){ parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); -// if(localCameraFragmentFS != null){ -// localCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(localCameraFragmentFS); -// localCameraFragmentFS = null; -// parentLocalFS.setVisibility(View.GONE); -// fragmentContainerLocalCameraFS.setVisibility(View.GONE); -// } - } else { log("No needed to refresh"); } @@ -2052,140 +1896,6 @@ public void updateRemoteVideoStatus(long userHandle){ } } -// public void updateRemoteVideoStatus(long userHandle){ -// log("updateRemoteVideoStatus"); -// if(chat.isGroup()){ -// MegaChatSession userSession = callChat.getMegaChatSession(userHandle); -// if(userSession!=null && userSession.hasVideo()) { -// log(userHandle+": Video remote connected"); -//// if(colorFragmentFS == null){ -//// colorFragmentFS = ColorFragment.newInstance(chatId, chat.getPeerHandle(0), 1); -//// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -//// ft.replace(R.id.fragment_container_group_call_cameraFS, colorFragmentFS, "colorFragmentFS"); -//// ft.commitNowAllowingStateLoss(); -//// parentColorFS.setVisibility(View.VISIBLE); -//// fragmentContainerColorFS.setVisibility(View.VISIBLE); -//// } -// if(remoteCameraFragmentFS == null) { -// -// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); -// ft.commitNowAllowingStateLoss(); -// -// contactAvatarLayout.setOnClickListener(null); -// contactAvatarLayout.setVisibility(GONE); -// -// parentRemoteFS.setVisibility(View.VISIBLE); -// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); -// } -// -// }else { -// log(userHandle+": Video remote NOT connected"); -// -//// parentColorFS.setVisibility(View.GONE); -//// fragmentContainerColorFS.setVisibility(View.GONE); -//// if (colorFragmentFS != null) { -//// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -//// ft.remove(colorFragmentFS); -//// colorFragmentFS = null; -//// } -// -// -// if (remoteCameraFragmentFS != null) { -// remoteCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(remoteCameraFragmentFS); -// remoteCameraFragmentFS = null; -// } -// contactAvatarLayout.setVisibility(View.VISIBLE); -// contactAvatarLayout.setOnClickListener(this); -// parentRemoteFS.setVisibility(View.GONE); -// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); -// -// } -// } -// else{ -// MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); -// -// if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ -// -// if(userSession!=null && userSession.hasVideo()){ -// log("Video remote connected"); -// isRemoteVideo = REMOTE_VIDEO_ENABLED; -// if (contactAvatarLayout.getVisibility() == View.VISIBLE) { -// -// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); -// ft.commitNowAllowingStateLoss(); -// -// contactAvatarLayout.setOnClickListener(null); -// contactAvatarLayout.setVisibility(GONE);// -// parentRemoteFS.setVisibility(View.VISIBLE); -// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); -// -// } else { -// log("No needed to refresh"); -// } -// -// }else{ -// log("Video remote NOT connected"); -// -// isRemoteVideo = REMOTE_VIDEO_DISABLED; -// -// if (remoteCameraFragmentFS != null) { -// remoteCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(remoteCameraFragmentFS); -// remoteCameraFragmentFS = null; -// } -//// -// parentRemoteFS.setVisibility(View.GONE); -// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); -// contactAvatarLayout.setVisibility(View.VISIBLE); -// contactAvatarLayout.setOnClickListener(this); -// } -// }else{ -// log("Change on remote video"); -// if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ -// -// isRemoteVideo = REMOTE_VIDEO_DISABLED; -// -// if (remoteCameraFragmentFS != null) { -// remoteCameraFragmentFS.setVideoFrame(false); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(remoteCameraFragmentFS); -// remoteCameraFragmentFS = null; -// } -//// -// parentRemoteFS.setVisibility(View.GONE); -// fragmentContainerRemoteCameraFS.setVisibility(View.GONE); -// contactAvatarLayout.setVisibility(View.VISIBLE); -// contactAvatarLayout.setOnClickListener(this); -// -// }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ -// -// isRemoteVideo = REMOTE_VIDEO_ENABLED; -// if (contactAvatarLayout.getVisibility() == View.VISIBLE) { -// remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); -// ft.commitNowAllowingStateLoss(); -// -// contactAvatarLayout.setOnClickListener(null); -// contactAvatarLayout.setVisibility(GONE);// -// parentRemoteFS.setVisibility(View.VISIBLE); -// fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); -// -// } else { -// log("No needed to refresh"); -// } -// } -// } -// } -// } - public void updateRemoteAudioStatus(long userHandle){ log("updateRemoteAudioStatus"); if(chat.isGroup()){ diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 47439dc9e81..38f762faed8 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -20,6 +20,8 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + Date: Wed, 25 Jul 2018 08:28:47 +0200 Subject: [PATCH 014/247] Feature#9775-Group calls UI --- .idea/misc.xml | 2 +- .../adapters/MegaBrowserLollipopAdapter.java | 1 - .../lollipop/listeners/GroupCallListener.java | 72 +++ .../megachat/calls/ChatCallActivity.java | 144 +++-- ...nt.java => GroupCallFragmentLollipop.java} | 46 +- .../megachat/calls/InfoPeerGroupCall.java | 62 +++ .../chatAdapters/GroupCallAdapter.java | 492 ++++++++++++++++++ .../main/res/layout/activity_calls_chat.xml | 12 +- app/src/main/res/layout/fragment_color.xml | 15 - .../main/res/layout/fragment_group_call.xml | 14 + .../res/layout/item_camera_group_call.xml | 53 ++ 11 files changed, 782 insertions(+), 131 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java rename app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/{ColorFragment.java => GroupCallFragmentLollipop.java} (62%) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java delete mode 100644 app/src/main/res/layout/fragment_color.xml create mode 100644 app/src/main/res/layout/fragment_group_call.xml create mode 100644 app/src/main/res/layout/item_camera_group_call.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index ba7052b8197..635999df1e8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaBrowserLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaBrowserLollipopAdapter.java index 4deb9b6e023..00f964f44c3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaBrowserLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaBrowserLollipopAdapter.java @@ -1136,7 +1136,6 @@ else if(node.isInShare()){ holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); }else{ if(((ManagerActivityLollipop) context).isCameraUploads(node)){ - log("**** cu"); holder.imageView.setImageResource(R.drawable.ic_folder_image_list); }else{ holder.imageView.setImageResource(R.drawable.ic_folder_list); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java new file mode 100644 index 00000000000..b0af260e423 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -0,0 +1,72 @@ +package mega.privacy.android.app.lollipop.listeners; + +import android.content.Context; +import android.graphics.Bitmap; +import android.util.Log; +import android.view.SurfaceHolder; +import java.nio.ByteBuffer; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; + + +public class GroupCallListener implements MegaChatVideoListenerInterface { + + Context context; + GroupCallAdapter.ViewHolderGroupCall holder; + int width,height; + Bitmap bitmap; + + public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall holder) { + this.context = context; + this.holder = holder; + + } + + public GroupCallListener(Context context) { + this.context = context; + } + + + @Override + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { + Log.d("*******","**** onChatVideoData()"); + if((width == 0) || (height == 0)){ + return; + } + + if (this.width != width || this.height != height) { + this.width = width; + this.height = height; + + SurfaceHolder Sholder = holder.localFullScreenSurfaceView.getHolder(); + if (Sholder != null) { + int viewWidth = holder.localFullScreenSurfaceView.getWidth(); + int viewHeight = holder.localFullScreenSurfaceView.getHeight(); + if ((viewWidth != 0) && (viewHeight != 0)) { + int holderWidth = viewWidth < width ? viewWidth : width; + int holderHeight = holderWidth * viewHeight / viewWidth; + if (holderHeight > viewHeight) { + holderHeight = viewHeight; + holderWidth = holderHeight * viewWidth / viewHeight; + } + this.bitmap = holder.localRenderer.CreateBitmap(width, height); + Sholder.setFixedSize(holderWidth, holderHeight); + } + else{ + this.width = -1; + this.height = -1; + } + } + } + + if (bitmap != null) { + bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); + + // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. + // The renderer has been modified a bit and an update of WebRTC could break our app + holder.localRenderer.DrawBitmap(false); + } + } +} + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1248d47d2e3..5eced70f890 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -35,6 +35,9 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.Display; @@ -71,9 +74,13 @@ import mega.privacy.android.app.R; import mega.privacy.android.app.components.OnSwipeTouchListener; import mega.privacy.android.app.components.RoundedImageView; +import mega.privacy.android.app.components.SimpleDividerItemDecoration; +import mega.privacy.android.app.components.scrollBar.FastScroller; import mega.privacy.android.app.lollipop.LoginActivityLollipop; +import mega.privacy.android.app.lollipop.adapters.MegaBrowserLollipopAdapter; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; import mega.privacy.android.app.utils.Util; @@ -136,13 +143,19 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque boolean avatarRequested = false; - ArrayList peersOnCall = new ArrayList<>(); + ArrayList peersOnCall = new ArrayList<>(); Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; + RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; + RelativeLayout bigElementsGroupCallLayout; + + RecyclerView recyclerView; + LinearLayoutManager mLayoutManager; + GroupCallAdapter adapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -176,11 +189,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FrameLayout fragmentContainerLocalCameraFS; FrameLayout fragmentContainerRemoteCameraFS; -// //pruebas colores: -// ViewGroup parentColorFS; -// private ColorFragment colorFragmentFS = null; -// FrameLayout fragmentContainerColorFS; - ViewGroup parentLocal; ViewGroup parentLocalFS; ViewGroup parentRemoteFS; @@ -483,8 +491,6 @@ protected void onCreate(Bundle savedInstanceState) { aB.setTitle(" "); myChrono = new Chronometer(context); - peersOnCall.add(megaChatApi.getMyUserHandle()); - smallElementsIndividualCallLayout = (RelativeLayout) findViewById(R.id.small_elements_individual_call); smallElementsIndividualCallLayout.setVisibility(GONE); @@ -534,6 +540,19 @@ protected void onCreate(Bundle savedInstanceState) { shake = AnimationUtils.loadAnimation(this, R.anim.shake); rtcAudioManager = AppRTCAudioManager.create(getApplicationContext()); + //Cameras in Group call + bigElementsGroupCallLayout = (RelativeLayout) findViewById(R.id.big_elements_group_call); + bigElementsGroupCallLayout.setVisibility(GONE); + + recyclerView = (RecyclerView) findViewById(R.id.recycler_view_cameras); + recyclerView.setPadding(0, 0, 0,0); + recyclerView.setClipToPadding(false); +// recyclerView.addItemDecoration(new SimpleDividerItemDecoration(context, outMetrics)); + mLayoutManager = new LinearLayoutManager(context); + recyclerView.setLayoutManager(mLayoutManager); + recyclerView.setHasFixedSize(true); +// recyclerView.setItemAnimator(new DefaultItemAnimator()); + //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); @@ -628,12 +647,12 @@ protected void onCreate(Bundle savedInstanceState) { if(chat.isGroup()){ smallElementsIndividualCallLayout.setVisibility(View.GONE); bigElementsIndividualCallLayout.setVisibility(View.GONE); + bigElementsGroupCallLayout.setVisibility(View.VISIBLE); }else{ smallElementsIndividualCallLayout.setVisibility(View.VISIBLE); bigElementsIndividualCallLayout.setVisibility(View.VISIBLE); - - + bigElementsGroupCallLayout.setVisibility(View.GONE); } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ @@ -658,8 +677,8 @@ protected void onCreate(Bundle savedInstanceState) { if(chat.isGroup()){ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - } - else{ + + }else{ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -689,13 +708,27 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("is Group"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - myAvatarLayout.setVisibility(View.GONE); - flagMyAvatar = false; - setProfileMyAvatar(); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); + peersOnCall.add(myPeer); + + if (adapter == null){ + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + } + else{ + adapter.setNodes(peersOnCall); + adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + } + + recyclerView.setAdapter(adapter); + adapter.setNodes(peersOnCall); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } }else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -760,11 +793,11 @@ public void createDefaultAvatar(long userHandle, String fullName) { } int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) - radius = defaultAvatar.getWidth()/2; - else - radius = defaultAvatar.getHeight()/2; - + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); if(flagContactAvatar){ myImage.setImageBitmap(defaultAvatar); @@ -1233,6 +1266,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",true, false, null); + log("userHandle added: "+userHandle); + peersOnCall.add(0,userPeer); + adapter.setNodes(peersOnCall); } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1341,70 +1378,6 @@ public void stopAudioSignals(){ ringerTimer = null; } - public Bitmap createDefaultAvatar(){ - log("createDefaultAvatar()"); - - Bitmap defaultAvatar = Bitmap.createBitmap(Constants.DEFAULT_AVATAR_WIDTH_HEIGHT,Constants.DEFAULT_AVATAR_WIDTH_HEIGHT, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint paintText = new Paint(); - Paint paintCircle = new Paint(); - - paintText.setColor(Color.WHITE); - paintText.setTextSize(150); - paintText.setAntiAlias(true); - paintText.setTextAlign(Paint.Align.CENTER); - Typeface face = Typeface.SANS_SERIF; - paintText.setTypeface(face); - paintText.setAntiAlias(true); - paintText.setSubpixelText(true); - paintText.setStyle(Paint.Style.FILL); - - if(chat.isGroup()){ - paintCircle.setColor(ContextCompat.getColor(context,R.color.divider_upgrade_account)); - } - else{ - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(chat.getPeerHandle(0))); - if(color!=null){ - log("The color to set the avatar is "+color); - paintCircle.setColor(Color.parseColor(color)); - paintCircle.setAntiAlias(true); - } - else{ - log("Default color to the avatar"); - paintCircle.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); - paintCircle.setAntiAlias(true); - } - } - - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) - radius = defaultAvatar.getWidth()/2; - else - radius = defaultAvatar.getHeight()/2; - - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius,paintCircle); - - if(chat.getTitle()!=null){ - if(!chat.getTitle().isEmpty()){ - char title = chat.getTitle().charAt(0); - String firstLetter = new String(title+""); - - if(!firstLetter.equals("(")){ - - log("Draw letter: "+firstLetter); - Rect bounds = new Rect(); - - paintText.getTextBounds(firstLetter,0,firstLetter.length(),bounds); - int xPos = (c.getWidth()/2); - int yPos = (int)((c.getHeight()/2)-((paintText.descent()+paintText.ascent()/2))+20); - c.drawText(firstLetter.toUpperCase(Locale.getDefault()), xPos, yPos, paintText); - } - - } - } - return defaultAvatar; - } - int width = 0; int height = 0; Bitmap bitmap; @@ -1717,7 +1690,6 @@ public void updateLocalVideoStatus(){ log("is group"); if(callChat !=null){ - } }else{ log("is individual"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/GroupCallFragmentLollipop.java similarity index 62% rename from app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java rename to app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/GroupCallFragmentLollipop.java index 39d249551e1..aac43e9d0af 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ColorFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/GroupCallFragmentLollipop.java @@ -2,7 +2,7 @@ import android.app.Activity; import android.content.Context; -import android.graphics.Color; +import android.graphics.Bitmap; import android.graphics.PixelFormat; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -11,34 +11,30 @@ import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; -import android.widget.RelativeLayout; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; -public class ColorFragment extends Fragment { +public class GroupCallFragmentLollipop extends Fragment implements MegaChatVideoListenerInterface { int width = 0; int height = 0; + Bitmap bitmap; MegaChatApiAndroid megaChatApi; Context context; long chatId; - long userHandle; - int color; - public RelativeLayout remoteFullScreenSurfaceView; - public static ColorFragment newInstance(long chatId, long userHandle, int color) { + public static GroupCallFragmentLollipop newInstance(long chatId) { log("newInstance"); - ColorFragment f = new ColorFragment(); + GroupCallFragmentLollipop f = new GroupCallFragmentLollipop(); Bundle args = new Bundle(); args.putLong("chatId", chatId); - args.putLong("userHandle",userHandle); - args.putInt("color",color); f.setArguments(args); return f; } @@ -52,8 +48,7 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); - this.userHandle = args.getLong("userHandle", -1); - this.color = args.getInt("color",0); + super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -66,21 +61,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return null; } - View v = inflater.inflate(R.layout.fragment_color, container, false); + View v = inflater.inflate(R.layout.fragment_group_call, container, false); - remoteFullScreenSurfaceView = (RelativeLayout)v.findViewById(R.id.surface_remote_video); + return v; + } - if(color == 1){ - remoteFullScreenSurfaceView.setBackgroundColor(Color.BLUE); - }else if (color == 2){ - remoteFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); - }else if (color == 3){ - remoteFullScreenSurfaceView.setBackgroundColor(Color.GREEN); - }else{ - remoteFullScreenSurfaceView.setBackgroundColor(Color.MAGENTA); - } + @Override + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { - return v; + } + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + context = activity; } @@ -92,6 +85,7 @@ public void onAttach(Context context) { @Override public void onDestroy(){ + megaChatApi.removeChatVideoListener(chatId, -1, this); super.onDestroy(); } @Override @@ -101,10 +95,8 @@ public void onResume() { this.height=0; super.onResume(); } - private static void log(String log) { - Util.log("ColorFragment", log); + Util.log("GroupCallFragmentLollipop", log); } - } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java new file mode 100644 index 00000000000..59962456c09 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java @@ -0,0 +1,62 @@ +package mega.privacy.android.app.lollipop.megachat.calls; + + +import mega.privacy.android.app.lollipop.listeners.GroupCallListener; + +public class InfoPeerGroupCall { + Long handle; + String name; + boolean videoOn; + boolean audioOn; + GroupCallListener listener; + + public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener) { + this.handle = handle; + this.name = name; + this.videoOn = videoOn; + this.audioOn = audioOn; + this.listener = listener; + } + + public Long getHandle() { + return handle; + } + + public void setHandle(Long handle) { + this.handle = handle; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isVideoOn() { + return videoOn; + } + + public void setVideoOn(boolean videoOn) { + this.videoOn = videoOn; + } + + public boolean isAudioOn() { + return audioOn; + } + + public void setAudioOn(boolean audioOn) { + this.audioOn = audioOn; + } + + public GroupCallListener getListener() { + return listener; + } + + public void setListener(GroupCallListener listener) { + this.listener = listener; + } + + +} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java new file mode 100644 index 00000000000..f5884567890 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -0,0 +1,492 @@ +package mega.privacy.android.app.lollipop.megachat.chatAdapters; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.PixelFormat; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.RecyclerView; +import android.util.DisplayMetrics; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.io.File; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Locale; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.components.RoundedImageView; +import mega.privacy.android.app.lollipop.adapters.FileStorageLollipopAdapter; +import mega.privacy.android.app.lollipop.listeners.GroupCallListener; +import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; +import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; +import mega.privacy.android.app.lollipop.megachat.calls.InfoPeerGroupCall; +import mega.privacy.android.app.lollipop.megachat.calls.LocalCameraCallFullScreenFragment; +import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRenderer; +import mega.privacy.android.app.lollipop.megachat.calls.RemoteCameraCallFullScreenFragment; +import mega.privacy.android.app.utils.Constants; +import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; +import nz.mega.sdk.MegaNode; + +import static android.view.View.GONE; +import static mega.privacy.android.app.utils.Util.context; + + +public class GroupCallAdapter extends RecyclerView.Adapter { + + public static final int ITEM_VIEW_TYPE_GRID = 1; + + Context context; + MegaApiAndroid megaApi; + MegaChatApiAndroid megaChatApi = null; + Display display; + DisplayMetrics outMetrics; + float density; + float scaleW; + float scaleH; + float widthScreenPX, heightScreenPX; + + RecyclerView recyclerViewFragment; + ArrayList peers; + long chatId; + + int width = 0; + int height = 0; + Bitmap bitmap; + + private int numberOfCells; + private int gridWidth = 50; + boolean avatarRequested = false; + private int adapterType; + + + public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType) { + log("GroupCallAdapter()"); + + this.context = context; + this.recyclerViewFragment = recyclerView; + this.peers = peers; + this.chatId = chatId; + this.adapterType = adapterType; + + MegaApplication app = (MegaApplication) ((Activity) context).getApplication(); + if (megaApi == null) { + megaApi = app.getMegaApi(); + } + + log("retryPendingConnections()"); + if (megaApi != null) { + log("---------retryPendingConnections"); + megaApi.retryPendingConnections(); + } + + if (megaChatApi == null) { + megaChatApi = app.getMegaChatApi(); + } + } + + /*private view holder class*/ + public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ + + public RelativeLayout rLayout; + public RelativeLayout avatarLayout; + public RoundedImageView avatarImage; + public TextView avatarInitialLetter; + public SurfaceView localFullScreenSurfaceView; + public MegaSurfaceRenderer localRenderer; + + public ViewHolderGroupCall(View itemView) { + super(itemView); + } + + } + + public class ViewHolderGroupCallGrid extends ViewHolderGroupCall{ + public ViewHolderGroupCallGrid(View v) { + super(v); + } + + } + + ViewHolderGroupCallGrid holderGrid = null; + + @Override public GroupCallAdapter.ViewHolderGroupCall onCreateViewHolder(ViewGroup parent, int viewType) { + log("onCreateViewHolder()"); + + display = ((Activity) context).getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics(); + display.getMetrics(outMetrics); + widthScreenPX = outMetrics.widthPixels; + heightScreenPX = outMetrics.heightPixels; + + density = ((Activity) context).getResources().getDisplayMetrics().density; + + scaleW = Util.getScaleW(outMetrics, density); + scaleH = Util.getScaleH(outMetrics, density); + + + + if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ +// View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); +// GroupCallAdapter.ViewHolderGroupCall holder = new GroupCallAdapter.ViewHolderGroupCall(v); +// +// holder.rLayout = (RelativeLayout) v.findViewById(R.id.rl); +// holder.rLayout.setVisibility(View.VISIBLE); +// holder.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); +// holder.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); +// holder.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); +// +// holder.localFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); +// holder.localFullScreenSurfaceView.setZOrderMediaOverlay(true); +// SurfaceHolder localSurfaceHolder = holder.localFullScreenSurfaceView.getHolder(); +// localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); +// holder.localRenderer = new MegaSurfaceRenderer( holder.localFullScreenSurfaceView); +// +// v.setTag(holder); +// return holder; + + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); + + holderGrid = new ViewHolderGroupCallGrid(v); + holderGrid.rLayout = (RelativeLayout) v.findViewById(R.id.rl); + holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); + holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); + holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); + holderGrid.localFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); + holderGrid.localFullScreenSurfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = holderGrid.localFullScreenSurfaceView.getHolder(); + localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holderGrid.localRenderer = new MegaSurfaceRenderer( holderGrid.localFullScreenSurfaceView); + + v.setTag(holderGrid); + return holderGrid; + + }else{ + return null; + + } + } + + @Override + public int getItemViewType(int position) { + return adapterType; + } + + @Override + public void onBindViewHolder(ViewHolderGroupCall holder, int position) { + log("onBindViewHolder"); + + if (adapterType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ + ViewHolderGroupCallGrid holderGrid = (ViewHolderGroupCallGrid) holder; + onBindViewHolderGrid(holderGrid, position); + } + + } + +// @Override +// public void onBindViewHolder(ViewHolderGroupCall holder, int position) { +public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ + + log("onBindViewHolderGrid()"); + + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); + if(peer.isVideoOn()){ + log("video on"); + this.width=0; + this.height=0; + GroupCallListener listenerPeer = new GroupCallListener(context,holder); + peer.setListener(listenerPeer); + megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); + holder.avatarLayout.setVisibility(GONE); + }else{ + log("video off"); + + holder.avatarLayout.setVisibility(View.VISIBLE); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + setProfileMyAvatar(holder); + }else{ + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); + } + } + + } + + public void setNodes(ArrayList peers) { + log("setNodes() -> peers: "+peers.size()); + this.peers = peers; + for(int i=0; i "+peers.size()); + + return peers.size(); + }else{ + log("getItemCount() -> 0"); + + return 0; + } + + } + + public Object getItem(int position) { + log("getItem()"); + + if (peers != null){ + return peers.get(position); + } + + return null; + } + + + public InfoPeerGroupCall getNodeAt(int position) { + log("getNodeAt() position-> "+position); + + try { + if (peers != null) { + return peers.get(position); + } + } catch (IndexOutOfBoundsException e) { + } + return null; + } + +// public int getGridWidth() { +// log("getGridWidth()"); +// return gridWidth; +// } +// +// public void setGridWidth(int gridWidth, ViewHolderGroupCall holder) { +// log("setGridWidth()"); +// +// if(this.gridWidth != gridWidth){ +// this.gridWidth = gridWidth; +//// ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) holder.contentLayout.getLayoutParams(); +//// params.height = gridWidth; +//// params.width = gridWidth; +//// holder.contentLayout.setLayoutParams(params); +// +// } +// } + + //My AVATAR + public void setProfileMyAvatar(ViewHolderGroupCall holder) { + log("setProfileMyAvatar()"); + + Bitmap myBitmap = null; + File avatar = null; + if (context != null) { + log("context is not null"); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } + } + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); + if (myBitmap != null) { + holder.avatarImage.setImageBitmap(myBitmap); + holder.avatarInitialLetter.setVisibility(GONE); + } + else{ + createMyDefaultAvatar(holder); + } + } + else { + createMyDefaultAvatar(holder); + } + } else { + createMyDefaultAvatar(holder); + } + } + + public void createMyDefaultAvatar(ViewHolderGroupCall holder) { + log("createMyDefaultAvatar()"); + + String myFullName = megaChatApi.getMyFullname(); + String myFirstLetter=myFullName.charAt(0) + ""; + myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); + long userHandle = megaChatApi.getMyUserHandle(); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels,outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + + if(color!=null){ + log("The color to set the avatar is "+color); + p.setColor(Color.parseColor(color)); + } + else{ + log("Default color to the avatar"); + p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) + radius = defaultAvatar.getWidth()/2; + else + radius = defaultAvatar.getHeight()/2; + + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + holder.avatarImage.setImageBitmap(defaultAvatar); + holder.avatarInitialLetter.setText(myFirstLetter); + holder.avatarInitialLetter.setTextSize(40); + holder.avatarInitialLetter.setTextColor(Color.WHITE); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + + } + + + public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ + log("setProfileContactAvatar"); + Bitmap bitmap = null; + File avatar = null; + String contactMail = megaChatApi.getContactEmail(userHandle); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); + if (bitmap != null) { + holder.avatarImage.setVisibility(View.VISIBLE); + holder.avatarImage.setImageBitmap(bitmap); + holder.avatarInitialLetter.setVisibility(GONE); + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + avatar.delete(); + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + + public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGroupCall holder) { + log("createDefaultAvatar"); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + log("The color to set the avatar is " + color); + p.setColor(Color.parseColor(color)); + } else { + log("Default color to the avatar"); + p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + holder.avatarImage.setVisibility(View.VISIBLE); + holder.avatarImage.setImageBitmap(defaultAvatar); + String contactFirstLetter = fullName.charAt(0) + ""; + contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); + holder.avatarInitialLetter.setText(contactFirstLetter); + holder.avatarInitialLetter.setTextSize(60); + holder.avatarInitialLetter.setTextColor(Color.WHITE); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + + } + + public void setAdapterType(int adapterType){ + this.adapterType = adapterType; + } + private static void log(String log) { + Util.log("GroupCallAdapter", log); + } + +} diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 38f762faed8..fa02955d0dd 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -20,7 +20,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + + + + - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_group_call.xml b/app/src/main/res/layout/fragment_group_call.xml new file mode 100644 index 00000000000..4eb878f4900 --- /dev/null +++ b/app/src/main/res/layout/fragment_group_call.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml new file mode 100644 index 00000000000..7aab9878830 --- /dev/null +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + \ No newline at end of file From 68afe0918af85f18d927b38b2ba2cf8ab7501137 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 25 Jul 2018 08:31:00 +0200 Subject: [PATCH 015/247] Feature#9775-Group calls UI --- .../megachat/chatAdapters/GroupCallAdapter.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index f5884567890..35bf2190ed1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -279,23 +279,6 @@ public InfoPeerGroupCall getNodeAt(int position) { return null; } -// public int getGridWidth() { -// log("getGridWidth()"); -// return gridWidth; -// } -// -// public void setGridWidth(int gridWidth, ViewHolderGroupCall holder) { -// log("setGridWidth()"); -// -// if(this.gridWidth != gridWidth){ -// this.gridWidth = gridWidth; -//// ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) holder.contentLayout.getLayoutParams(); -//// params.height = gridWidth; -//// params.width = gridWidth; -//// holder.contentLayout.setLayoutParams(params); -// -// } -// } //My AVATAR public void setProfileMyAvatar(ViewHolderGroupCall holder) { From f74c263b8c6b43ffc026c83e8b5a8407ae88f859 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 25 Jul 2018 11:51:11 +0200 Subject: [PATCH 016/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 32 ++++++++--- .../LocalCameraCallFullScreenFragment.java | 2 + .../chatAdapters/GroupCallAdapter.java | 57 +++++++++++++++++-- .../main/res/layout/activity_calls_chat.xml | 10 +++- .../res/layout/item_camera_group_call.xml | 5 +- 5 files changed, 89 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 5eced70f890..330041ff480 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -36,6 +36,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; @@ -72,6 +73,7 @@ import mega.privacy.android.app.DatabaseHandler; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; +import mega.privacy.android.app.components.CustomizedGridRecyclerView; import mega.privacy.android.app.components.OnSwipeTouchListener; import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.SimpleDividerItemDecoration; @@ -545,13 +547,29 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsGroupCallLayout.setVisibility(GONE); recyclerView = (RecyclerView) findViewById(R.id.recycler_view_cameras); - recyclerView.setPadding(0, 0, 0,0); + + //****************************** + recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); -// recyclerView.addItemDecoration(new SimpleDividerItemDecoration(context, outMetrics)); - mLayoutManager = new LinearLayoutManager(context); - recyclerView.setLayoutManager(mLayoutManager); recyclerView.setHasFixedSize(true); -// recyclerView.setItemAnimator(new DefaultItemAnimator()); + ((CustomizedGridRecyclerView) recyclerView).setWrapContent(); + final GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); + gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { + @Override + public int getSpanSize(int position) { + return 1; + } + }); + + recyclerView.setItemAnimator(new DefaultItemAnimator()); + //***************************+ + + +// recyclerView.setPadding(0, 0, 0,0); +// recyclerView.setClipToPadding(false); +// mLayoutManager = new LinearLayoutManager(context); +// recyclerView.setLayoutManager(mLayoutManager); +// recyclerView.setHasFixedSize(true); //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); @@ -711,7 +729,7 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); peersOnCall.add(myPeer); if (adapter == null){ @@ -740,7 +758,7 @@ protected void onCreate(Bundle savedInstanceState) { myAvatarLayout.setVisibility(View.VISIBLE); } - + log("**** updateLocalVideo"); updateLocalVideoStatus(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java index 1a037486161..7afbb2cfc90 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java @@ -119,6 +119,8 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } } + + @Override public void onAttach(Activity activity) { super.onAttach(activity); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 35bf2190ed1..863291ba685 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -49,7 +49,7 @@ import static mega.privacy.android.app.utils.Util.context; -public class GroupCallAdapter extends RecyclerView.Adapter { +public class GroupCallAdapter extends RecyclerView.Adapter { public static final int ITEM_VIEW_TYPE_GRID = 1; @@ -141,8 +141,6 @@ public ViewHolderGroupCallGrid(View v) { scaleW = Util.getScaleW(outMetrics, density); scaleH = Util.getScaleH(outMetrics, density); - - if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ // View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); // GroupCallAdapter.ViewHolderGroupCall holder = new GroupCallAdapter.ViewHolderGroupCall(v); @@ -213,19 +211,32 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ log("video on"); + holderGrid.localFullScreenSurfaceView.setVisibility(View.VISIBLE); this.width=0; this.height=0; GroupCallListener listenerPeer = new GroupCallListener(context,holder); peer.setListener(listenerPeer); - megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("me"); + megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); + }else{ + log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); + } holder.avatarLayout.setVisibility(GONE); + }else{ log("video off"); - holder.avatarLayout.setVisibility(View.VISIBLE); + holderGrid.localFullScreenSurfaceView.setVisibility(View.GONE); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("me"); + setProfileMyAvatar(holder); }else{ + log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } } @@ -279,6 +290,33 @@ public InfoPeerGroupCall getNodeAt(int position) { return null; } +// @Override +// public View getView(int position, View convertView, ViewGroup parent) { +// Viewholder holder; +// if (convertView == null) { +// +// holder = new Viewholder(); +// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); +// convertView = inflater.inflate(R.layout.grid_list_item, null); +// +// holder.textView = (TextView) convertView.findViewById(R.id.txtTitle); +// holder.imageView = (ImageView)convertView.findViewById(R.id.imgGrid); +// +// +// convertView.setTag(holder); +// +// } else { +// +// holder = (Viewholder) convertView.getTag(); +// } +// +// holder.textView.setText(web[position]); +// holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); +// Glide.with(mContext).load(Imageid[position]).into(holder.imageView); +// +// return convertView; +// } + //My AVATAR public void setProfileMyAvatar(ViewHolderGroupCall holder) { @@ -363,6 +401,7 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde Bitmap bitmap = null; File avatar = null; String contactMail = megaChatApi.getContactEmail(userHandle); + log("contactMail: "+contactMail); if (context.getExternalCacheDir() != null) { avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); } else { @@ -472,4 +511,12 @@ private static void log(String log) { Util.log("GroupCallAdapter", log); } + public RecyclerView getListFragment() { + return recyclerViewFragment; + } + + public void setListFragment(RecyclerView recyclerViewFragment) { + this.recyclerViewFragment = recyclerViewFragment; + } + } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index fa02955d0dd..7e1229fe7cf 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -26,10 +26,16 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black"> - + + + + + android:layout_height="match_parent" + android:choiceMode="multipleChoice" + android:layout_centerInParent="true"/> diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 7aab9878830..0b9b73b51b9 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,14 +4,13 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_margin="6dp" android:layout_height="match_parent"> Date: Wed, 25 Jul 2018 15:35:19 +0200 Subject: [PATCH 017/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 55 +++++++++----- .../chatAdapters/GroupCallAdapter.java | 71 ++++++++++++------- .../main/res/layout/activity_calls_chat.xml | 20 ++++-- .../res/layout/item_camera_group_call.xml | 8 +-- 4 files changed, 100 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 330041ff480..7ee2162a26c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -156,7 +156,9 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout bigElementsGroupCallLayout; RecyclerView recyclerView; - LinearLayoutManager mLayoutManager; +// CustomizedGridRecyclerView recyclerView; + +// LinearLayoutManager mLayoutManager; GroupCallAdapter adapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -547,28 +549,36 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsGroupCallLayout.setVisibility(GONE); recyclerView = (RecyclerView) findViewById(R.id.recycler_view_cameras); - - //****************************** recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); - ((CustomizedGridRecyclerView) recyclerView).setWrapContent(); - final GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); - gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { - @Override - public int getSpanSize(int position) { - return 1; - } - }); - + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); + recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); - //***************************+ +// recyclerView = (CustomizedGridRecyclerView) findViewById(R.id.recycler_view_cameras); +// //****************************** +// recyclerView.setPadding(0, 0, 0, 0); +// recyclerView.setClipToPadding(false); +// recyclerView.setHasFixedSize(true); +// ((CustomizedGridRecyclerView) recyclerView).setWrapContent(); +// final GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); +// gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { +// @Override +// public int getSpanSize(int position) { +// return 1; +// } +// }); +// +// recyclerView.setItemAnimator(new DefaultItemAnimator()); +// //***************************+ + +// // recyclerView.setPadding(0, 0, 0,0); // recyclerView.setClipToPadding(false); -// mLayoutManager = new LinearLayoutManager(context); -// recyclerView.setLayoutManager(mLayoutManager); +//// LinearLayoutManager mLayoutManager = new LinearLayoutManager(context); +// recyclerView.setLayoutManager(new GridLayoutManager(this,1)); // recyclerView.setHasFixedSize(true); //Local camera small @@ -695,10 +705,14 @@ public int getSpanSize(int position) { if(chat.isGroup()){ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + relativeVideo.requestLayout(); + }else{ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + relativeVideo.requestLayout(); + myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); @@ -728,8 +742,9 @@ public int getSpanSize(int position) { if(chat.isGroup()){ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.requestLayout(); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); peersOnCall.add(myPeer); if (adapter == null){ @@ -739,6 +754,8 @@ public int getSpanSize(int position) { adapter.setNodes(peersOnCall); adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); } + adapter.notifyDataSetChanged(); + recyclerView.setAdapter(adapter); adapter.setNodes(peersOnCall); @@ -751,6 +768,8 @@ public int getSpanSize(int position) { }else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.requestLayout(); + flagMyAvatar = false; setProfileMyAvatar(); flagContactAvatar = true; @@ -1284,10 +1303,12 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",true, false, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",false, false, null); log("userHandle added: "+userHandle); peersOnCall.add(0,userPeer); adapter.setNodes(peersOnCall); + adapter.notifyDataSetChanged(); + } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 863291ba685..7463f321c1b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -8,6 +8,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; +import android.graphics.Point; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; @@ -47,6 +48,8 @@ import static android.view.View.GONE; import static mega.privacy.android.app.utils.Util.context; +import static mega.privacy.android.app.utils.Util.deleteFolderAndSubfolders; +import static mega.privacy.android.app.utils.Util.percScreenLogin; public class GroupCallAdapter extends RecyclerView.Adapter { @@ -141,29 +144,13 @@ public ViewHolderGroupCallGrid(View v) { scaleW = Util.getScaleW(outMetrics, density); scaleH = Util.getScaleH(outMetrics, density); - if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ -// View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); -// GroupCallAdapter.ViewHolderGroupCall holder = new GroupCallAdapter.ViewHolderGroupCall(v); -// -// holder.rLayout = (RelativeLayout) v.findViewById(R.id.rl); -// holder.rLayout.setVisibility(View.VISIBLE); -// holder.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); -// holder.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); -// holder.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); -// -// holder.localFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); -// holder.localFullScreenSurfaceView.setZOrderMediaOverlay(true); -// SurfaceHolder localSurfaceHolder = holder.localFullScreenSurfaceView.getHolder(); -// localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); -// holder.localRenderer = new MegaSurfaceRenderer( holder.localFullScreenSurfaceView); -// -// v.setTag(holder); -// return holder; + if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rLayout = (RelativeLayout) v.findViewById(R.id.rl); + holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); @@ -172,7 +159,6 @@ public ViewHolderGroupCallGrid(View v) { SurfaceHolder localSurfaceHolder = holderGrid.localFullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holderGrid.localRenderer = new MegaSurfaceRenderer( holderGrid.localFullScreenSurfaceView); - v.setTag(holderGrid); return holderGrid; @@ -208,6 +194,28 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if (peer == null){ return; } + + int numPeersOnCall = getItemCount(); + + if(numPeersOnCall < 4){ + log("**** peers: : "+numPeersOnCall); + holderGrid.rLayout.getLayoutParams().width = RelativeLayout.LayoutParams.MATCH_PARENT; + + //calculate height for 1 element: + int heightCameras = (int)(heightScreenPX/numPeersOnCall); + heightCameras = heightCameras - 80; + holderGrid.rLayout.getLayoutParams().height = heightCameras; + log("**** heightScreenPX: "+heightScreenPX+", heightCameras: "+heightCameras); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + holderGrid.rLayout.setBackgroundColor(Color.BLUE); + }else{ + holderGrid.rLayout.setBackgroundColor(Color.YELLOW); + + } + + } + log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ log("video on"); @@ -246,10 +254,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ public void setNodes(ArrayList peers) { log("setNodes() -> peers: "+peers.size()); this.peers = peers; - for(int i=0; i - - - - - + android:choiceMode="multipleChoice"/> + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 0b9b73b51b9..f548b510ba1 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,14 +4,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="wrap_content"> + android:layout_height="90dp" + android:background="@color/orange" + android:gravity="center"> Date: Thu, 26 Jul 2018 13:07:37 +0200 Subject: [PATCH 018/247] Feature#9775-Group calls UI --- .../CustomizedGridCallRecyclerView.java | 105 ++++++++++++++++++ .../lollipop/listeners/GroupCallListener.java | 1 - .../megachat/calls/ChatCallActivity.java | 55 ++------- .../chatAdapters/GroupCallAdapter.java | 38 ++++--- .../main/res/layout/activity_calls_chat.xml | 15 +-- .../res/layout/item_camera_group_call.xml | 25 +++-- 6 files changed, 154 insertions(+), 85 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java diff --git a/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java new file mode 100644 index 00000000000..3ff8a6e5988 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java @@ -0,0 +1,105 @@ +package mega.privacy.android.app.components; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.RecyclerView; +import android.util.AttributeSet; +import android.view.ViewGroup; +import mega.privacy.android.app.components.CustomizedGridLayoutManager; +import mega.privacy.android.app.utils.Util; + +public class CustomizedGridCallRecyclerView extends RecyclerView { + + private CustomizedGridLayoutManager manager; + public int columnWidth = -1; + private boolean isWrapContent = false; + private int widthTotal = 0; + + public CustomizedGridCallRecyclerView(Context context) { + super(context); + init(context, null); + } + + public CustomizedGridCallRecyclerView(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs); + } + + public CustomizedGridCallRecyclerView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(context, attrs); + } + + private void init(Context context, AttributeSet attrs) { + if (attrs != null) { + int[] attrsArray = { + android.R.attr.columnWidth + }; + TypedArray array = context.obtainStyledAttributes(attrs, attrsArray); + columnWidth = array.getDimensionPixelSize(0, -1); + array.recycle(); + } + + manager = new CustomizedGridLayoutManager(getContext(), 1); + setLayoutManager(manager); + } + + @Override + protected void onMeasure(int widthSpec, int heightSpec) { + super.onMeasure(widthSpec, heightSpec); + if(!isWrapContent){ + log("columnWidth :"+columnWidth); + if (columnWidth > 0) { + int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); + log("spanCount: "+spanCount); + manager.setSpanCount(spanCount); + } + }else{ + + ViewGroup.LayoutParams params = getLayoutParams(); + log("columnWidth :"+columnWidth); + + if (columnWidth > 0) { + int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); + log("spanCount: "+spanCount); + manager.setSpanCount(spanCount); + params.width = ViewGroup.LayoutParams.WRAP_CONTENT; + setLayoutParams(params); + } + } + } + + public void setWrapContent(){ + isWrapContent = true; +// widthTotal = getMeasuredWidth(); +// ViewGroup.LayoutParams params = getLayoutParams(); +// params.width = ViewGroup.LayoutParams.WRAP_CONTENT; +// setLayoutParams(params); + this.invalidate(); + } + + public int findFirstCompletelyVisibleItemPosition() { + return getLayoutManager().findFirstCompletelyVisibleItemPosition(); + } + + public int findFirstVisibleItemPosition() { + return getLayoutManager().findFirstVisibleItemPosition(); + } + + public int getColumnWidth() { + return columnWidth; + } + + public void setColumnWidth(int columnWidth) { + this.columnWidth = columnWidth; + } + + @Override + public CustomizedGridLayoutManager getLayoutManager() { + return manager; + } + + private static void log(String txt){ + Util.log("CustomizedGridCallRecyclerView", txt); + } +} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index b0af260e423..55295bb21d2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -30,7 +30,6 @@ public GroupCallListener(Context context) { @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { - Log.d("*******","**** onChatVideoData()"); if((width == 0) || (height == 0)){ return; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 7ee2162a26c..93af915a2c1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -11,8 +11,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.Typeface; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; @@ -36,9 +34,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.Display; @@ -73,13 +68,11 @@ import mega.privacy.android.app.DatabaseHandler; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; -import mega.privacy.android.app.components.CustomizedGridRecyclerView; +import mega.privacy.android.app.components.CustomizedGridLayoutManager; import mega.privacy.android.app.components.OnSwipeTouchListener; import mega.privacy.android.app.components.RoundedImageView; -import mega.privacy.android.app.components.SimpleDividerItemDecoration; -import mega.privacy.android.app.components.scrollBar.FastScroller; +import mega.privacy.android.app.components.CustomizedGridCallRecyclerView; import mega.privacy.android.app.lollipop.LoginActivityLollipop; -import mega.privacy.android.app.lollipop.adapters.MegaBrowserLollipopAdapter; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; @@ -155,10 +148,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout bigElementsIndividualCallLayout; RelativeLayout bigElementsGroupCallLayout; - RecyclerView recyclerView; -// CustomizedGridRecyclerView recyclerView; - -// LinearLayoutManager mLayoutManager; + CustomizedGridCallRecyclerView recyclerView; GroupCallAdapter adapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -413,7 +403,6 @@ protected void onCreate(Bundle savedInstanceState) { display.getMetrics(outMetrics); widthScreenPX = outMetrics.widthPixels; heightScreenPX = outMetrics.heightPixels; - density = getResources().getDisplayMetrics().density; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); @@ -548,39 +537,14 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsGroupCallLayout = (RelativeLayout) findViewById(R.id.big_elements_group_call); bigElementsGroupCallLayout.setVisibility(GONE); - recyclerView = (RecyclerView) findViewById(R.id.recycler_view_cameras); + recyclerView = (CustomizedGridCallRecyclerView) findViewById(R.id.recycler_view_cameras); recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); - recyclerView.setLayoutManager(linearLayoutManager); + recyclerView.setColumnWidth((int) widthScreenPX); + CustomizedGridLayoutManager gridLayoutManager = (CustomizedGridLayoutManager) recyclerView.getLayoutManager(); recyclerView.setItemAnimator(new DefaultItemAnimator()); -// recyclerView = (CustomizedGridRecyclerView) findViewById(R.id.recycler_view_cameras); - -// //****************************** -// recyclerView.setPadding(0, 0, 0, 0); -// recyclerView.setClipToPadding(false); -// recyclerView.setHasFixedSize(true); -// ((CustomizedGridRecyclerView) recyclerView).setWrapContent(); -// final GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); -// gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { -// @Override -// public int getSpanSize(int position) { -// return 1; -// } -// }); -// -// recyclerView.setItemAnimator(new DefaultItemAnimator()); -// //***************************+ - -// -// recyclerView.setPadding(0, 0, 0,0); -// recyclerView.setClipToPadding(false); -//// LinearLayoutManager mLayoutManager = new LinearLayoutManager(context); -// recyclerView.setLayoutManager(new GridLayoutManager(this,1)); -// recyclerView.setHasFixedSize(true); - //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); @@ -744,13 +708,12 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); peersOnCall.add(myPeer); if (adapter == null){ adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - } - else{ + }else{ adapter.setNodes(peersOnCall); adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); } @@ -1303,7 +1266,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",false, false, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",true, false, null); log("userHandle added: "+userHandle); peersOnCall.add(0,userPeer); adapter.setNodes(peersOnCall); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7463f321c1b..7bf5244853a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -109,6 +109,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList heightCameras("+heightCameras+")/heightScreenPX("+heightScreenPX+") "); + log("rLayout---> widthScreenPX("+widthScreenPX+")"); if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { holderGrid.rLayout.setBackgroundColor(Color.BLUE); +// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.BLUE); }else{ holderGrid.rLayout.setBackgroundColor(Color.YELLOW); - +// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); } +// holderGrid.localFullScreenSurfaceView.getHolder().setFixedSize(holderGrid.rLayout.getWidth(),holderGrid.rLayout.getHeight()); +// log("surfaceview---> height: "+holderGrid.rLayout.getHeight()+", width: "+holderGrid.rLayout.getWidth()); + } log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ log("video on"); holderGrid.localFullScreenSurfaceView.setVisibility(View.VISIBLE); + holder.avatarLayout.setVisibility(GONE); + + holderGrid.localFullScreenSurfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = holderGrid.localFullScreenSurfaceView.getHolder(); + localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holderGrid.localRenderer = new MegaSurfaceRenderer( holderGrid.localFullScreenSurfaceView); + this.width=0; this.height=0; GroupCallListener listenerPeer = new GroupCallListener(context,holder); peer.setListener(listenerPeer); if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("me"); megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); }else{ - log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); } - holder.avatarLayout.setVisibility(GONE); }else{ log("video off"); @@ -280,12 +288,12 @@ public int getItemCount() { // int numPeersOnCall = getItemCount(); // // if(numPeersOnCall < 4){ -// log("**** peers: : "+numPeersOnCall); +// log("peers: : "+numPeersOnCall); // holderGrid.rLayout.getLayoutParams().width = RelativeLayout.LayoutParams.MATCH_PARENT; // //calculate height for 1 element: // int heightCameras = (int)(heightScreenPX/numPeersOnCall); // holderGrid.rLayout.getLayoutParams().height = heightCameras; -// log("**** heightScreenPX: "+heightScreenPX+", heightCameras: "+heightCameras); +// log("heightScreenPX: "+heightScreenPX+", heightCameras: "+heightCameras); // } // } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index c26b066f639..d5cbb993a66 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -26,22 +26,13 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black"> - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index f548b510ba1..6d10edf548a 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,22 +4,25 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:layout_gravity="center_horizontal" android:layout_height="wrap_content"> - - + android:layout_height="match_parent" + android:gravity="center" + android:background="@android:color/transparent"> + + + Date: Thu, 26 Jul 2018 14:50:13 +0200 Subject: [PATCH 019/247] Feature#9775-Group calls UI --- .../megachat/calls/MegaSurfaceRenderer.java | 7 ++++++- .../chatAdapters/GroupCallAdapter.java | 18 ++++++++++-------- .../java/org/webrtc/SurfaceViewRenderer.java | 2 +- .../main/res/layout/activity_calls_chat.xml | 2 +- .../main/res/layout/item_camera_group_call.xml | 6 ++---- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index a2d7055cf85..1c170501b34 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -55,9 +55,11 @@ public class MegaSurfaceRenderer implements Callback { PorterDuffXfermode modesrcin; int surfaceWidth = 0; int surfaceHeight = 0; + SurfaceView surf; public MegaSurfaceRenderer(SurfaceView view) { + this.surf = view; surfaceHolder = view.getHolder(); if(surfaceHolder == null) return; @@ -104,7 +106,10 @@ private void adjustAspectRatio() { public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); - + android.view.ViewGroup.LayoutParams lp = surf.getLayoutParams(); + lp.width = in_width; + lp.height = in_height; + surf.setLayoutParams(lp); changeDestRect(in_width, in_height); Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7bf5244853a..6da3d7ed22f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -207,13 +207,14 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("rLayout---> heightCameras("+heightCameras+")/heightScreenPX("+heightScreenPX+") "); log("rLayout---> widthScreenPX("+widthScreenPX+")"); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - holderGrid.rLayout.setBackgroundColor(Color.BLUE); -// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.BLUE); - }else{ - holderGrid.rLayout.setBackgroundColor(Color.YELLOW); -// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); - } + +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { +// holderGrid.rLayout.setBackgroundColor(Color.BLUE); +//// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.BLUE); +// }else{ +// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); +//// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); +// } // holderGrid.localFullScreenSurfaceView.getHolder().setFixedSize(holderGrid.rLayout.getWidth(),holderGrid.rLayout.getHeight()); // log("surfaceview---> height: "+holderGrid.rLayout.getHeight()+", width: "+holderGrid.rLayout.getWidth()); @@ -225,8 +226,9 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("video on"); holderGrid.localFullScreenSurfaceView.setVisibility(View.VISIBLE); holder.avatarLayout.setVisibility(GONE); + holderGrid.localFullScreenSurfaceView.setZOrderOnTop(false); - holderGrid.localFullScreenSurfaceView.setZOrderMediaOverlay(true); +// holderGrid.localFullScreenSurfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holderGrid.localFullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holderGrid.localRenderer = new MegaSurfaceRenderer( holderGrid.localFullScreenSurfaceView); diff --git a/app/src/main/java/org/webrtc/SurfaceViewRenderer.java b/app/src/main/java/org/webrtc/SurfaceViewRenderer.java index ccfb9d0641e..4d1f4698393 100644 --- a/app/src/main/java/org/webrtc/SurfaceViewRenderer.java +++ b/app/src/main/java/org/webrtc/SurfaceViewRenderer.java @@ -284,7 +284,7 @@ public void run() { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { ThreadUtils.checkIsOnMainThread(); - logD("surfaceChanged: format: " + format + " size: " + width + "x" + height); + logD("******surfaceChanged: format: " + format + " size: " + width + "x" + height); } private String getResourceName() { diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index d5cbb993a66..7e26826ab68 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -26,7 +26,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black"> - From 13665007f0dd1a9580a7455bd05673f76aec0808 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 1 Aug 2018 13:24:13 +0200 Subject: [PATCH 020/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 35 ++++++++++++-- .../chatAdapters/GroupCallAdapter.java | 46 ++++++++++++++++++- .../res/layout/item_camera_group_call.xml | 6 +-- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b43147f8330..adc0a8bfac4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -649,7 +649,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - log("Incoming call"); + log("*****Incoming call"); ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); @@ -672,8 +672,33 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); + long numParticipants = chat.getPeerCount()-1; + long contactHandle = chat.getPeerHandle(numParticipants); + String contactName = chat.getPeerFullnameByHandle(contactHandle); + + InfoPeerGroupCall contactPeer = new InfoPeerGroupCall(contactHandle, contactName, false, false, null); + peersOnCall.add(contactPeer); + + if (adapter == null){ + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + }else{ + adapter.setNodes(peersOnCall); + adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + } + adapter.notifyDataSetChanged(); + + + recyclerView.setAdapter(adapter); + adapter.setNodes(peersOnCall); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + }else{ + log("*** individual call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); @@ -709,7 +734,7 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); peersOnCall.add(myPeer); if (adapter == null){ @@ -1259,7 +1284,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ - log("Session status have changed"); + log("************Session status have changed"); if(chat.isGroup()){ long userHandle = call.getPeerSessionStatusChange(); @@ -1268,8 +1293,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, "Monica Garcia",true, false, null); - log("userHandle added: "+userHandle); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),false, false, null); + log("**********userHandle added: "+userHandle); peersOnCall.add(0,userPeer); adapter.setNodes(peersOnCall); adapter.notifyDataSetChanged(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 6da3d7ed22f..afc1204b8f8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -138,7 +138,7 @@ public ViewHolderGroupCallGrid(View v) { outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); widthScreenPX = outMetrics.widthPixels; - heightScreenPX = outMetrics.heightPixels; + heightScreenPX = outMetrics.heightPixels -80; density = ((Activity) context).getResources().getDisplayMetrics().density; @@ -248,12 +248,56 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarLayout.setVisibility(View.VISIBLE); holderGrid.localFullScreenSurfaceView.setVisibility(View.GONE); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("me"); +// holderGrid.rLayout.setBackgroundColor(Color.BLUE); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + + if(numPeersOnCall == 1){ + log("1 (me) -> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + layoutParams.setMargins(0, 0, 0, 0); + }else if(numPeersOnCall == 2) { + log("2 (me)-> align parent top"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); + layoutParams.setMargins(0, 80, 0, 0); + }else{ + log("3 (me)-> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + layoutParams.setMargins(0, 0, 0, 0); + } + holderGrid.avatarLayout.setLayoutParams(layoutParams); setProfileMyAvatar(holder); }else{ log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); +// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + if(numPeersOnCall == 1){ + log("1 (contact)-> center in parent"); + + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + layoutParams.setMargins(0,0,0,0); + }else if(numPeersOnCall == 2){ + log("2 (contact)-> align parent bottom"); + + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT,0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + layoutParams.setMargins(0,0,0,80); + }else{ + log("3 (contact)-> center in parent"); + + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + layoutParams.setMargins(0,0,0,0); + } + holderGrid.avatarLayout.setLayoutParams(layoutParams); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 0844c5177b2..3778426500f 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -11,7 +11,6 @@ android:id="@+id/rl" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="center" android:background="@android:color/transparent"> @@ -20,15 +19,16 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" + android:layout_centerInParent="true" android:background="@android:color/transparent" /> Date: Wed, 1 Aug 2018 15:06:14 +0200 Subject: [PATCH 021/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 46 +++++++++++-------- .../chatAdapters/GroupCallAdapter.java | 19 ++------ 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index adc0a8bfac4..f46973ca338 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -143,6 +143,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; + boolean isIncoming = false; RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -649,8 +650,8 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - log("*****Incoming call"); - + log("Incoming call"); + isIncoming = true; ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); @@ -698,12 +699,10 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - log("*** individual call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); - myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; @@ -717,6 +716,7 @@ protected void onCreate(Bundle savedInstanceState) { }else{ log("Outgoing call"); + isIncoming = false; int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { @@ -766,10 +766,7 @@ protected void onCreate(Bundle savedInstanceState) { myAvatarLayout.setVisibility(View.VISIBLE); } - log("**** updateLocalVideo"); updateLocalVideoStatus(); - - } } } @@ -1228,14 +1225,15 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("onChatCallUpdate() "); if(call.getChatid()==chatId){ - log("onChatCallUpdate: "+call.getStatus()); this.callChat = call; if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){ + log("CHANGE_TYPE_STATUS"); + int callStatus = callChat.getStatus(); switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ - log("onChatCallUpdate() - CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS"); videoFAB.setOnClickListener(null); answerCallFAB.setOnTouchListener(null); @@ -1253,7 +1251,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION:{ - log("onChatCallUpdate() - CALL_STATUS_TERMINATING_USER_PARTICIPATION"); + log("CALL_STATUS_TERMINATING_USER_PARTICIPATION"); log("Terminating call of chat: "+chatId); if(chat.isGroup()){ @@ -1264,7 +1262,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ - log("onChatCallUpdate() - CALL_STATUS_DESTROYED"); log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); @@ -1284,7 +1281,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ - log("************Session status have changed"); + log("CHANGE_TYPE_SESSION_STATUS"); if(chat.isGroup()){ long userHandle = call.getPeerSessionStatusChange(); @@ -1293,15 +1290,24 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),false, false, null); - log("**********userHandle added: "+userHandle); - peersOnCall.add(0,userPeer); - adapter.setNodes(peersOnCall); - adapter.notifyDataSetChanged(); + if(isIncoming){ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), false, false, null); + int position = peersOnCall.size(); + peersOnCall.add(myPeer); + adapter.setNodes(peersOnCall); + adapter.notifyDataSetChanged(); + }else{ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),false, false, null); + peersOnCall.add(0,userPeer); + adapter.setNodes(peersOnCall); + adapter.notifyDataSetChanged(); + } } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); + updateLocalVideoStatus(); + updateLocalAudioStatus(); } else{ if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ @@ -1314,7 +1320,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ - log("Remote flags have changed"); + log("CHANGE_TYPE_REMOTE_AVFLAGS"); if(chat.isGroup()){ updateRemoteVideoStatus(call.getPeerSessionStatusChange()); updateRemoteAudioStatus(call.getPeerSessionStatusChange()); @@ -1327,7 +1333,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ - log("Local flags have changed"); + log("CHANGE_TYPE_LOCAL_AVFLAGS"); updateLocalAudioStatus(); updateLocalVideoStatus(); @@ -1337,7 +1343,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_RINGING_STATUS)){ } else{ - log("CHANGE_TYPE_RINGING_STATUS: "+call.getChanges()); + log("other: "+call.getChanges()); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index afc1204b8f8..de61481a849 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -207,18 +207,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("rLayout---> heightCameras("+heightCameras+")/heightScreenPX("+heightScreenPX+") "); log("rLayout---> widthScreenPX("+widthScreenPX+")"); - -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { -// holderGrid.rLayout.setBackgroundColor(Color.BLUE); -//// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.BLUE); -// }else{ -// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); -//// holderGrid.localFullScreenSurfaceView.setBackgroundColor(Color.YELLOW); -// } - -// holderGrid.localFullScreenSurfaceView.getHolder().setFixedSize(holderGrid.rLayout.getWidth(),holderGrid.rLayout.getHeight()); -// log("surfaceview---> height: "+holderGrid.rLayout.getHeight()+", width: "+holderGrid.rLayout.getWidth()); - } log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); @@ -248,12 +236,11 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarLayout.setVisibility(View.VISIBLE); holderGrid.localFullScreenSurfaceView.setVisibility(View.GONE); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("me"); // holderGrid.rLayout.setBackgroundColor(Color.BLUE); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); if(numPeersOnCall == 1){ log("1 (me) -> center in parent"); @@ -278,16 +265,20 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); // holderGrid.rLayout.setBackgroundColor(Color.YELLOW); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + if(numPeersOnCall == 1){ log("1 (contact)-> center in parent"); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + layoutParams.setMargins(0,0,0,0); }else if(numPeersOnCall == 2){ log("2 (contact)-> align parent bottom"); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT,0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutParams.setMargins(0,0,0,80); }else{ From fdecd8f515d07fe347d0b58d305427d3fa6535ce Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 2 Aug 2018 13:16:05 +0200 Subject: [PATCH 022/247] Feature#9775-Group calls UI --- .../chatAdapters/GroupCallAdapter.java | 7 +++-- .../res/layout/item_camera_group_call.xml | 30 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index de61481a849..49fac544726 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -238,8 +238,9 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("me"); -// holderGrid.rLayout.setBackgroundColor(Color.BLUE); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + holderGrid.rLayout.setBackgroundColor(Color.BLUE); + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); if(numPeersOnCall == 1){ @@ -263,7 +264,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ setProfileMyAvatar(holder); }else{ log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); -// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); + holderGrid.rLayout.setBackgroundColor(Color.YELLOW); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 3778426500f..f5216228cab 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,14 +4,16 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" android:layout_height="wrap_content"> + android:layout_centerInParent="true" + android:layout_centerHorizontal="true" + android:background="@android:color/holo_blue_light"> From 47e483820710bab0a0aa41508511ff8d825db53a Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 6 Aug 2018 08:39:08 +0200 Subject: [PATCH 023/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 22 +++++++------ .../chatAdapters/GroupCallAdapter.java | 31 +++++++++---------- .../res/layout/item_camera_group_call.xml | 19 +++++++----- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f46973ca338..0701ad44e59 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -135,7 +135,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque AppBarLayout appBarLayout; Toolbar tB; ActionBar aB; - + boolean isMe = true; boolean avatarRequested = false; ArrayList peersOnCall = new ArrayList<>(); @@ -673,11 +673,14 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); - long numParticipants = chat.getPeerCount()-1; - long contactHandle = chat.getPeerHandle(numParticipants); +// long numParticipants = chat.getPeerCount()-1; + long contactHandle = chat.getPeerHandle(0); String contactName = chat.getPeerFullnameByHandle(contactHandle); + for(int i=0;i heightCameras("+heightCameras+")/heightScreenPX("+heightScreenPX+") "); - log("rLayout---> widthScreenPX("+widthScreenPX+")"); - - } - log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ log("video on"); - holderGrid.localFullScreenSurfaceView.setVisibility(View.VISIBLE); + holderGrid.rLlocalFullScreenSurfaceView.setVisibility(View.VISIBLE); holder.avatarLayout.setVisibility(GONE); holderGrid.localFullScreenSurfaceView.setZOrderOnTop(false); @@ -233,8 +223,17 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ }else{ log("video off"); + if(numPeersOnCall < 4){ + //calculate height for 1 element: + int heightCameras = (int)(heightScreenPX/numPeersOnCall); + holderGrid.rLayout.getLayoutParams().height = heightCameras; + holderGrid.rLayout.getLayoutParams().width = (int) widthScreenPX; + + log("****height: "+heightCameras+"/"+heightScreenPX); + log("****width: "+widthScreenPX); + } holder.avatarLayout.setVisibility(View.VISIBLE); - holderGrid.localFullScreenSurfaceView.setVisibility(View.GONE); + holderGrid.rLlocalFullScreenSurfaceView.setVisibility(View.GONE); if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("me"); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index f5216228cab..46cbf311fca 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -5,26 +5,31 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:gravity="center_horizontal" - android:layout_height="wrap_content"> + android:layout_height="match_parent"> - + + + + Date: Mon, 6 Aug 2018 14:50:32 +0200 Subject: [PATCH 024/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 8 +- .../megachat/calls/ChatCallActivity.java | 87 +++++++-- .../megachat/calls/MegaSurfaceRenderer.java | 15 +- .../chatAdapters/GroupCallAdapter.java | 184 ++++++++++-------- .../main/res/layout/activity_calls_chat.xml | 1 + .../res/layout/item_camera_group_call.xml | 8 +- 6 files changed, 186 insertions(+), 117 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 55295bb21d2..d7ee7e661fb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -38,10 +38,12 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.width = width; this.height = height; - SurfaceHolder Sholder = holder.localFullScreenSurfaceView.getHolder(); + SurfaceHolder Sholder = holder.surfaceView.getHolder(); if (Sholder != null) { - int viewWidth = holder.localFullScreenSurfaceView.getWidth(); - int viewHeight = holder.localFullScreenSurfaceView.getHeight(); + int viewWidth = holder.surfaceView.getWidth(); + int viewHeight = holder.surfaceView.getHeight(); +// Log.d("**GroupCallListener*","***** viewWidth("+viewWidth+"), viewHeight("+viewHeight+") "); + if ((viewWidth != 0) && (viewHeight != 0)) { int holderWidth = viewWidth < width ? viewWidth : width; int holderHeight = holderWidth * viewHeight / viewWidth; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 0701ad44e59..e1370f7ccad 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -677,9 +677,8 @@ protected void onCreate(Bundle savedInstanceState) { long contactHandle = chat.getPeerHandle(0); String contactName = chat.getPeerFullnameByHandle(contactHandle); for(int i=0;i create myPeer"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); peersOnCall.add(myPeer); isMe = false; if (adapter == null){ @@ -748,7 +747,6 @@ protected void onCreate(Bundle savedInstanceState) { } adapter.notifyDataSetChanged(); - recyclerView.setAdapter(adapter); adapter.setNodes(peersOnCall); if (adapter.getItemCount() == 0){ @@ -769,7 +767,8 @@ protected void onCreate(Bundle savedInstanceState) { myAvatarLayout.setVisibility(View.VISIBLE); } - updateLocalVideoStatus(); +// updateLocalVideoStatus(); +// updateLocalAudioStatus(); } } } @@ -1090,6 +1089,8 @@ public void onDestroy(){ customHandler.removeCallbacksAndMessages(null); } + peersOnCall.clear(); + stopAudioSignals(); MegaApplication.activityPaused(); @@ -1301,7 +1302,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ adapter.notifyDataSetChanged(); isMe = false; }else{ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),true, false, null); + log("*** add contactPeer"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),userSession.hasVideo(), userSession.hasAudio(), null); peersOnCall.add(0,userPeer); adapter.setNodes(peersOnCall); adapter.notifyDataSetChanged(); @@ -1312,6 +1314,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateRemoteAudioStatus(userHandle); updateLocalVideoStatus(); updateLocalAudioStatus(); + } else{ if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ @@ -1321,6 +1324,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateRemoteAudioStatus(-1); updateLocalVideoStatus(); updateLocalAudioStatus(); + } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ @@ -1341,6 +1345,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ updateLocalAudioStatus(); updateLocalVideoStatus(); + + } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_RINGING_STATUS)){ log("CHANGE_TYPE_RINGING_STATUS"); @@ -1417,6 +1423,7 @@ public void stopAudioSignals(){ ringerTimer = null; } + int width = 0; int height = 0; Bitmap bitmap; @@ -1727,7 +1734,24 @@ public void updateLocalVideoStatus(){ if(chat.isGroup()){ log("is group"); if(callChat !=null){ + if (callChat.hasLocalVideo()) { + log("Video local connected"); + videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); + videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); + if(!peersOnCall.get(0).isVideoOn()){ + peersOnCall.get(0).setVideoOn(true); + adapter.notifyItemChanged(0); + } + }else { + log("Video local NOT connected"); + videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); + videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); + if(peersOnCall.get(0).isVideoOn()){ + peersOnCall.get(0).setVideoOn(false); + adapter.notifyItemChanged(0); + } + } } }else{ log("is individual"); @@ -1797,17 +1821,45 @@ public void updateLocalVideoStatus(){ public void updateLocalAudioStatus(){ log("updateLocalAudioStatus"); - if(callChat.hasLocalAudio()){ + if(chat.isGroup()) { + log("is group"); + if (callChat != null) { + if(callChat.hasLocalAudio()){ + log("Audio local connected"); + microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); + microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); + if(!peersOnCall.get(0).isAudioOn()) { + peersOnCall.get(0).setAudioOn(true); +// adapter.notifyItemChanged(0); - log("Audio local connected"); - microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); - microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); + } + }else{ + log("Audio local NOT connected"); + microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); + microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); + if(peersOnCall.get(0).isAudioOn()) { + peersOnCall.get(0).setAudioOn(false); +// adapter.notifyItemChanged(0); + } - }else{ - log("Audio local NOT connected"); - microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); - microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); + } + } + + }else { + log("is individual"); + if(callChat.hasLocalAudio()){ + + log("Audio local connected"); + microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); + microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); + + }else{ + log("Audio local NOT connected"); + microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); + microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); + } } + } public void updateRemoteVideoStatus(long userHandle){ @@ -1974,7 +2026,7 @@ public void onSensorChanged(SensorEvent event) { } public void remoteCameraClick(){ - + log("remoteCameraClick"); if(aB.isShowing()){ hideActionBar(); hideFABs(); @@ -1982,10 +2034,7 @@ public void remoteCameraClick(){ showActionBar(); showInitialFABConfiguration(); } - - } - @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 1c170501b34..537bd60e48b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -55,11 +55,11 @@ public class MegaSurfaceRenderer implements Callback { PorterDuffXfermode modesrcin; int surfaceWidth = 0; int surfaceHeight = 0; - SurfaceView surf; +// SurfaceView surf; public MegaSurfaceRenderer(SurfaceView view) { - this.surf = view; +// this.surf = view; surfaceHolder = view.getHolder(); if(surfaceHolder == null) return; @@ -103,13 +103,12 @@ private void adjustAspectRatio() { } } - public void surfaceChanged(SurfaceHolder holder, int format, - int in_width, int in_height) { + public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); - android.view.ViewGroup.LayoutParams lp = surf.getLayoutParams(); - lp.width = in_width; - lp.height = in_height; - surf.setLayoutParams(lp); +// android.view.ViewGroup.LayoutParams lp = surf.getLayoutParams(); +// lp.width = in_width; +// lp.height = in_height; +// surf.setLayoutParams(lp); changeDestRect(in_width, in_height); Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 6008168e8bb..f43d690d358 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -29,6 +29,7 @@ import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; import mega.privacy.android.app.components.RoundedImageView; +import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; import mega.privacy.android.app.lollipop.adapters.FileStorageLollipopAdapter; import mega.privacy.android.app.lollipop.listeners.GroupCallListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; @@ -52,7 +53,7 @@ import static mega.privacy.android.app.utils.Util.percScreenLogin; -public class GroupCallAdapter extends RecyclerView.Adapter { +public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener { public static final int ITEM_VIEW_TYPE_GRID = 1; @@ -78,6 +79,8 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, int adapterType) { @@ -105,17 +108,29 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayListSurfaceView VISIBLE, avatarLayout GONE"); + holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); + holderGrid.surfaceView.setZOrderOnTop(true); + SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holderGrid.localRenderer = new MegaSurfaceRenderer( holderGrid.localFullScreenSurfaceView); - - this.width=0; - this.height=0; - GroupCallListener listenerPeer = new GroupCallListener(context,holder); + holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); + holder.avatarLayout.setVisibility(GONE); + listenerPeer = new GroupCallListener(context, holder); peer.setListener(listenerPeer); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); - }else{ + } else { megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); } }else{ - log("video off"); - if(numPeersOnCall < 4){ + log("**** video on->SurfaceView GONE, avatarLayout VISIBLE"); + if(numPeersOnCall == 1 ){ + holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; + holderGrid.rlGeneral.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + + }else if (numPeersOnCall < 4) { + log("*** numPeersOnCall < 4 "); //calculate height for 1 element: - int heightCameras = (int)(heightScreenPX/numPeersOnCall); - holderGrid.rLayout.getLayoutParams().height = heightCameras; - holderGrid.rLayout.getLayoutParams().width = (int) widthScreenPX; + int heightCameras = (int) (heightScreenPX / numPeersOnCall); + holderGrid.rlGeneral.getLayoutParams().height = heightCameras; + holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; - log("****height: "+heightCameras+"/"+heightScreenPX); - log("****width: "+widthScreenPX); + log("****height: " + heightCameras + "/" + heightScreenPX); + log("****width: " + widthScreenPX); } - holder.avatarLayout.setVisibility(View.VISIBLE); - holderGrid.rLlocalFullScreenSurfaceView.setVisibility(View.GONE); + holderGrid.avatarLayout.setVisibility(View.VISIBLE); + holderGrid.surfaceViewLayout.setVisibility(View.GONE); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("me"); - holderGrid.rLayout.setBackgroundColor(Color.BLUE); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("me"); + holderGrid.rLayout.setBackgroundColor(Color.YELLOW); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - if(numPeersOnCall == 1){ - log("1 (me) -> center in parent"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); - layoutParams.setMargins(0, 0, 0, 0); - }else if(numPeersOnCall == 2) { - log("2 (me)-> align parent top"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); - layoutParams.setMargins(0, 80, 0, 0); - }else{ - log("3 (me)-> center in parent"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + if (numPeersOnCall == 1) { + log("***1 (me) -> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + layoutParams.setMargins(0, 0, 0, 0); + } else if (numPeersOnCall == 2) { + log("***2 (me)-> align parent top"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); + layoutParams.setMargins(0, 80, 0, 0); + } else { + log("***3 (me)-> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + layoutParams.setMargins(0, 0, 0, 0); + } + holderGrid.avatarLayout.setLayoutParams(layoutParams); + setProfileMyAvatar(holder); + + } else { + log("contact"); + holderGrid.rLayout.setBackgroundColor(Color.RED); + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); - layoutParams.setMargins(0, 0, 0, 0); - } - holderGrid.avatarLayout.setLayoutParams(layoutParams); - setProfileMyAvatar(holder); - }else{ - log("contact----------> handle("+peer.getHandle()+"), name("+peer.getName()+")"); - holderGrid.rLayout.setBackgroundColor(Color.YELLOW); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + if (numPeersOnCall == 1) { + log("***1 (contact)-> center in parent"); - if(numPeersOnCall == 1){ - log("1 (contact)-> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + layoutParams.setMargins(0, 0, 0, 0); + } else if (numPeersOnCall == 2) { + log("***2 (contact)-> align parent bottom"); - layoutParams.setMargins(0,0,0,0); - }else if(numPeersOnCall == 2){ - log("2 (contact)-> align parent bottom"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT,0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + layoutParams.setMargins(0, 0, 0, 80); + } else { + log("***3 (contact)-> center in parent"); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - layoutParams.setMargins(0,0,0,80); - }else{ - log("3 (contact)-> center in parent"); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); + layoutParams.setMargins(0, 0, 0, 0); + } + holderGrid.avatarLayout.setLayoutParams(layoutParams); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - layoutParams.setMargins(0,0,0,0); + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - holderGrid.avatarLayout.setLayoutParams(layoutParams); - - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - } - } public void setNodes(ArrayList peers) { @@ -583,4 +596,7 @@ public void setListFragment(RecyclerView recyclerViewFragment) { this.recyclerViewFragment = recyclerViewFragment; } + public void updateVideo(){ + + } } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 7e26826ab68..1699dd203d9 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -26,6 +26,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black"> + + android:background="@color/black"> @@ -41,6 +42,7 @@ android:layout_centerHorizontal="true" android:gravity="center" android:textAlignment="center" + android:visibility="gone" android:background="@android:color/transparent"> Date: Mon, 6 Aug 2018 15:20:15 +0200 Subject: [PATCH 025/247] Feature#9775-Group calls UI --- .../chatAdapters/GroupCallAdapter.java | 25 +++++++++++++++---- .../res/layout/item_camera_group_call.xml | 10 +++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index f43d690d358..f6261e8aebe 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -215,8 +215,22 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("*****Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ log("**** video on->SurfaceView VISIBLE, avatarLayout GONE"); + if(numPeersOnCall == 1 ){ + holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; + holderGrid.rlGeneral.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + + }else if (numPeersOnCall < 4) { + log("*** numPeersOnCall < 4 "); + //calculate height for 1 element: + int heightCameras = (int) (heightScreenPX / numPeersOnCall); + holderGrid.rlGeneral.getLayoutParams().height = heightCameras; +// holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; + holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; + + log("****height: " + heightCameras + "/" + heightScreenPX); + } holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); - holderGrid.surfaceView.setZOrderOnTop(true); + holderGrid.surfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); @@ -240,17 +254,18 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ //calculate height for 1 element: int heightCameras = (int) (heightScreenPX / numPeersOnCall); holderGrid.rlGeneral.getLayoutParams().height = heightCameras; - holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; +// holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; + holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; log("****height: " + heightCameras + "/" + heightScreenPX); - log("****width: " + widthScreenPX); +// log("****width: " + widthScreenPX); } holderGrid.avatarLayout.setVisibility(View.VISIBLE); holderGrid.surfaceViewLayout.setVisibility(View.GONE); if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("me"); - holderGrid.rLayout.setBackgroundColor(Color.YELLOW); +// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); @@ -276,7 +291,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } else { log("contact"); - holderGrid.rLayout.setBackgroundColor(Color.RED); +// holderGrid.rLayout.setBackgroundColor(Color.RED); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index c37a82384d7..ea31e14a4f3 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -5,6 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:gravity="center_horizontal" + android:layout_centerInParent="true" + android:background="@color/green_free_account" android:id="@+id/general" android:layout_height="match_parent"> @@ -12,18 +14,20 @@ android:id="@+id/rl" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/black"> + android:layout_centerHorizontal="true" + android:background="@android:color/transparent"> Date: Wed, 8 Aug 2018 11:10:46 +0200 Subject: [PATCH 026/247] Feature#9775-Group calls UI --- .../CustomizedGridCallRecyclerView.java | 19 +- .../megachat/calls/ChatCallActivity.java | 58 +++-- .../megachat/calls/MegaSurfaceRenderer.java | 17 ++ .../chatAdapters/GroupCallAdapter.java | 225 +++++++----------- .../java/org/webrtc/SurfaceViewRenderer.java | 1 - .../main/res/layout/activity_calls_chat.xml | 38 ++- .../res/layout/item_camera_group_call.xml | 168 ++++++++----- 7 files changed, 289 insertions(+), 237 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java index 3ff8a6e5988..291c9e91d92 100644 --- a/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java +++ b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java @@ -12,6 +12,7 @@ public class CustomizedGridCallRecyclerView extends RecyclerView { private CustomizedGridLayoutManager manager; public int columnWidth = -1; + public int rowHeight = -1; private boolean isWrapContent = false; private int widthTotal = 0; @@ -33,10 +34,14 @@ public CustomizedGridCallRecyclerView(Context context, AttributeSet attrs, int d private void init(Context context, AttributeSet attrs) { if (attrs != null) { int[] attrsArray = { - android.R.attr.columnWidth + android.R.attr.columnWidth, + android.R.attr.rowHeight + }; TypedArray array = context.obtainStyledAttributes(attrs, attrsArray); columnWidth = array.getDimensionPixelSize(0, -1); + rowHeight = array.getDimensionPixelSize(0, -1); + array.recycle(); } @@ -46,9 +51,12 @@ private void init(Context context, AttributeSet attrs) { @Override protected void onMeasure(int widthSpec, int heightSpec) { + log("onMeasure-> widthSpec: "+widthSpec+", heightSpec: "+heightSpec); super.onMeasure(widthSpec, heightSpec); if(!isWrapContent){ log("columnWidth :"+columnWidth); + log("rowHeight :"+rowHeight); + if (columnWidth > 0) { int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); log("spanCount: "+spanCount); @@ -58,6 +66,7 @@ protected void onMeasure(int widthSpec, int heightSpec) { ViewGroup.LayoutParams params = getLayoutParams(); log("columnWidth :"+columnWidth); + log("rowHeight :"+rowHeight); if (columnWidth > 0) { int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); @@ -94,6 +103,14 @@ public void setColumnWidth(int columnWidth) { this.columnWidth = columnWidth; } + public int getRowHeight() { + return rowHeight; + } + + public void setRowHeight(int rowHeight) { + this.rowHeight = rowHeight; + } + @Override public CustomizedGridLayoutManager getLayoutManager() { return manager; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index e1370f7ccad..ddee7dd4f2b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -34,6 +34,8 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.Display; @@ -57,6 +59,11 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import com.google.android.flexbox.AlignItems; +import com.google.android.flexbox.FlexWrap; +import com.google.android.flexbox.FlexboxLayoutManager; +import com.google.android.flexbox.JustifyContent; + import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -542,10 +549,14 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); - recyclerView.setColumnWidth((int) widthScreenPX); - CustomizedGridLayoutManager gridLayoutManager = (CustomizedGridLayoutManager) recyclerView.getLayoutManager(); + +// recyclerView.setColumnWidth((int) widthScreenPX); +// recyclerView.setRowHeight((int) heightScreenPX); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + + //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); @@ -688,11 +699,12 @@ protected void onCreate(Bundle savedInstanceState) { adapter.setNodes(peersOnCall); adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); } - adapter.notifyDataSetChanged(); +// adapter.notifyDataSetChanged(); - recyclerView.setAdapter(adapter); - adapter.setNodes(peersOnCall); +// recyclerView.setAdapter(adapter); +// adapter.setNodes(peersOnCall); +// setLayoutManager(); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ @@ -735,20 +747,19 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - log("** Outgoing call -> create myPeer"); + log("Outgoing call -> create myPeer"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); peersOnCall.add(myPeer); isMe = false; if (adapter == null){ adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); + }else{ adapter.setNodes(peersOnCall); adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); } - adapter.notifyDataSetChanged(); - recyclerView.setAdapter(adapter); - adapter.setNodes(peersOnCall); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ @@ -1066,6 +1077,7 @@ protected void onResume() { // this.width=0; // this.height=0; super.onResume(); +// adapter.notifyDataSetChanged(); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); @@ -1090,7 +1102,6 @@ public void onDestroy(){ } peersOnCall.clear(); - stopAudioSignals(); MegaApplication.activityPaused(); @@ -1296,17 +1307,19 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateSubTitle(); if(isIncoming && isMe){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); - int position = peersOnCall.size(); peersOnCall.add(myPeer); adapter.setNodes(peersOnCall); - adapter.notifyDataSetChanged(); isMe = false; }else{ - log("*** add contactPeer"); + log("add contactPeer -> "+chat.getPeerFullnameByHandle(userHandle)); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),userSession.hasVideo(), userSession.hasAudio(), null); peersOnCall.add(0,userPeer); adapter.setNodes(peersOnCall); - adapter.notifyDataSetChanged(); + adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); } } @@ -1738,19 +1751,19 @@ public void updateLocalVideoStatus(){ log("Video local connected"); videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); - if(!peersOnCall.get(0).isVideoOn()){ - peersOnCall.get(0).setVideoOn(true); - adapter.notifyItemChanged(0); - } +// if(!peersOnCall.get(0).isVideoOn()){ +// peersOnCall.get(0).setVideoOn(true); +// adapter.notifyItemChanged(0); +// } }else { log("Video local NOT connected"); videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); - if(peersOnCall.get(0).isVideoOn()){ - peersOnCall.get(0).setVideoOn(false); - adapter.notifyItemChanged(0); - } +// if(peersOnCall.get(0).isVideoOn()){ +// peersOnCall.get(0).setVideoOn(false); +// adapter.notifyItemChanged(0); +// } } } }else{ @@ -2144,4 +2157,5 @@ public void animationAlphaArrows(final ImageView arrow){ alphaAnimArrows.setRepeatCount(Animation.INFINITE); arrow.startAnimation(alphaAnimArrows); } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 537bd60e48b..77921ff7214 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -28,6 +28,7 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; +import android.util.Log; import android.util.TypedValue; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -81,9 +82,13 @@ private void changeDestRect(int dstWidth, int dstHeight) { } private void adjustAspectRatio() { + Log.d("***********","******** adjustAspectRatio:"); + if (bitmap != null && dstRect.height() != 0) { float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); float dstaspectratio = (float) dstRect.width() / dstRect.height(); + Log.d("***********","******** srcaspectratio:"+srcaspectratio+", dstaspectratio: "+dstaspectratio); + if (srcaspectratio != 0 && dstaspectratio != 0) { if (srcaspectratio > dstaspectratio) { @@ -104,6 +109,7 @@ private void adjustAspectRatio() { } public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { + Log.d("***********","******** surfaceChanged: in_width("+in_width+"), in_height("+in_height+")"); Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); // android.view.ViewGroup.LayoutParams lp = surf.getLayoutParams(); // lp.width = in_width; @@ -111,6 +117,17 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i // surf.setLayoutParams(lp); changeDestRect(in_width, in_height); + Log.d("******", "****ViESurfaceRender::surfaceChanged" + + " in_width:" + in_width + " in_height:" + in_height + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + " in_width:" + in_width + " in_height:" + in_height + " srcRect.left:" + srcRect.left + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index f6261e8aebe..d2002a34c66 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -9,6 +9,7 @@ import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Point; +import android.graphics.Rect; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; @@ -18,9 +19,12 @@ import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import com.google.android.flexbox.FlexboxLayoutManager; + import java.io.File; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -74,6 +78,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter Get heightMeasure("+heightMeasure+"), widthMeasure("+widthMeasure+")"); + + if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - holderGrid.rLayout = (RelativeLayout) v.findViewById(R.id.rl); - holderGrid.rLayout.setOnClickListener(this); + holderGrid.rlGeneral.setOnClickListener(this); // holderGrid.rlSurface = (RelativeLayout) v.findViewById(R.id.rl_surfacevies); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); @@ -202,8 +210,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ - - log("****onBindViewHolderGrid()"); + log("onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -212,23 +219,17 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ int numPeersOnCall = getItemCount(); - log("*****Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); + log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); if(peer.isVideoOn()){ - log("**** video on->SurfaceView VISIBLE, avatarLayout GONE"); - if(numPeersOnCall == 1 ){ - holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; - holderGrid.rlGeneral.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - - }else if (numPeersOnCall < 4) { - log("*** numPeersOnCall < 4 "); - //calculate height for 1 element: - int heightCameras = (int) (heightScreenPX / numPeersOnCall); - holderGrid.rlGeneral.getLayoutParams().height = heightCameras; -// holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; - holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; - - log("****height: " + heightCameras + "/" + heightScreenPX); - } + log("video on->SurfaceView VISIBLE, avatarLayout GONE"); + holderGrid.rlGeneral.getLayoutParams().height = heightMeasure/numPeersOnCall; + holderGrid.rlGeneral.getLayoutParams().width= widthMeasure; + holderGrid.surfaceView.getLayoutParams().height = heightMeasure/numPeersOnCall; + holderGrid.surfaceView.getLayoutParams().width= widthMeasure/numPeersOnCall; + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.surfaceView.getLayoutParams(); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + + holderGrid.surfaceView.setLayoutParams(layoutParams); holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); holderGrid.surfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); @@ -244,131 +245,100 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } }else{ - log("**** video on->SurfaceView GONE, avatarLayout VISIBLE"); - if(numPeersOnCall == 1 ){ - holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; - holderGrid.rlGeneral.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - - }else if (numPeersOnCall < 4) { - log("*** numPeersOnCall < 4 "); - //calculate height for 1 element: - int heightCameras = (int) (heightScreenPX / numPeersOnCall); - holderGrid.rlGeneral.getLayoutParams().height = heightCameras; -// holderGrid.rlGeneral.getLayoutParams().width = (int) widthScreenPX; - holderGrid.rlGeneral.getLayoutParams().width= RelativeLayout.LayoutParams.MATCH_PARENT; - - log("****height: " + heightCameras + "/" + heightScreenPX); -// log("****width: " + widthScreenPX); - } - holderGrid.avatarLayout.setVisibility(View.VISIBLE); - holderGrid.surfaceViewLayout.setVisibility(View.GONE); + log("onBindViewHolderGrid() -> video off: position: "+position+", name("+peer.getName()+")"); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("me"); -// holderGrid.rLayout.setBackgroundColor(Color.YELLOW); - - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - - if (numPeersOnCall == 1) { - log("***1 (me) -> center in parent"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); - layoutParams.setMargins(0, 0, 0, 0); - } else if (numPeersOnCall == 2) { - log("***2 (me)-> align parent top"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); - layoutParams.setMargins(0, 80, 0, 0); - } else { - log("***3 (me)-> center in parent"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); - layoutParams.setMargins(0, 0, 0, 0); - } - holderGrid.avatarLayout.setLayoutParams(layoutParams); - setProfileMyAvatar(holder); + holderGrid.avatarLayout.setVisibility(View.VISIBLE); + holderGrid.surfaceViewLayout.setVisibility(View.GONE); - } else { - log("contact"); -// holderGrid.rLayout.setBackgroundColor(Color.RED); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("me"); + holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); + }else{ + holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); + } - if (numPeersOnCall == 1) { - log("***1 (contact)-> center in parent"); + if (numPeersOnCall < 4) { + if(numPeersOnCall == 3){ + holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure/numPeersOnCall); + log("onBindViewHolderGrid() new height: "+((heightMeasure/numPeersOnCall))); + holderGrid.rlGeneral.setBackgroundColor(Color.MAGENTA); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - layoutParams.setMargins(0, 0, 0, 0); - } else if (numPeersOnCall == 2) { - log("***2 (contact)-> align parent bottom"); + }else{ + holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure/numPeersOnCall); + log("onBindViewHolderGrid() new height: "+(heightMeasure/numPeersOnCall)); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); + } + holderGrid.rlGeneral.getLayoutParams().width= widthMeasure; + log("onBindViewHolderGrid() new width: "+widthMeasure); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - layoutParams.setMargins(0, 0, 0, 80); - } else { - log("***3 (contact)-> center in parent"); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); - layoutParams.setMargins(0, 0, 0, 0); - } - holderGrid.avatarLayout.setLayoutParams(layoutParams); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("me"); + holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); +// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); +// +// if (numPeersOnCall == 2) { +// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); +// layoutParams.setMargins(0, 80, 0, 0); +// } else { +// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); +// layoutParams.setMargins(0, 0, 0, 0); +// } +// holderGrid.avatarLayout.setLayoutParams(layoutParams); + setProfileMyAvatar(holder); + + } else { + log("contact"); + holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); + +// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); +// +// if (numPeersOnCall == 2) { +// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); +// layoutParams.setMargins(0, 0, 0, 80); +// } else { +// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); +// layoutParams.setMargins(0, 0, 0, 0); +// } +// holderGrid.avatarLayout.setLayoutParams(layoutParams); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } } + } } public void setNodes(ArrayList peers) { - log("setNodes() -> peers: "+peers.size()); + log("setNodes() -> peers: "+peers.size()+" && notifyDataSetChanged()"); this.peers = peers; - + notifyDataSetChanged(); } - @Override public int getItemCount() { if (peers != null){ log("getItemCount() -> "+peers.size()); - return peers.size(); }else{ log("getItemCount() -> 0"); - return 0; } - } -// public void modifyScreenPosition(){ -// -// for(int i=0; i< getItemCount();i++){ -// getItem(i) -// } -// int numPeersOnCall = getItemCount(); -// -// if(numPeersOnCall < 4){ -// log("peers: : "+numPeersOnCall); -// holderGrid.rLayout.getLayoutParams().width = RelativeLayout.LayoutParams.MATCH_PARENT; -// //calculate height for 1 element: -// int heightCameras = (int)(heightScreenPX/numPeersOnCall); -// holderGrid.rLayout.getLayoutParams().height = heightCameras; -// log("heightScreenPX: "+heightScreenPX+", heightCameras: "+heightCameras); -// } -// } - public Object getItem(int position) { log("getItem()"); if (peers != null){ return peers.get(position); } - return null; } @@ -385,34 +355,6 @@ public InfoPeerGroupCall getNodeAt(int position) { return null; } -// @Override -// public View getView(int position, View convertView, ViewGroup parent) { -// Viewholder holder; -// if (convertView == null) { -// -// holder = new Viewholder(); -// LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); -// convertView = inflater.inflate(R.layout.grid_list_item, null); -// -// holder.textView = (TextView) convertView.findViewById(R.id.txtTitle); -// holder.imageView = (ImageView)convertView.findViewById(R.id.imgGrid); -// -// -// convertView.setTag(holder); -// -// } else { -// -// holder = (Viewholder) convertView.getTag(); -// } -// -// holder.textView.setText(web[position]); -// holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); -// Glide.with(mContext).load(Imageid[position]).into(holder.imageView); -// -// return convertView; -// } - - //My AVATAR public void setProfileMyAvatar(ViewHolderGroupCall holder) { log("setProfileMyAvatar()"); @@ -611,7 +553,4 @@ public void setListFragment(RecyclerView recyclerViewFragment) { this.recyclerViewFragment = recyclerViewFragment; } - public void updateVideo(){ - - } } diff --git a/app/src/main/java/org/webrtc/SurfaceViewRenderer.java b/app/src/main/java/org/webrtc/SurfaceViewRenderer.java index 4d1f4698393..54c7f27660a 100644 --- a/app/src/main/java/org/webrtc/SurfaceViewRenderer.java +++ b/app/src/main/java/org/webrtc/SurfaceViewRenderer.java @@ -284,7 +284,6 @@ public void run() { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { ThreadUtils.checkIsOnMainThread(); - logD("******surfaceChanged: format: " + format + " size: " + width + "x" + height); } private String getResourceName() { diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 1699dd203d9..8ca2e4a9776 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -20,21 +20,35 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - + - + android:background="@color/black"> + + + + + + + + + + + + + + + + - + android:id="@+id/general"> - - - - + + + + + + - + android:gravity="center" + android:textAlignment="center" + android:visibility="gone" + android:background="@android:color/transparent"> + + + - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From af69d8d9fcf31cbdbeb52a8bc1573463421f307c Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 13 Aug 2018 08:44:18 +0200 Subject: [PATCH 027/247] Feature#9775-Group calls UI --- .../CustomizedGridCallRecyclerView.java | 18 -- .../lollipop/listeners/GroupCallListener.java | 8 +- .../megachat/calls/ChatCallActivity.java | 173 ++++++++----- .../megachat/calls/MegaSurfaceRenderer.java | 107 +++++--- .../chatAdapters/GroupCallAdapter.java | 229 ++++++++++++------ .../res/layout/item_camera_group_call.xml | 16 +- 6 files changed, 344 insertions(+), 207 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java index 291c9e91d92..88553caee46 100644 --- a/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java +++ b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java @@ -12,7 +12,6 @@ public class CustomizedGridCallRecyclerView extends RecyclerView { private CustomizedGridLayoutManager manager; public int columnWidth = -1; - public int rowHeight = -1; private boolean isWrapContent = false; private int widthTotal = 0; @@ -35,13 +34,9 @@ private void init(Context context, AttributeSet attrs) { if (attrs != null) { int[] attrsArray = { android.R.attr.columnWidth, - android.R.attr.rowHeight - }; TypedArray array = context.obtainStyledAttributes(attrs, attrsArray); columnWidth = array.getDimensionPixelSize(0, -1); - rowHeight = array.getDimensionPixelSize(0, -1); - array.recycle(); } @@ -55,8 +50,6 @@ protected void onMeasure(int widthSpec, int heightSpec) { super.onMeasure(widthSpec, heightSpec); if(!isWrapContent){ log("columnWidth :"+columnWidth); - log("rowHeight :"+rowHeight); - if (columnWidth > 0) { int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); log("spanCount: "+spanCount); @@ -66,8 +59,6 @@ protected void onMeasure(int widthSpec, int heightSpec) { ViewGroup.LayoutParams params = getLayoutParams(); log("columnWidth :"+columnWidth); - log("rowHeight :"+rowHeight); - if (columnWidth > 0) { int spanCount = Math.max(1, getMeasuredWidth() / columnWidth); log("spanCount: "+spanCount); @@ -98,19 +89,10 @@ public int findFirstVisibleItemPosition() { public int getColumnWidth() { return columnWidth; } - public void setColumnWidth(int columnWidth) { this.columnWidth = columnWidth; } - public int getRowHeight() { - return rowHeight; - } - - public void setRowHeight(int rowHeight) { - this.rowHeight = rowHeight; - } - @Override public CustomizedGridLayoutManager getLayoutManager() { return manager; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index d7ee7e661fb..02738acd8f2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -20,14 +20,11 @@ public class GroupCallListener implements MegaChatVideoListenerInterface { public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall holder) { this.context = context; this.holder = holder; + this.width = 0; + this.height = 0; } - public GroupCallListener(Context context) { - this.context = context; - } - - @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { if((width == 0) || (height == 0)){ @@ -42,7 +39,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei if (Sholder != null) { int viewWidth = holder.surfaceView.getWidth(); int viewHeight = holder.surfaceView.getHeight(); -// Log.d("**GroupCallListener*","***** viewWidth("+viewWidth+"), viewHeight("+viewHeight+") "); if ((viewWidth != 0) && (viewHeight != 0)) { int holderWidth = viewWidth < width ? viewWidth : width; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index ddee7dd4f2b..0b6e8b57766 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -142,7 +142,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque AppBarLayout appBarLayout; Toolbar tB; ActionBar aB; - boolean isMe = true; +// boolean isMe = true; boolean avatarRequested = false; ArrayList peersOnCall = new ArrayList<>(); @@ -150,7 +150,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; - boolean isIncoming = false; +// boolean isIncoming = false; RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -324,8 +324,6 @@ public void updateNumberOfPeers(){ if(chat.isGroup()){ int totalParticipants = callChat.getNumParticipants(); //redesign of screens: - - } } @@ -549,14 +547,9 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); - -// recyclerView.setColumnWidth((int) widthScreenPX); -// recyclerView.setRowHeight((int) heightScreenPX); - + recyclerView.setColumnWidth((int) widthScreenPX); recyclerView.setItemAnimator(new DefaultItemAnimator()); - - //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); @@ -662,7 +655,7 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); - isIncoming = true; +// isIncoming = true; ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); @@ -680,38 +673,30 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ + log("1- Incoming call"); + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); -// long numParticipants = chat.getPeerCount()-1; - long contactHandle = chat.getPeerHandle(0); - String contactName = chat.getPeerFullnameByHandle(contactHandle); + //Get all the peers, add them to peersOnCall array, show the interface of all those in the video call (avatar only) for(int i=0;i create myPeer"); + + log("create my Peer: "+megaChatApi.getMyFullname()); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); peersOnCall.add(myPeer); - isMe = false; - if (adapter == null){ - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - recyclerView.setAdapter(adapter); - - }else{ - adapter.setNodes(peersOnCall); - adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - } +// isMe = false; + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -1305,23 +1289,53 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log(userHandle+": joined the group call - create fragment!"); updateSubTitle(); - if(isIncoming && isMe){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), true, false, null); + if(userHandle==megaChatApi.getMyUserHandle()){ + //I joined the group call + log("I joined the group call"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); peersOnCall.add(myPeer); - adapter.setNodes(peersOnCall); - isMe = false; + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); + //Update the peers that were in the call whether or not they have video and audio }else{ - log("add contactPeer -> "+chat.getPeerFullnameByHandle(userHandle)); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle),userSession.hasVideo(), userSession.hasAudio(), null); + //contact joined the group call + log("2-"+chat.getPeerFullnameByHandle(userHandle)+" joined the group call"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null); peersOnCall.add(0,userPeer); - adapter.setNodes(peersOnCall); - adapter.setAdapterType(GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); } +// if(isIncoming && isMe){ +// //Ver por el userHandle si es el mio o no! +// +// log("Me joined the call -> setNodes()"); +// //adapter.setNodes(peersOnCall); +// +// +// isMe = false; +// }else{ +// log("add contactPeer -> "+chat.getPeerFullnameByHandle(userHandle)+", hasVideo: "+userSession.hasVideo()); +// InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null); +// peersOnCall.add(0,userPeer); +// log("contact joined to the call -> setNodes()"); +// +//// adapter.setNodes(peersOnCall); +// +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); +// recyclerView.setAdapter(adapter); +// +//// if(peersOnCall.size()>3){ +//// log("setColumnWidth-> widthScreenPX/2"); +//// recyclerView.setColumnWidth((int) widthScreenPX/2); +//// } +// +// } + } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1751,19 +1765,26 @@ public void updateLocalVideoStatus(){ log("Video local connected"); videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); -// if(!peersOnCall.get(0).isVideoOn()){ -// peersOnCall.get(0).setVideoOn(true); -// adapter.notifyItemChanged(0); -// } - + if (peersOnCall != null && !peersOnCall.isEmpty()) { + InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); + if(!item.isVideoOn()){ + log("update LOCAL video: "+peersOnCall.get((peersOnCall.size()-1)).getName()+" camera TRUE"); + item.setVideoOn(true); + adapter.notifyItemChanged(peersOnCall.size()-1); + } + } }else { log("Video local NOT connected"); videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); -// if(peersOnCall.get(0).isVideoOn()){ -// peersOnCall.get(0).setVideoOn(false); -// adapter.notifyItemChanged(0); -// } + if (peersOnCall != null && !peersOnCall.isEmpty()) { + InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); + if(item.isVideoOn()){ + log("update LOCAL video: "+peersOnCall.get((peersOnCall.size()-1)).getName()+" camera FALSE"); + item.setVideoOn(false); + adapter.notifyItemChanged(peersOnCall.size()-1); + } + } } } }else{ @@ -1841,19 +1862,19 @@ public void updateLocalAudioStatus(){ log("Audio local connected"); microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); - if(!peersOnCall.get(0).isAudioOn()) { - peersOnCall.get(0).setAudioOn(true); +// if(!peersOnCall.get(0).isAudioOn()) { +// peersOnCall.get(0).setAudioOn(true); // adapter.notifyItemChanged(0); - } +// } }else{ log("Audio local NOT connected"); microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); - if(peersOnCall.get(0).isAudioOn()) { - peersOnCall.get(0).setAudioOn(false); +// if(peersOnCall.get(0).isAudioOn()) { +// peersOnCall.get(0).setAudioOn(false); // adapter.notifyItemChanged(0); - } +// } } } @@ -1881,8 +1902,32 @@ public void updateRemoteVideoStatus(long userHandle){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null && userSession.hasVideo()) { log(userHandle+": Video remote connected"); + if (peersOnCall != null && !peersOnCall.isEmpty()) { + for(int i=0;i dstaspectratio) { +// Log.d("####","#### A -> newHeight "); + float newHeight = dstRect.width() / srcaspectratio; +// Log.d("####","#### A -> newHeight("+newHeight+")= dstRect.width("+dstRect.width()+") / srcaspectratio("+srcaspectratio+")"); + float decrease = dstRect.height() - newHeight; +// Log.d("####","#### A -> decrease("+decrease+")= dstRect.height("+dstRect.height()+") - newHeight("+newHeight+")"); + dstRect.top += decrease / 2; dstRect.bottom -= decrease / 2; +// Log.d("####","#### A -> top("+dstRect.top+"), bottom("+dstRect.bottom+"), left("+dstRect.left+"), right("+dstRect.right+")"); dstRectf = new RectF(dstRect); + } else { + + float newWidth = dstRect.height() * srcaspectratio; +// Log.d("####","#### B -> newWidth("+newWidth+")= dstRect.height("+dstRect.height()+") * srcaspectratio ("+srcaspectratio+")"); + float decrease = dstRect.width() - newWidth; +// Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); + +// dstRect.left = -40; +// dstRect.right = -40 + ((int)newWidth); + dstRect.left += decrease / 2; dstRect.right -= decrease / 2; + +// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); } } } } - public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - Log.d("***********","******** surfaceChanged: in_width("+in_width+"), in_height("+in_height+")"); - Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); -// android.view.ViewGroup.LayoutParams lp = surf.getLayoutParams(); -// lp.width = in_width; -// lp.height = in_height; -// surf.setLayoutParams(lp); - changeDestRect(in_width, in_height); +// private void adjustAspectRatio() { +// if (bitmap != null && dstRect.height() != 0) { +// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); +// float dstaspectratio = (float) dstRect.width() / dstRect.height(); +// +// if (srcaspectratio != 0 && dstaspectratio != 0) { +// if (srcaspectratio > dstaspectratio) { +// float newHeight = dstRect.width() / srcaspectratio; +// float decrease = dstRect.height() - newHeight; +// dstRect.top += decrease / 2; +// dstRect.bottom -= decrease / 2; +// dstRectf = new RectF(dstRect); +// } else { +// float newWidth = dstRect.height() * srcaspectratio; +// float decrease = dstRect.width() - newWidth; +// dstRect.left += decrease / 2; +// dstRect.right -= decrease / 2; +// dstRectf = new RectF(dstRect); +// } +// } +// } +// } - Log.d("******", "****ViESurfaceRender::surfaceChanged" + - " in_width:" + in_width + " in_height:" + in_height + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + - " in_width:" + in_width + " in_height:" + in_height + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - } public void surfaceCreated(SurfaceHolder holder) { + Log.d("####","#### surfaceCreated(): "); + Canvas canvas = surfaceHolder.lockCanvas(); if(canvas != null) { Rect dst = surfaceHolder.getSurfaceFrame(); @@ -164,13 +181,35 @@ public void surfaceCreated(SurfaceHolder holder) { } } + public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { + Log.d("####","#### surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); + changeDestRect(in_width, in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + + " in_width:" + in_width + " in_height:" + in_height + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + } + public void surfaceDestroyed(SurfaceHolder holder) { + Log.d("####","#### surfaceDestroyed(): "); + Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; } public Bitmap CreateBitmap(int width, int height) { + Log.d("####","#### CreateBitmap(): width = "+width+", height = "+height); + Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); if (bitmap == null) { try { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index d2002a34c66..2962a095f6a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -14,6 +14,7 @@ import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.view.Display; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -23,8 +24,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; -import com.google.android.flexbox.FlexboxLayoutManager; - import java.io.File; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -32,6 +31,7 @@ import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; +import mega.privacy.android.app.components.CustomizedGridRecyclerView; import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; import mega.privacy.android.app.lollipop.adapters.FileStorageLollipopAdapter; @@ -78,18 +78,18 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, int adapterType) { - log("GroupCallAdapter()"); + log("GroupCallAdapter( peers: "+peers.size()+")"); this.context = context; this.recyclerViewFragment = recyclerView; @@ -111,6 +111,20 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList Get heightMeasure("+heightMeasure+"), widthMeasure("+widthMeasure+")"); +// log("onCreateViewHolder-> maxScreenHeight("+maxScreenHeight+"), maxScreenWidth("+maxScreenWidth+")"); if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ + +// View itemView = mLayoutInflater.inflate(R.layout.view_item, parent, false); +// int height = parent.getMeasuredHeight() / 4; +// itemView.setMinimumHeight(height); +// return new ItemViewHolder(itemView); + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); + int numPeersOnCall = getItemCount(); + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); + lp.height =parent.getMeasuredHeight() / numPeersOnCall; + lp.width = parent.getMeasuredWidth(); + log("onCreateViewHolder() -> height: "+maxScreenHeight+"/"+numPeersOnCall+" = "+height); + log("onCreateViewHolder() -> width: "+maxScreenWidth); + + v.setLayoutParams(lp); + holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - holderGrid.rlGeneral.setOnClickListener(this); -// holderGrid.rlSurface = (RelativeLayout) v.findViewById(R.id.rl_surfacevies); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.surfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); + holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; + holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; + holderGrid.surfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); + localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); v.setTag(holderGrid); return holderGrid; @@ -218,65 +250,97 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } int numPeersOnCall = getItemCount(); - - log("Peer in position: "+position+", handle("+peer.getHandle()+"), name("+peer.getName()+"), videoOn("+peer.isVideoOn()+"), audioOn("+peer.isAudioOn()+")"); +// if((listenerPeer==null)&&(peer.getListener()==null)){ +// listenerPeer = new GroupCallListener(context, holder); +// peer.setListener(listenerPeer); +// } +// if(numPeersOnCall<=3){ +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; +// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; +// }else{ +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/2; +// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; +// } + + +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; + +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight; +// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; if(peer.isVideoOn()){ - log("video on->SurfaceView VISIBLE, avatarLayout GONE"); - holderGrid.rlGeneral.getLayoutParams().height = heightMeasure/numPeersOnCall; - holderGrid.rlGeneral.getLayoutParams().width= widthMeasure; - holderGrid.surfaceView.getLayoutParams().height = heightMeasure/numPeersOnCall; - holderGrid.surfaceView.getLayoutParams().width= widthMeasure/numPeersOnCall; - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.surfaceView.getLayoutParams(); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - - holderGrid.surfaceView.setLayoutParams(layoutParams); - holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); - holderGrid.surfaceView.setZOrderMediaOverlay(true); - SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); - localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); holder.avatarLayout.setVisibility(GONE); - listenerPeer = new GroupCallListener(context, holder); - peer.setListener(listenerPeer); + holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); +// holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight; +// holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth/numPeersOnCall; + +// if(numPeersOnCall<=3){ +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; +// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth/numPeersOnCall; +// }else{ +// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/2; +// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth/2; +// } + +// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.surfaceView.getLayoutParams(); +// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); +// holderGrid.surfaceView.setLayoutParams(layoutParams); + + + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); - } else { - megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); +// if(peer.getListener()==null){ + log("Video ON -> create listener Peer (YO) "); + GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); + peer.setListener(listenerPeer); + megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); +// } +// megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); + }else{ +// if(peer.getListener()==null){ + log(" Video ON -> create listener Peer ("+peer.getName()+") "); + GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); + peer.setListener(listenerPeer); + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); +// } +// megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); } }else{ - log("onBindViewHolderGrid() -> video off: position: "+position+", name("+peer.getName()+")"); - holderGrid.avatarLayout.setVisibility(View.VISIBLE); holderGrid.surfaceViewLayout.setVisibility(View.GONE); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("me"); + +// if(peer.getListener()!=null){ +// log(" Video OFF -> remove listener Peer (YO) "); +// megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); +// peer.setListener(null); +// } holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); + setProfileMyAvatar(holder); + }else{ +// if(peer.getListener()!=null){ +// log(" Video OFF -> remove listener Peer ("+peer.getName()+") "); +// megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); +// peer.setListener(null); +// } holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); - + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - if (numPeersOnCall < 4) { - if(numPeersOnCall == 3){ - holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure/numPeersOnCall); - log("onBindViewHolderGrid() new height: "+((heightMeasure/numPeersOnCall))); - holderGrid.rlGeneral.setBackgroundColor(Color.MAGENTA); - - - }else{ - holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure/numPeersOnCall); - log("onBindViewHolderGrid() new height: "+(heightMeasure/numPeersOnCall)); - - } - holderGrid.rlGeneral.getLayoutParams().width= widthMeasure; - log("onBindViewHolderGrid() new width: "+widthMeasure); - - - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("me"); - holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); +// if (numPeersOnCall < 4) { +// holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure / numPeersOnCall); +// log("onBindViewHolderGrid() new height: " + (heightMeasure / numPeersOnCall)); +// holderGrid.rlGeneral.getLayoutParams().width = widthMeasure; +// log("onBindViewHolderGrid() new width: " + widthMeasure); +// } + +// if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { +// log("me"); +// holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); +// setProfileMyAvatar(holder); // RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); // layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); // @@ -290,12 +354,12 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ // layoutParams.setMargins(0, 0, 0, 0); // } // holderGrid.avatarLayout.setLayoutParams(layoutParams); - setProfileMyAvatar(holder); - } else { - log("contact"); - holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); +// } else { +// log("contact"); +// holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); +// setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); // RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); // layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); // @@ -309,18 +373,27 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ // layoutParams.setMargins(0, 0, 0, 0); // } // holderGrid.avatarLayout.setLayoutParams(layoutParams); +// } - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); - } - } } } - public void setNodes(ArrayList peers) { - log("setNodes() -> peers: "+peers.size()+" && notifyDataSetChanged()"); - this.peers = peers; - notifyDataSetChanged(); - } +// public void setNodes(ArrayList peers) { +// log("setNodes() -> peers: "+peers.size()+" && notifyDataSetChanged()"); +// this.peers = peers; +// display = ((Activity) context).getWindowManager().getDefaultDisplay(); +// outMetrics = new DisplayMetrics(); +// display.getMetrics(outMetrics); +// widthScreenPX = outMetrics.widthPixels; +// heightScreenPX = outMetrics.heightPixels; +// maxScreenWidth = (int) widthScreenPX; +// maxScreenHeight = ((int) heightScreenPX) - 50; +// if (peers.size() < 4) { +// heightReal = maxScreenHeight/peers.size(); +// widthReal = maxScreenWidth/peers.size(); +// } +// notifyDataSetChanged(); +// } @Override public int getItemCount() { @@ -426,7 +499,7 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); holder.avatarImage.setImageBitmap(defaultAvatar); holder.avatarInitialLetter.setText(myFirstLetter); - holder.avatarInitialLetter.setTextSize(40); +// holder.avatarInitialLetter.setTextSize(40); holder.avatarInitialLetter.setTextColor(Color.WHITE); holder.avatarInitialLetter.setVisibility(View.VISIBLE); @@ -532,7 +605,7 @@ public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGro String contactFirstLetter = fullName.charAt(0) + ""; contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); holder.avatarInitialLetter.setText(contactFirstLetter); - holder.avatarInitialLetter.setTextSize(60); +// holder.avatarInitialLetter.setTextSize(60); holder.avatarInitialLetter.setTextColor(Color.WHITE); holder.avatarInitialLetter.setVisibility(View.VISIBLE); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 008ebd52135..a8e9d799577 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -2,21 +2,23 @@ xmlns:rounded="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/green_free_account" + android:gravity="center" + android:background="@android:color/holo_green_light" android:id="@+id/general"> + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> @@ -42,7 +44,7 @@ android:id="@+id/avatar_initial_letter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="50sp" + android:textSize="20sp" android:background="@android:color/transparent" android:textColor="@color/white" android:layout_centerInParent="true" From f78cc2e4eeabc2cdc4b7d80a798ee2393a00e704 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 14 Aug 2018 08:31:52 +0200 Subject: [PATCH 028/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 113 +++++++++++------- .../calls/GroupCallFragmentLollipop.java | 102 ---------------- .../megachat/calls/MegaSurfaceRenderer.java | 8 +- .../chatAdapters/GroupCallAdapter.java | 111 +++++++++-------- .../res/layout/item_camera_group_call.xml | 10 +- 5 files changed, 141 insertions(+), 203 deletions(-) delete mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/GroupCallFragmentLollipop.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 0b6e8b57766..e642483a75c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -59,10 +59,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; -import com.google.android.flexbox.AlignItems; -import com.google.android.flexbox.FlexWrap; -import com.google.android.flexbox.FlexboxLayoutManager; -import com.google.android.flexbox.JustifyContent; import java.io.File; import java.text.SimpleDateFormat; @@ -105,6 +101,7 @@ import static android.provider.Settings.System.DEFAULT_RINGTONE_URI; import static android.view.View.GONE; +import static mega.privacy.android.app.utils.Util.brandAlertDialog; import static mega.privacy.android.app.utils.Util.context; public class ChatCallActivity extends AppCompatActivity implements MegaChatRequestListenerInterface, MegaChatCallListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback { @@ -142,7 +139,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque AppBarLayout appBarLayout; Toolbar tB; ActionBar aB; -// boolean isMe = true; boolean avatarRequested = false; ArrayList peersOnCall = new ArrayList<>(); @@ -150,7 +146,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; -// boolean isIncoming = false; RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -655,13 +650,14 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); -// isIncoming = true; + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); ringerTimer.schedule(myRingerTask, 0, 500); + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); long[] pattern = {0, 1000, 500, 500, 1000}; if (vibrator != null){ @@ -673,28 +669,32 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("1- Incoming call"); + log("1- Incoming call -> numParticipants: "+callChat.getParticipants().size()); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); //Get all the peers, add them to peersOnCall array, show the interface of all those in the video call (avatar only) - for(int i=0;i decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); -// dstRect.left = -40; -// dstRect.right = -40 + ((int)newWidth); + dstRect.left = -40; + dstRect.right = -40 + ((int)newWidth); - dstRect.left += decrease / 2; - dstRect.right -= decrease / 2; +// dstRect.left += decrease / 2; +// dstRect.right -= decrease / 2; // Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 2962a095f6a..a0f5d2ce56c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -167,21 +167,20 @@ public ViewHolderGroupCallGrid(View v) { ViewHolderGroupCallGrid holderGrid = null; @Override public GroupCallAdapter.ViewHolderGroupCall onCreateViewHolder(ViewGroup parent, int viewType) { - log("onCreateViewHolder()"); + log(" onCreateViewHolder()"); -// display = ((Activity) context).getWindowManager().getDefaultDisplay(); -// outMetrics = new DisplayMetrics(); -// display.getMetrics(outMetrics); -// widthScreenPX = outMetrics.widthPixels; -// heightScreenPX = outMetrics.heightPixels; -// density = ((Activity) context).getResources().getDisplayMetrics().density; -// scaleW = Util.getScaleW(outMetrics, density); -// scaleH = Util.getScaleH(outMetrics, density); + display = ((Activity) context).getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics(); + display.getMetrics(outMetrics); + widthScreenPX = outMetrics.widthPixels; + heightScreenPX = outMetrics.heightPixels; + density = ((Activity) context).getResources().getDisplayMetrics().density; + scaleW = Util.getScaleW(outMetrics, density); + scaleH = Util.getScaleH(outMetrics, density); maxScreenHeight = parent.getMeasuredHeight(); maxScreenWidth = parent.getMeasuredWidth(); - // log("onCreateViewHolder-> maxScreenHeight("+maxScreenHeight+"), maxScreenWidth("+maxScreenWidth+")"); @@ -210,14 +209,16 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); - holderGrid.surfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); - holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; - holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; - - holderGrid.surfaceView.setZOrderMediaOverlay(true); - SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); - localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); +// holderGrid.surfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); +// holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; +// holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; +// +// holderGrid.surfaceView.setZOrderMediaOverlay(true); +// SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); +// localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); +// holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); + + v.setTag(holderGrid); return holderGrid; @@ -242,7 +243,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ - log("onBindViewHolderGrid()"); + log("* onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -250,10 +251,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } int numPeersOnCall = getItemCount(); -// if((listenerPeer==null)&&(peer.getListener()==null)){ -// listenerPeer = new GroupCallListener(context, holder); -// peer.setListener(listenerPeer); -// } + + // if(numPeersOnCall<=3){ // holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; // holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; @@ -267,9 +266,31 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ // holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight; // holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; + + + + if(peer.isVideoOn()){ + log("Video ON-> for "+peer.getName()); holder.avatarLayout.setVisibility(GONE); holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); + log(" Video ON-> surfaceViewLayout.child: "+holderGrid.surfaceViewLayout.getChildCount()); + + if(holderGrid.surfaceViewLayout.getChildCount() == 0){ + log(" Video ON-> Create New SurfaceView "); + holderGrid.surfaceView = new SurfaceView(context); + + holderGrid.surfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); + localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); + + holderGrid.surfaceViewLayout.addView(holderGrid.surfaceView); + holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; + holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; + } + + // holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight; // holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth/numPeersOnCall; @@ -288,44 +309,44 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { -// if(peer.getListener()==null){ - log("Video ON -> create listener Peer (YO) "); + if(peer.getListener()==null){ + log(" Video ON-> Create listener for me "); GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); peer.setListener(listenerPeer); megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); -// } -// megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); + } }else{ -// if(peer.getListener()==null){ - log(" Video ON -> create listener Peer ("+peer.getName()+") "); + if(peer.getListener()==null){ + log(" Video ON-> Create listener for "+peer.getName()); GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); peer.setListener(listenerPeer); megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); -// } -// megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); + } } }else{ + log("Video OFF-> for "+peer.getName()); holderGrid.avatarLayout.setVisibility(View.VISIBLE); + log("Video OFF-> Remove all views of SurfaceView "); + holderGrid.surfaceViewLayout.removeAllViews(); holderGrid.surfaceViewLayout.setVisibility(View.GONE); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - -// if(peer.getListener()!=null){ -// log(" Video OFF -> remove listener Peer (YO) "); -// megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); -// peer.setListener(null); -// } + if(peer.getListener()!=null){ + log("Video OFF-> Remove listener for me "); + megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); + peer.setListener(null); + } holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); setProfileMyAvatar(holder); }else{ -// if(peer.getListener()!=null){ -// log(" Video OFF -> remove listener Peer ("+peer.getName()+") "); -// megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); -// peer.setListener(null); -// } + if(peer.getListener()!=null){ + log("Video OFF-> Remove listener for "+peer.getName()); + + megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); + peer.setListener(null); + } holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } @@ -499,8 +520,6 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); holder.avatarImage.setImageBitmap(defaultAvatar); holder.avatarInitialLetter.setText(myFirstLetter); -// holder.avatarInitialLetter.setTextSize(40); - holder.avatarInitialLetter.setTextColor(Color.WHITE); holder.avatarInitialLetter.setVisibility(View.VISIBLE); } @@ -605,8 +624,6 @@ public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGro String contactFirstLetter = fullName.charAt(0) + ""; contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); holder.avatarInitialLetter.setText(contactFirstLetter); -// holder.avatarInitialLetter.setTextSize(60); - holder.avatarInitialLetter.setTextColor(Color.WHITE); holder.avatarInitialLetter.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index a8e9d799577..f09f6de9f64 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -15,10 +15,10 @@ android:background="@android:color/transparent" android:visibility="gone"> - + + + + @@ -44,7 +44,7 @@ android:id="@+id/avatar_initial_letter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="20sp" + android:textSize="50sp" android:background="@android:color/transparent" android:textColor="@color/white" android:layout_centerInParent="true" From 028d95a80c3369ddac201279b9543b1c49ec3deb Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 22 Aug 2018 10:55:15 +0200 Subject: [PATCH 029/247] Feature #9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 6 +- .../megachat/calls/ChatCallActivity.java | 24 ++- .../megachat/calls/InfoPeerGroupCall.java | 14 +- .../megachat/calls/MegaSurfaceRenderer.java | 78 ++++++--- .../chatAdapters/GroupCallAdapter.java | 151 +++++++----------- .../res/layout/item_camera_group_call.xml | 8 +- 6 files changed, 156 insertions(+), 125 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 02738acd8f2..169dce1e615 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -6,6 +6,7 @@ import android.view.SurfaceHolder; import java.nio.ByteBuffer; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; +import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaChatApiJava; import nz.mega.sdk.MegaChatVideoListenerInterface; @@ -22,7 +23,6 @@ public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall h this.holder = holder; this.width = 0; this.height = 0; - } @Override @@ -65,5 +65,9 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holder.localRenderer.DrawBitmap(false); } } + private static void log(String log) { + Util.log("GroupCallListener", log); + } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index e642483a75c..f87a1280eb5 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -682,7 +682,7 @@ protected void onCreate(Bundle savedInstanceState) { long userHandle = callChat.getParticipants().get(i); log("Create contact Peer & add it: "+chat.getPeerFullnameByHandle(userHandle)); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersOnCall.add(0, userPeer); recyclerView.setAdapter(null); @@ -735,7 +735,7 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.requestLayout(); log("Create my Peer & add it: "+megaChatApi.getMyFullname()); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); @@ -1314,7 +1314,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("Create my peer and add me: "+megaChatApi.getMyFullname()); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); @@ -1323,8 +1323,12 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ }else{ //contact joined the group call log("2-"+chat.getPeerFullnameByHandle(userHandle)+" joined the group call"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null); - peersOnCall.add(0,userPeer); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + peersOnCall.add(0, userPeer); + + if(peersOnCall.size()>3){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); @@ -1486,6 +1490,7 @@ public void onClick(View v) { break; } case R.id.video_fab:{ + log("onClick video FAB"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ megaChatApi.answerChatCall(chatId, true, this); @@ -1493,9 +1498,13 @@ public void onClick(View v) { } else{ if(callChat.hasLocalVideo()){ + log(" disableVideo"); + megaChatApi.disableVideo(chatId, this); } else{ + log(" enableVideo"); + megaChatApi.enableVideo(chatId, this); } } @@ -1789,7 +1798,7 @@ public void updateLocalVideoStatus(){ if (peersOnCall != null && !peersOnCall.isEmpty()) { InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); if(!item.isVideoOn()){ - log(" activate Local Video for "+peersOnCall.get((peersOnCall.size()-1)).getName()); + log("activate Local Video for "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(true); adapter.notifyItemChanged(peersOnCall.size()-1); } @@ -1801,7 +1810,7 @@ public void updateLocalVideoStatus(){ if (peersOnCall != null && !peersOnCall.isEmpty()) { InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); if(item.isVideoOn()){ - log(" remove Local Video fot "+peersOnCall.get((peersOnCall.size()-1)).getName()); + log("remove Local Video fot "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(false); adapter.notifyItemChanged(peersOnCall.size()-1); } @@ -1929,6 +1938,7 @@ public void updateRemoteVideoStatus(long userHandle){ if(!peersOnCall.get(i).isVideoOn()){ log("update REMOTE video: "+peersOnCall.get(i).getName()+" camera TRUE"); peersOnCall.get(i).setVideoOn(true); +// adapter.setPeers(peersOnCall); adapter.notifyItemChanged(i); break; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java index 59962456c09..2030bb38f8e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java @@ -1,6 +1,8 @@ package mega.privacy.android.app.lollipop.megachat.calls; +import android.view.SurfaceView; + import mega.privacy.android.app.lollipop.listeners.GroupCallListener; public class InfoPeerGroupCall { @@ -9,13 +11,15 @@ public class InfoPeerGroupCall { boolean videoOn; boolean audioOn; GroupCallListener listener; + SurfaceView surfaceview; - public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener) { + public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener, SurfaceView surfaceview) { this.handle = handle; this.name = name; this.videoOn = videoOn; this.audioOn = audioOn; this.listener = listener; + this.surfaceview = surfaceview; } public Long getHandle() { @@ -58,5 +62,13 @@ public void setListener(GroupCallListener listener) { this.listener = listener; } + public SurfaceView getSurfaceview() { + return surfaceview; + } + + public void setSurfaceview(SurfaceView surfaceview) { + this.surfaceview = surfaceview; + } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index cfc6ef7caba..671c7d71790 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -85,51 +85,83 @@ private void changeDestRect(int dstWidth, int dstHeight) { adjustAspectRatio(); } - private void adjustAspectRatio() { +// private void adjustAspectRatio() { +// Log.d("####","#### adjustAspectRatio()"); +// +// if (bitmap != null && dstRect.height() != 0 && dstRect.width() != 0) { +// Log.d("####","#### bitmap.getWidth(): "+bitmap.getWidth()+", bitmap.getHeight(): "+bitmap.getHeight()); +// Log.d("####","#### dstRect.width(): "+dstRect.width()+", dstRect.height(): "+dstRect.height()); +// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); +// float dstaspectratio = (float) dstRect.width() / dstRect.height(); +// Log.d("####","#### srcaspectratio("+srcaspectratio+") = "+bitmap.getWidth()+" / "+bitmap.getHeight()); +// Log.d("####","#### dstaspectratio("+dstaspectratio+") = "+dstRect.width()+" / "+dstRect.height()); +// +// if ((srcaspectratio != 0 && dstaspectratio != 0)) { +// if (srcaspectratio > dstaspectratio) { +// Log.d("####","#### A -> newHeight "); +// +// float newHeight = dstRect.width() / srcaspectratio; +// Log.d("####","#### A -> newHeight("+newHeight+")= dstRect.width("+dstRect.width()+") / srcaspectratio("+srcaspectratio+")"); +// +// float decrease = dstRect.height() - newHeight; +// Log.d("####","#### A -> decrease("+decrease+")= dstRect.height("+dstRect.height()+") - newHeight("+newHeight+")"); +// +// dstRect.top += decrease / 2; +// dstRect.bottom -= decrease / 2; +// Log.d("####","#### A -> top("+dstRect.top+"), bottom("+dstRect.bottom+"), left("+dstRect.left+"), right("+dstRect.right+")"); +// dstRectf = new RectF(dstRect); +// +// } else { +// +// +// float newWidth = dstRect.height() * srcaspectratio; +// Log.d("####","#### B -> newWidth("+newWidth+")= dstRect.height("+dstRect.height()+") * srcaspectratio ("+srcaspectratio+")"); +// +// float decrease = dstRect.width() - newWidth; +// Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); +// +// dstRect.left = -40; +// dstRect.right = -40 + ((int)newWidth); +// +//// dstRect.left += decrease / 2; +//// dstRect.right -= decrease / 2; +// +// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); +// dstRectf = new RectF(dstRect); +// } +// } +// } +// } - if (bitmap != null && dstRect.height() != 0 && dstRect.width() != 0) { + private void adjustAspectRatio() { + if (bitmap != null && dstRect.height() != 0) { float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); float dstaspectratio = (float) dstRect.width() / dstRect.height(); -// Log.d("####","#### bitmap.getWidth(): "+bitmap.getWidth()+", bitmap.getHeight(): "+bitmap.getHeight()); -// Log.d("####","#### dstRect.width(): "+dstRect.width()+", dstRect.height(): "+dstRect.height()); - if ((srcaspectratio != 0 && dstaspectratio != 0)) { + if (srcaspectratio != 0 && dstaspectratio != 0) { if (srcaspectratio > dstaspectratio) { -// Log.d("####","#### A -> newHeight "); - float newHeight = dstRect.width() / srcaspectratio; -// Log.d("####","#### A -> newHeight("+newHeight+")= dstRect.width("+dstRect.width()+") / srcaspectratio("+srcaspectratio+")"); - float decrease = dstRect.height() - newHeight; -// Log.d("####","#### A -> decrease("+decrease+")= dstRect.height("+dstRect.height()+") - newHeight("+newHeight+")"); - dstRect.top += decrease / 2; dstRect.bottom -= decrease / 2; -// Log.d("####","#### A -> top("+dstRect.top+"), bottom("+dstRect.bottom+"), left("+dstRect.left+"), right("+dstRect.right+")"); dstRectf = new RectF(dstRect); - } else { - - float newWidth = dstRect.height() * srcaspectratio; -// Log.d("####","#### B -> newWidth("+newWidth+")= dstRect.height("+dstRect.height()+") * srcaspectratio ("+srcaspectratio+")"); - float decrease = dstRect.width() - newWidth; // Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); +// float decrease = 0; - dstRect.left = -40; - dstRect.right = -40 + ((int)newWidth); + dstRect.left += decrease / 2; + dstRect.right -= decrease / 2; + Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); -// dstRect.left += decrease / 2; -// dstRect.right -= decrease / 2; - -// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); } } } } + // private void adjustAspectRatio() { // if (bitmap != null && dstRect.height() != 0) { // float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index a0f5d2ce56c..e1dc6cd4b9d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -72,21 +72,22 @@ public class GroupCallAdapter extends RecyclerView.Adapter getPeers() { + return peers; + } + + public void setPeers(ArrayList peers) { + this.peers = peers; + } + ArrayList peers; long chatId; - int width = 0; - int height = 0; - Bitmap bitmap; -// int heightMeasure, widthMeasure; -// int heightReal, widthReal; int maxScreenWidth, maxScreenHeight; - private int numberOfCells; - private int gridWidth = 50; boolean avatarRequested = false; private int adapterType; - private boolean isCreated = false; public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType) { log("GroupCallAdapter( peers: "+peers.size()+")"); @@ -112,19 +113,6 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList maxScreenHeight("+maxScreenHeight+"), maxScreenWidth("+maxScreenWidth+")"); - if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ -// View itemView = mLayoutInflater.inflate(R.layout.view_item, parent, false); -// int height = parent.getMeasuredHeight() / 4; -// itemView.setMinimumHeight(height); -// return new ItemViewHolder(itemView); - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); - int numPeersOnCall = getItemCount(); + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - lp.height =parent.getMeasuredHeight() / numPeersOnCall; - lp.width = parent.getMeasuredWidth(); - log("onCreateViewHolder() -> height: "+maxScreenHeight+"/"+numPeersOnCall+" = "+height); - log("onCreateViewHolder() -> width: "+maxScreenWidth); + if(numPeersOnCall <= 3){ + + lp.height = maxScreenHeight / numPeersOnCall; + lp.width = maxScreenWidth; + + }else if(numPeersOnCall == 4){ + lp.height = maxScreenHeight / 2; + lp.width = maxScreenWidth/2; + + }else if((numPeersOnCall > 4)&&(numPeersOnCall<7)){ + lp.height = maxScreenHeight / 3; + lp.width = maxScreenWidth/2; + + } v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); holderGrid.rlGeneral.setOnClickListener(this); + holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holderGrid.avatarLayout.setLayoutParams(layoutParams); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); + // holderGrid.surfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); // holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; // holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; @@ -243,7 +235,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ - log("* onBindViewHolderGrid()"); + log("onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -269,26 +261,33 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ - if(peer.isVideoOn()){ log("Video ON-> for "+peer.getName()); - holder.avatarLayout.setVisibility(GONE); + holderGrid.avatarLayout.setVisibility(GONE); holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); - log(" Video ON-> surfaceViewLayout.child: "+holderGrid.surfaceViewLayout.getChildCount()); + log("Video ON-> surfaceViewLayout.child: "+holderGrid.surfaceViewLayout.getChildCount()); - if(holderGrid.surfaceViewLayout.getChildCount() == 0){ - log(" Video ON-> Create New SurfaceView "); +// if(holderGrid.surfaceViewLayout.getChildCount() == 0){ + log("Video ON-> Create New SurfaceView "); holderGrid.surfaceView = new SurfaceView(context); + holderGrid.surfaceViewLayout.addView(holderGrid.surfaceView); + holderGrid.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); holderGrid.surfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); - holderGrid.surfaceViewLayout.addView(holderGrid.surfaceView); - holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; - holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; - } + if(peer.getListener() == null){ + GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); + peer.setListener(listenerPeer); + } + + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); + }else{ + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); + } // holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight; @@ -308,49 +307,38 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - if(peer.getListener()==null){ - log(" Video ON-> Create listener for me "); - GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); - peer.setListener(listenerPeer); - megaChatApi.addChatLocalVideoListener(chatId, listenerPeer); - } - }else{ - if(peer.getListener()==null){ - log(" Video ON-> Create listener for "+peer.getName()); - GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); - peer.setListener(listenerPeer); - megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), listenerPeer); - } - } + }else{ log("Video OFF-> for "+peer.getName()); - holderGrid.avatarLayout.setVisibility(View.VISIBLE); - log("Video OFF-> Remove all views of SurfaceView "); - holderGrid.surfaceViewLayout.removeAllViews(); - holderGrid.surfaceViewLayout.setVisibility(View.GONE); - +// if(holderGrid.surfaceViewLayout.getChildCount() != 0){ + log("Video OFF-> Remove all views of SurfaceView "); + holderGrid.surfaceViewLayout.removeAllViewsInLayout(); +// } if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { if(peer.getListener()!=null){ - log("Video OFF-> Remove listener for me "); megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); peer.setListener(null); + }else{ } holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); setProfileMyAvatar(holder); }else{ if(peer.getListener()!=null){ - log("Video OFF-> Remove listener for "+peer.getName()); - megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); peer.setListener(null); + }else{ } holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } + holderGrid.avatarLayout.setVisibility(View.VISIBLE); + holderGrid.surfaceViewLayout.setVisibility(View.GONE); + + + // if (numPeersOnCall < 4) { // holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure / numPeersOnCall); // log("onBindViewHolderGrid() new height: " + (heightMeasure / numPeersOnCall)); @@ -399,23 +387,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } } -// public void setNodes(ArrayList peers) { -// log("setNodes() -> peers: "+peers.size()+" && notifyDataSetChanged()"); -// this.peers = peers; -// display = ((Activity) context).getWindowManager().getDefaultDisplay(); -// outMetrics = new DisplayMetrics(); -// display.getMetrics(outMetrics); -// widthScreenPX = outMetrics.widthPixels; -// heightScreenPX = outMetrics.heightPixels; -// maxScreenWidth = (int) widthScreenPX; -// maxScreenHeight = ((int) heightScreenPX) - 50; -// if (peers.size() < 4) { -// heightReal = maxScreenHeight/peers.size(); -// widthReal = maxScreenWidth/peers.size(); -// } -// notifyDataSetChanged(); -// } - @Override public int getItemCount() { if (peers != null){ diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index f09f6de9f64..7efff42efb7 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -1,10 +1,9 @@ + android:background="@android:color/holo_green_light"> From f49e8fa5af9792a7e8693c07c359725bcb9ab18b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 22 Aug 2018 13:19:42 +0200 Subject: [PATCH 030/247] Feature#9775-Group calls UI --- .../megachat/calls/MegaSurfaceRenderer.java | 57 +------ .../chatAdapters/GroupCallAdapter.java | 147 ++++-------------- 2 files changed, 36 insertions(+), 168 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 671c7d71790..e3fcfcb6f21 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -85,54 +85,6 @@ private void changeDestRect(int dstWidth, int dstHeight) { adjustAspectRatio(); } -// private void adjustAspectRatio() { -// Log.d("####","#### adjustAspectRatio()"); -// -// if (bitmap != null && dstRect.height() != 0 && dstRect.width() != 0) { -// Log.d("####","#### bitmap.getWidth(): "+bitmap.getWidth()+", bitmap.getHeight(): "+bitmap.getHeight()); -// Log.d("####","#### dstRect.width(): "+dstRect.width()+", dstRect.height(): "+dstRect.height()); -// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); -// float dstaspectratio = (float) dstRect.width() / dstRect.height(); -// Log.d("####","#### srcaspectratio("+srcaspectratio+") = "+bitmap.getWidth()+" / "+bitmap.getHeight()); -// Log.d("####","#### dstaspectratio("+dstaspectratio+") = "+dstRect.width()+" / "+dstRect.height()); -// -// if ((srcaspectratio != 0 && dstaspectratio != 0)) { -// if (srcaspectratio > dstaspectratio) { -// Log.d("####","#### A -> newHeight "); -// -// float newHeight = dstRect.width() / srcaspectratio; -// Log.d("####","#### A -> newHeight("+newHeight+")= dstRect.width("+dstRect.width()+") / srcaspectratio("+srcaspectratio+")"); -// -// float decrease = dstRect.height() - newHeight; -// Log.d("####","#### A -> decrease("+decrease+")= dstRect.height("+dstRect.height()+") - newHeight("+newHeight+")"); -// -// dstRect.top += decrease / 2; -// dstRect.bottom -= decrease / 2; -// Log.d("####","#### A -> top("+dstRect.top+"), bottom("+dstRect.bottom+"), left("+dstRect.left+"), right("+dstRect.right+")"); -// dstRectf = new RectF(dstRect); -// -// } else { -// -// -// float newWidth = dstRect.height() * srcaspectratio; -// Log.d("####","#### B -> newWidth("+newWidth+")= dstRect.height("+dstRect.height()+") * srcaspectratio ("+srcaspectratio+")"); -// -// float decrease = dstRect.width() - newWidth; -// Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); -// -// dstRect.left = -40; -// dstRect.right = -40 + ((int)newWidth); -// -//// dstRect.left += decrease / 2; -//// dstRect.right -= decrease / 2; -// -// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); -// dstRectf = new RectF(dstRect); -// } -// } -// } -// } - private void adjustAspectRatio() { if (bitmap != null && dstRect.height() != 0) { float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); @@ -149,11 +101,10 @@ private void adjustAspectRatio() { float newWidth = dstRect.height() * srcaspectratio; float decrease = dstRect.width() - newWidth; // Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); -// float decrease = 0; - - dstRect.left += decrease / 2; - dstRect.right -= decrease / 2; - Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); +// Log.d("####","#### dstREct.left: "+dstRect.left+", dstRect.right: "+dstRect.right); + dstRect.left -= decrease/2; + dstRect.right += decrease/2 - ((int)newWidth);; +// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e1dc6cd4b9d..f7e76d4bcb4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -229,8 +229,8 @@ public int getItemViewType(int position) { public void onBindViewHolder(ViewHolderGroupCall holder, int position) { log("onBindViewHolder"); if (adapterType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ - ViewHolderGroupCallGrid holderGrid = (ViewHolderGroupCallGrid) holder; - onBindViewHolderGrid(holderGrid, position); + ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder; + onBindViewHolderGrid(holderGrid2, position); } } @@ -244,145 +244,62 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ int numPeersOnCall = getItemCount(); + if(peer.isVideoOn()) { + holder.avatarLayout.setVisibility(GONE); + holder.surfaceViewLayout.setVisibility(View.VISIBLE); + log("Video ON-> for " + peer.getName()+", getChildCount: "+holder.surfaceViewLayout.getChildCount()); -// if(numPeersOnCall<=3){ -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; -// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; -// }else{ -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/2; -// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; -// } - - -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; - -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight; -// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth; - - - - if(peer.isVideoOn()){ - log("Video ON-> for "+peer.getName()); - holderGrid.avatarLayout.setVisibility(GONE); - holderGrid.surfaceViewLayout.setVisibility(View.VISIBLE); - log("Video ON-> surfaceViewLayout.child: "+holderGrid.surfaceViewLayout.getChildCount()); - -// if(holderGrid.surfaceViewLayout.getChildCount() == 0){ + if(holder.surfaceViewLayout.getChildCount() == 0){ log("Video ON-> Create New SurfaceView "); - holderGrid.surfaceView = new SurfaceView(context); - holderGrid.surfaceViewLayout.addView(holderGrid.surfaceView); - holderGrid.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); + holder.surfaceView = new SurfaceView(context); + holder.surfaceViewLayout.addView(holderGrid.surfaceView); + holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - holderGrid.surfaceView.setZOrderMediaOverlay(true); - SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); + holder.surfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); - - if(peer.getListener() == null){ - GroupCallListener listenerPeer = new GroupCallListener(context, holderGrid); - peer.setListener(listenerPeer); - } + holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); + } + if (peer.getListener() == null) { + log("Video ON-> Create New Listener "); + GroupCallListener listenerPeer = new GroupCallListener(context, holder); + peer.setListener(listenerPeer); if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video ON-> addChatLocalVideoListener() "); megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); - }else{ + } else { + log("Video ON-> addChatRemoteVideoListener()"); megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); } - - -// holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight; -// holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth/numPeersOnCall; - -// if(numPeersOnCall<=3){ -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/numPeersOnCall; -// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth/numPeersOnCall; -// }else{ -// holderGrid.rlGeneral.getLayoutParams().height = maxScreenHeight/2; -// holderGrid.rlGeneral.getLayoutParams().width= maxScreenWidth/2; -// } - -// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.surfaceView.getLayoutParams(); -// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); -// holderGrid.surfaceView.setLayoutParams(layoutParams); - - - - + } }else{ - log("Video OFF-> for "+peer.getName()); -// if(holderGrid.surfaceViewLayout.getChildCount() != 0){ + log("Video OFF-> for "+peer.getName()+", getChildCount: "+holder.surfaceViewLayout.getChildCount()); + if(holder.surfaceViewLayout.getChildCount() != 0){ log("Video OFF-> Remove all views of SurfaceView "); - holderGrid.surfaceViewLayout.removeAllViewsInLayout(); -// } + holder.surfaceViewLayout.removeAllViewsInLayout(); + } if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { if(peer.getListener()!=null){ + log("Video OFF-> removeMYChatVideoListener() "); megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); peer.setListener(null); - }else{ } - holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); + holder.rlGeneral.setBackgroundColor(Color.BLUE); setProfileMyAvatar(holder); - }else{ if(peer.getListener()!=null){ + log("Video OFF-> removeChatVideoListener() "); megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); peer.setListener(null); - }else{ } - holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); + holder.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - holderGrid.avatarLayout.setVisibility(View.VISIBLE); - holderGrid.surfaceViewLayout.setVisibility(View.GONE); - - - -// if (numPeersOnCall < 4) { -// holderGrid.rlGeneral.getLayoutParams().height = (heightMeasure / numPeersOnCall); -// log("onBindViewHolderGrid() new height: " + (heightMeasure / numPeersOnCall)); -// holderGrid.rlGeneral.getLayoutParams().width = widthMeasure; -// log("onBindViewHolderGrid() new width: " + widthMeasure); -// } - -// if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { -// log("me"); -// holderGrid.rlGeneral.setBackgroundColor(Color.BLUE); -// setProfileMyAvatar(holder); -// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); -// -// if (numPeersOnCall == 2) { -// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); -// layoutParams.setMargins(0, 80, 0, 0); -// } else { -// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); -// layoutParams.setMargins(0, 0, 0, 0); -// } -// holderGrid.avatarLayout.setLayoutParams(layoutParams); - - -// } else { -// log("contact"); -// holderGrid.rlGeneral.setBackgroundColor(Color.YELLOW); -// setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); -// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holderGrid.avatarLayout.getLayoutParams(); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); -// -// if (numPeersOnCall == 2) { -// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); -// layoutParams.setMargins(0, 0, 0, 80); -// } else { -// layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); -// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); -// layoutParams.setMargins(0, 0, 0, 0); -// } -// holderGrid.avatarLayout.setLayoutParams(layoutParams); -// } + holder.avatarLayout.setVisibility(View.VISIBLE); + holder.surfaceViewLayout.setVisibility(View.GONE); } } From 833ade6e38f39bc32d19aece573258ce4cd38d02 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 22 Aug 2018 20:29:48 +0200 Subject: [PATCH 031/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 108 ++++++++---------- .../megachat/calls/MegaSurfaceRenderer.java | 2 +- .../chatAdapters/GroupCallAdapter.java | 4 +- .../res/layout/item_camera_group_call.xml | 3 +- 4 files changed, 53 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f87a1280eb5..568b49e7dce 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -141,7 +141,11 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ActionBar aB; boolean avatarRequested = false; + boolean myPeerisAdded = false; + ArrayList peersOnCall = new ArrayList<>(); + ArrayList peersBeforeCall = new ArrayList<>(); + Timer timer = null; Timer ringerTimer = null; @@ -669,7 +673,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("1- Incoming call -> numParticipants: "+callChat.getParticipants().size()); + log("Incoming call -> numParticipants: "+callChat.getParticipants().size()); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -683,10 +687,10 @@ protected void onCreate(Bundle savedInstanceState) { log("Create contact Peer & add it: "+chat.getPeerFullnameByHandle(userHandle)); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); - peersOnCall.add(0, userPeer); + peersBeforeCall.add(0, userPeer); recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -728,7 +732,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("1- Outgoing call"); + log("Outgoing call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -737,6 +741,7 @@ protected void onCreate(Bundle savedInstanceState) { log("Create my Peer & add it: "+megaChatApi.getMyFullname()); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); + myPeerisAdded = true; recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); @@ -1258,7 +1263,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ - log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); stopAudioSignals(); @@ -1288,31 +1292,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateSubTitle(); if(userHandle==megaChatApi.getMyUserHandle()){ //I joined the group call - log("2- I joined the group call"); - //First clear the array and add real participants: -// peersOnCall.clear(); -// for(int j=0;j setNodes()"); -// //adapter.setNodes(peersOnCall); -// -// -// isMe = false; -// }else{ -// log("add contactPeer -> "+chat.getPeerFullnameByHandle(userHandle)+", hasVideo: "+userSession.hasVideo()); -// InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null); -// peersOnCall.add(0,userPeer); -// log("contact joined to the call -> setNodes()"); -// -//// adapter.setNodes(peersOnCall); -// -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); -// recyclerView.setAdapter(adapter); -// -//// if(peersOnCall.size()>3){ -//// log("setColumnWidth-> widthScreenPX/2"); -//// recyclerView.setColumnWidth((int) widthScreenPX/2); -//// } -// -// } - } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1404,6 +1357,45 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ log("CHANGE_TYPE_CALL_COMPOSITION"); + boolean isMe = false; + for(int i=0;i decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); // Log.d("####","#### dstREct.left: "+dstRect.left+", dstRect.right: "+dstRect.right); dstRect.left -= decrease/2; - dstRect.right += decrease/2 - ((int)newWidth);; + dstRect.right -= decrease/2 + ((int)newWidth);; // Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index f7e76d4bcb4..5460114d915 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -252,7 +252,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if(holder.surfaceViewLayout.getChildCount() == 0){ log("Video ON-> Create New SurfaceView "); holder.surfaceView = new SurfaceView(context); - holder.surfaceViewLayout.addView(holderGrid.surfaceView); + holder.surfaceViewLayout.addView(holder.surfaceView); holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); holder.surfaceView.setZOrderMediaOverlay(true); @@ -286,7 +286,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); peer.setListener(null); } - holder.rlGeneral.setBackgroundColor(Color.BLUE); setProfileMyAvatar(holder); }else{ if(peer.getListener()!=null){ @@ -294,7 +293,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); peer.setListener(null); } - holder.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 7efff42efb7..dc8159a2d9d 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -2,8 +2,7 @@ xmlns:rounded="http://schemas.android.com/apk/res-auto" android:id="@+id/general" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@android:color/holo_green_light"> + android:layout_height="match_parent"> Date: Thu, 23 Aug 2018 12:08:18 +0200 Subject: [PATCH 032/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 185 ++++++++++++------ 1 file changed, 120 insertions(+), 65 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 568b49e7dce..61c9f5f131a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -141,8 +141,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ActionBar aB; boolean avatarRequested = false; - boolean myPeerisAdded = false; - ArrayList peersOnCall = new ArrayList<>(); ArrayList peersBeforeCall = new ArrayList<>(); @@ -656,7 +654,6 @@ protected void onCreate(Bundle savedInstanceState) { log("Incoming call"); ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); ringerTimer.schedule(myRingerTask, 0, 500); @@ -679,7 +676,7 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); - //Get all the peers, add them to peersOnCall array, show the interface of all those in the video call (avatar only) + //Get all the peers, add them to peersBeforeCall array, show the AVATARS only if(callChat.getParticipants().size()!=0){ for(int i = 0; i < callChat.getParticipants().size(); i++){ @@ -741,7 +738,6 @@ protected void onCreate(Bundle savedInstanceState) { log("Create my Peer & add it: "+megaChatApi.getMyFullname()); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - myPeerisAdded = true; recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); @@ -1234,25 +1230,42 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { int callStatus = callChat.getStatus(); switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ - log("CALL_STATUS_IN_PROGRESS"); + log("*CALL_STATUS_IN_PROGRESS"); + + if(chat.isGroup()){ + if(call.isIncoming()){ + log("incoming call"); + if(peersBeforeCall.size()!=0){ + for(int i=0;i3){ + recyclerView.setColumnWidth((int) widthScreenPX/2); }else{ - //contact joined the group call - log(chat.getPeerFullnameByHandle(userHandle)+" joined the group call"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); - peersOnCall.add(0, userPeer); + recyclerView.setColumnWidth((int) widthScreenPX); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); - if(peersOnCall.size()>3){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } + }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ + updateSubTitle(); - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - recyclerView.setAdapter(adapter); + //contact left the group call + log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); + for(int i=0;i3){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); + } updateRemoteVideoStatus(userHandle); @@ -1355,48 +1379,79 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("CHANGE_TYPE_CALL_COMPOSITION"); - - boolean isMe = false; - for(int i=0;i RINGING --> remove peersBeforeCall elements"); + for(int i=0;i Date: Fri, 24 Aug 2018 10:56:36 +0200 Subject: [PATCH 033/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 184 ++++++++++-------- .../megachat/calls/InfoPeerGroupCall.java | 1 - .../megachat/calls/MegaSurfaceRenderer.java | 47 +++-- .../chatAdapters/GroupCallAdapter.java | 77 +++++--- 4 files changed, 187 insertions(+), 122 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 61c9f5f131a..b6c0cae4755 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -651,7 +651,8 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - log("Incoming call"); + log("1- Incoming call"); + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); @@ -670,22 +671,29 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Incoming call -> numParticipants: "+callChat.getParticipants().size()); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); //Get all the peers, add them to peersBeforeCall array, show the AVATARS only + peersBeforeCall.clear(); + peersOnCall.clear(); + if(callChat.getParticipants().size()!=0){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - log("Create contact Peer & add it: "+chat.getPeerFullnameByHandle(userHandle)); + log("1- Incoming call: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); @@ -729,15 +737,24 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Outgoing call"); + log("2 Outgoing call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); + peersBeforeCall.clear(); + peersOnCall.clear(); - log("Create my Peer & add it: "+megaChatApi.getMyFullname()); + log("2- Outgoing call: Add : "+megaChatApi.getMyFullname()+" my peer "); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); @@ -1084,7 +1101,9 @@ public void onDestroy(){ } peersOnCall.clear(); + peersBeforeCall.clear(); stopAudioSignals(); + mSensorManager.unregisterListener(this); MegaApplication.activityPaused(); @@ -1230,25 +1249,25 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { int callStatus = callChat.getStatus(); switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ - log("*CALL_STATUS_IN_PROGRESS"); + log("4 CALL_STATUS_IN_PROGRESS"); if(chat.isGroup()){ if(call.isIncoming()){ log("incoming call"); - if(peersBeforeCall.size()!=0){ - for(int i=0;i 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); - }else if(call.isOutgoing()){ - log("outgoing call"); - } } @@ -1301,38 +1320,42 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + updateSubTitle(); //contact joined the group call - log(chat.getPeerFullnameByHandle(userHandle)+" joined the group call"); - + log("5- Session Status: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - if(peersOnCall.size()>3){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - }else{ + if(peersOnCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); } + recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ + updateSubTitle(); //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); for(int i=0;i3){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - }else{ + + if(peersOnCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); } recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); @@ -1381,10 +1404,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ - log("CHANGE_TYPE_CALL_COMPOSITION -> RINGING --> remove peersBeforeCall elements"); - for(int i=0;i 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); @@ -1414,44 +1442,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } } - } - -// if(call.isIncoming()){ -// boolean isMe = false; -// for(int i=0;i left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); + dstRect.top += decreaseASide; + dstRect.bottom -= decreaseASide; +// Log.d("&&","&& DESPUES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); + dstRectf = new RectF(dstRect); } else { + float newWidth = dstRect.height() * srcaspectratio; +// Log.d("&&","&& newWidth = dstRect.height("+dstRect.height()+") * srcaspectratio("+srcaspectratio+") = "+newWidth); + float decrease = dstRect.width() - newWidth; -// Log.d("####","#### B -> decrease("+decrease+")= dstRect.width("+dstRect.width()+") - newWidth("+newWidth+")"); -// Log.d("####","#### dstREct.left: "+dstRect.left+", dstRect.right: "+dstRect.right); - dstRect.left -= decrease/2; - dstRect.right -= decrease/2 + ((int)newWidth);; -// Log.d("####","#### B -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); +// Log.d("&&","&& decrease = dstRect.width()("+dstRect.width()+") - newWidth("+newWidth+") = "+decrease); + float decreaseASide = decrease/2; + +// Log.d("&&","&& decreaseASide = "+decreaseASide); + +// Log.d("&&","&& ANTES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); + dstRect.left += (-1)*decreaseASide; + dstRect.right -= (newWidth - decreaseASide); + +// Log.d("&&","&& DESPUES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); dstRectf = new RectF(dstRect); } @@ -139,8 +160,6 @@ private void adjustAspectRatio() { public void surfaceCreated(SurfaceHolder holder) { - Log.d("####","#### surfaceCreated(): "); - Canvas canvas = surfaceHolder.lockCanvas(); if(canvas != null) { Rect dst = surfaceHolder.getSurfaceFrame(); @@ -165,7 +184,7 @@ public void surfaceCreated(SurfaceHolder holder) { } public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - Log.d("####","#### surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + Log.d("MegaSurfaceRenderer","surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); changeDestRect(in_width, in_height); @@ -183,7 +202,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - Log.d("####","#### surfaceDestroyed(): "); + Log.d("MegaSurfaceRenderer","surfaceDestroyed(): "); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; @@ -191,7 +210,7 @@ public void surfaceDestroyed(SurfaceHolder holder) { } public Bitmap CreateBitmap(int width, int height) { - Log.d("####","#### CreateBitmap(): width = "+width+", height = "+height); + Log.d("MegaSurfaceRenderer","CreateBitmap(): width = "+width+", height = "+height); Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); if (bitmap == null) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 5460114d915..e0cab0d20d7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -194,23 +194,15 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); holderGrid.rlGeneral.setOnClickListener(this); holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); + holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holderGrid.avatarLayout.setLayoutParams(layoutParams); + holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); -// holderGrid.surfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); -// holderGrid.surfaceView.getLayoutParams().height = maxScreenHeight/numPeersOnCall; -// holderGrid.surfaceView.getLayoutParams().width = maxScreenWidth; -// -// holderGrid.surfaceView.setZOrderMediaOverlay(true); -// SurfaceHolder localSurfaceHolder = holderGrid.surfaceView.getHolder(); -// localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); -// holderGrid.localRenderer = new MegaSurfaceRenderer(holderGrid.surfaceView); - - v.setTag(holderGrid); return holderGrid; @@ -242,26 +234,32 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } - int numPeersOnCall = getItemCount(); + if(peer.isAudioOn()){ + log("Audio ON"); + }else{ + log("Audio OFF"); + } if(peer.isVideoOn()) { + log("Video ON"); + holder.avatarLayout.setVisibility(GONE); holder.surfaceViewLayout.setVisibility(View.VISIBLE); - log("Video ON-> for " + peer.getName()+", getChildCount: "+holder.surfaceViewLayout.getChildCount()); if(holder.surfaceViewLayout.getChildCount() == 0){ log("Video ON-> Create New SurfaceView "); holder.surfaceView = new SurfaceView(context); holder.surfaceViewLayout.addView(holder.surfaceView); holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - holder.surfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); + } + if (peer.getListener() == null) { - log("Video ON-> Create New Listener "); + log("Video ON-> Create new Listener "); GroupCallListener listenerPeer = new GroupCallListener(context, holder); peer.setListener(listenerPeer); @@ -275,30 +273,36 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } }else{ - log("Video OFF-> for "+peer.getName()+", getChildCount: "+holder.surfaceViewLayout.getChildCount()); + log("Video OFF"); + log("surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); if(holder.surfaceViewLayout.getChildCount() != 0){ - log("Video OFF-> Remove all views of SurfaceView "); + log("Video OFF-> Remove SurfaceView "); holder.surfaceViewLayout.removeAllViewsInLayout(); } - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - if(peer.getListener()!=null){ - log("Video OFF-> removeMYChatVideoListener() "); + + if(peer.getListener()!=null){ + log("Video OFF-> Remove Listener"); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video OFF-> removeChatMyVideoListener()"); megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); peer.setListener(null); - } - setProfileMyAvatar(holder); - }else{ - if(peer.getListener()!=null){ - log("Video OFF-> removeChatVideoListener() "); + }else{ + log("Video OFF-> removeChatVideoListener()"); megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); peer.setListener(null); } + } + + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video OFF-> my Avatar"); + setProfileMyAvatar(holder); + }else{ + log("Video OFF-> contact Avatar"); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } holder.avatarLayout.setVisibility(View.VISIBLE); holder.surfaceViewLayout.setVisibility(View.GONE); - } } @@ -529,4 +533,27 @@ public void setListFragment(RecyclerView recyclerViewFragment) { this.recyclerViewFragment = recyclerViewFragment; } + + public void changesInAudio(int position, ViewHolderGroupCall holder){ + log("changesInAudio"); + if(holder == null){ + holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + if(peer.isAudioOn()){ + log("Audio ON"); + }else{ + log("Audio OFF"); + } + }else{ + log("holder is NULL"); + notifyItemChanged(position); + } + } + + } From 64cfe952f320ae0219ecd68f958d6ca15632b2e5 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 24 Aug 2018 13:40:55 +0200 Subject: [PATCH 034/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 3 +- .../chatAdapters/GroupCallAdapter.java | 72 ++++++-- .../res/layout/item_camera_group_call.xml | 163 ++++++------------ 3 files changed, 113 insertions(+), 125 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b6c0cae4755..bed5d1daecf 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -653,7 +653,6 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("1- Incoming call"); - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -722,7 +721,6 @@ protected void onCreate(Bundle savedInstanceState) { }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("CALL_STATUS_IN_PROGRESS"); updateScreenStatusInProgress(); - }else{ int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); @@ -745,6 +743,7 @@ protected void onCreate(Bundle savedInstanceState) { peersBeforeCall.clear(); peersOnCall.clear(); + log("2- Outgoing call: Add : "+megaChatApi.getMyFullname()+" my peer "); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e0cab0d20d7..b9a45842efd 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -20,6 +20,7 @@ import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -135,7 +136,10 @@ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ public RoundedImageView avatarImage; public TextView avatarInitialLetter; public RelativeLayout surfaceViewLayout; + public long userHandle; public SurfaceView surfaceView; + public ImageView microAvatar; + public ImageView microSurface; public MegaSurfaceRenderer localRenderer; public ViewHolderGroupCall(View itemView) { super(itemView); @@ -194,12 +198,17 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); holderGrid.rlGeneral.setOnClickListener(this); holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); + holderGrid.surfaceViewLayout.removeAllViewsInLayout(); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holderGrid.avatarLayout.setLayoutParams(layoutParams); + holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); + + holderGrid.microSurface = new ImageView(context); + holderGrid.surfaceView = new SurfaceView(context); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); @@ -234,35 +243,50 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } - if(peer.isAudioOn()){ - log("Audio ON"); - }else{ - log("Audio OFF"); - } if(peer.isVideoOn()) { log("Video ON"); + holder.microAvatar.setVisibility(View.GONE); holder.avatarLayout.setVisibility(GONE); holder.surfaceViewLayout.setVisibility(View.VISIBLE); + log("Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); if(holder.surfaceViewLayout.getChildCount() == 0){ - log("Video ON-> Create New SurfaceView "); - holder.surfaceView = new SurfaceView(context); - holder.surfaceViewLayout.addView(holder.surfaceView); + log("Video ON- > SurfaceLayout == 0 -----> Create New SurfaceView"); + + log("Video ON-> Created child: "+holder.surfaceViewLayout.getChildCount()); holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); holder.surfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); + holder.surfaceViewLayout.addView(holder.surfaceView); + + holder.microSurface.setImageResource(R.drawable.ic_mic_off); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); + + if(peer.isAudioOn()){ + holder.microSurface.setVisibility(View.GONE); + }else{ + holder.microSurface.setVisibility(View.VISIBLE); + } + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + + + + }else{ + log("Video ON- > SurfaceLayout != 0 -----> NADA "); } if (peer.getListener() == null) { log("Video ON-> Create new Listener "); GroupCallListener listenerPeer = new GroupCallListener(context, holder); peer.setListener(listenerPeer); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("Video ON-> addChatLocalVideoListener() "); megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); @@ -272,14 +296,21 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } } + + }else{ log("Video OFF"); - log("surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + holder.microSurface.setVisibility(View.GONE); + + log("Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); if(holder.surfaceViewLayout.getChildCount() != 0){ - log("Video OFF-> Remove SurfaceView "); + log("Video OFF- > SurfaceLayout != 0 -----> Remove SurfaceView "); holder.surfaceViewLayout.removeAllViewsInLayout(); + }else{ + log("Video OFF- > SurfaceLayout == 0 -----> NADA "); } - + holder.avatarLayout.setVisibility(View.VISIBLE); + holder.surfaceViewLayout.setVisibility(View.GONE); if(peer.getListener()!=null){ log("Video OFF-> Remove Listener"); if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -300,9 +331,11 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ log("Video OFF-> contact Avatar"); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - - holder.avatarLayout.setVisibility(View.VISIBLE); - holder.surfaceViewLayout.setVisibility(View.GONE); + if(peer.isAudioOn()){ + holder.microAvatar.setVisibility(View.GONE); + }else{ + holder.microAvatar.setVisibility(View.VISIBLE); + } } } @@ -546,8 +579,17 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } if(peer.isAudioOn()){ log("Audio ON"); + holder.microAvatar.setVisibility(View.GONE); + holder.microSurface.setVisibility(View.GONE); }else{ log("Audio OFF"); + if(!peer.isVideoOn()){ + holder.microAvatar.setVisibility(View.VISIBLE); + holder.microSurface.setVisibility(View.GONE); + }else{ + holder.microSurface.setVisibility(View.VISIBLE); + holder.microAvatar.setVisibility(View.GONE); + } } }else{ log("holder is NULL"); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index dc8159a2d9d..0f536202f0b 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -5,121 +5,68 @@ android:layout_height="match_parent"> - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - \ No newline at end of file + From 9748c6e8a91b11a10f439ed649535cd45322901a Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 27 Aug 2018 08:51:05 +0200 Subject: [PATCH 035/247] Feature#9775-Group calls U --- .../lollipop/listeners/GroupCallListener.java | 6 +- .../megachat/calls/ChatCallActivity.java | 2 + .../megachat/calls/MegaSurfaceRenderer.java | 4 + .../chatAdapters/GroupCallAdapter.java | 98 ++++++++++++------- 4 files changed, 76 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 169dce1e615..247042dbdb2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -15,7 +15,8 @@ public class GroupCallListener implements MegaChatVideoListenerInterface { Context context; GroupCallAdapter.ViewHolderGroupCall holder; - int width,height; + int width; + int height; Bitmap bitmap; public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall holder) { @@ -48,6 +49,8 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = holder.localRenderer.CreateBitmap(width, height); + holder.widthX = width; + holder.heightX = height; Sholder.setFixedSize(holderWidth, holderHeight); } else{ @@ -65,6 +68,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holder.localRenderer.DrawBitmap(false); } } + private static void log(String log) { Util.log("GroupCallListener", log); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index bed5d1daecf..5705b9ae58e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -721,8 +721,10 @@ protected void onCreate(Bundle savedInstanceState) { }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("CALL_STATUS_IN_PROGRESS"); updateScreenStatusInProgress(); + }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index adc26fe3969..8c503c43fbf 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -313,4 +313,8 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { return output; } + + public Bitmap getBitmap(){ + return bitmap; + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index b9a45842efd..77c91b86944 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -131,16 +131,19 @@ public void onClick(View v) { /*private view holder class*/ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ - public RelativeLayout rlGeneral; - public RelativeLayout avatarLayout; - public RoundedImageView avatarImage; - public TextView avatarInitialLetter; - public RelativeLayout surfaceViewLayout; - public long userHandle; + RelativeLayout rlGeneral; + RelativeLayout avatarLayout; + RoundedImageView avatarImage; + TextView avatarInitialLetter; + RelativeLayout surfaceViewLayout; + ImageView microAvatar; + ImageView microSurface; public SurfaceView surfaceView; - public ImageView microAvatar; - public ImageView microSurface; public MegaSurfaceRenderer localRenderer; + SurfaceHolder localSurfaceHolder; + + public int widthX, heightX = 0; + public ViewHolderGroupCall(View itemView) { super(itemView); } @@ -208,7 +211,8 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); holderGrid.microSurface = new ImageView(context); - holderGrid.surfaceView = new SurfaceView(context); + holderGrid.microSurface.setVisibility(View.GONE); + holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); @@ -247,19 +251,21 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if(peer.isVideoOn()) { log("Video ON"); holder.microAvatar.setVisibility(View.GONE); - holder.avatarLayout.setVisibility(GONE); holder.surfaceViewLayout.setVisibility(View.VISIBLE); - log("Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + log("1-Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + holder.surfaceViewLayout.removeView(holder.surfaceView); + holder.surfaceViewLayout.removeView(holder.microSurface); if(holder.surfaceViewLayout.getChildCount() == 0){ - log("Video ON- > SurfaceLayout == 0 -----> Create New SurfaceView"); - - log("Video ON-> Created child: "+holder.surfaceViewLayout.getChildCount()); + log("Video ON --> Create New SurfaceView"); + holder.surfaceView = new SurfaceView(context); holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); holder.surfaceView.setZOrderMediaOverlay(true); - SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); - localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); +// SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); + holder.localSurfaceHolder = holder.surfaceView.getHolder(); + + holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); holder.surfaceViewLayout.addView(holder.surfaceView); @@ -268,19 +274,14 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); - - if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ holder.microSurface.setVisibility(View.VISIBLE); } - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - - +// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + log("2-Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); - }else{ - log("Video ON- > SurfaceLayout != 0 -----> NADA "); } if (peer.getListener() == null) { @@ -290,27 +291,55 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("Video ON-> addChatLocalVideoListener() "); megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); + } else { log("Video ON-> addChatRemoteVideoListener()"); megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); } - } - +// log("###### w: "+holder.widthX+", h: "+holder.heightX); +// holder.microSurface.setImageResource(R.drawable.ic_mic_off); +// RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); +// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); +// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); +// if((holder.widthX == 0)||(holder.heightX == 0)){ +// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); +// }else{ +// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); +// } +// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); +// if(peer.isAudioOn()){ +// holder.microSurface.setVisibility(View.GONE); +// }else{ +// holder.microSurface.setVisibility(View.VISIBLE); +// } + } }else{ log("Video OFF"); holder.microSurface.setVisibility(View.GONE); + holder.surfaceViewLayout.setVisibility(View.VISIBLE); - log("Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); - if(holder.surfaceViewLayout.getChildCount() != 0){ - log("Video OFF- > SurfaceLayout != 0 -----> Remove SurfaceView "); - holder.surfaceViewLayout.removeAllViewsInLayout(); - }else{ - log("Video OFF- > SurfaceLayout == 0 -----> NADA "); +// log("***** Video OFF- > Remove SurfaceView"); + log("1-Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + if(holder.surfaceViewLayout.getChildCount()!=0){ + holder.surfaceViewLayout.removeView(holder.surfaceView); + holder.surfaceViewLayout.removeView(holder.microSurface); } - holder.avatarLayout.setVisibility(View.VISIBLE); - holder.surfaceViewLayout.setVisibility(View.GONE); + log("2-Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + + +// holder.surfaceViewLayout.removeView(holder.surfaceView); + // holder.localRenderer.surfaceDestroyed(holder.localSurfaceHolder); + +// log("Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); +// if(holder.surfaceViewLayout.getChildCount() != 0){ +// log("Video OFF- > SurfaceLayout != 0 -----> Remove SurfaceView "); +// holder.surfaceViewLayout.removeAllViewsInLayout(); +// }else{ +// log("Video OFF- > SurfaceLayout == 0 -----> NADA "); +// } + if(peer.getListener()!=null){ log("Video OFF-> Remove Listener"); if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -336,6 +365,9 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ }else{ holder.microAvatar.setVisibility(View.VISIBLE); } + + holder.avatarLayout.setVisibility(View.VISIBLE); + holder.surfaceViewLayout.setVisibility(View.GONE); } } From d0ced00bb9d73ebdc1c45ddc2b8fbe8d29db84d0 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Thu, 23 Aug 2018 14:27:11 +0200 Subject: [PATCH 036/247] update libsodium to 1.0.16 & fix undefined SIZE_MAX --- app/src/main/jni/build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/jni/build.sh b/app/src/main/jni/build.sh index 5c652eba445..a5cc9f92217 100755 --- a/app/src/main/jni/build.sh +++ b/app/src/main/jni/build.sh @@ -55,11 +55,11 @@ OPENSSL_PREFIX=${JNI_PATH}/${OPENSSL}/${OPENSSL_SOURCE_FOLDER} OPENSSL_SHA1="577585f5f5d299c44dd3c993d3c0ac7a219e4949" SODIUM=sodium -SODIUM_VERSION=1.0.10 +SODIUM_VERSION=1.0.16 SODIUM_SOURCE_FILE=libsodium-${SODIUM_VERSION}.tar.gz SODIUM_SOURCE_FOLDER=libsodium-${SODIUM_VERSION} -SODIUM_DOWNLOAD_URL=https://download.libsodium.org/libsodium/releases/old/${SODIUM_SOURCE_FILE} -SODIUM_SHA1="f34f78330cf1a4f69acce5f3fc2ada2d4098c7f4" +SODIUM_DOWNLOAD_URL=https://download.libsodium.org/libsodium/releases/${SODIUM_SOURCE_FILE} +SODIUM_SHA1="c7ea321d7b8534e51c5e3d86055f6c1aa1e48ee9" LIBUV=libuv LIBUV_VERSION=1.8.0 @@ -268,6 +268,7 @@ if [ ! -f ${SODIUM}/${SODIUM_SOURCE_FILE}.ready ]; then pushd ${SODIUM}/${SODIUM} &>> ${LOG_FILE} export ANDROID_NDK_HOME=${NDK_ROOT} ./autogen.sh &>> ${LOG_FILE} + echo "#include " >> src/libsodium/include/sodium/export.h sed -i 's/enable-minimal/enable-minimal --disable-pie/g' dist-build/android-build.sh echo "* Prebuilding libsodium for ARM" dist-build/android-arm.sh &>> ${LOG_FILE} From 7f98d183811b18d933c43c88dd989cbed2698790 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 27 Aug 2018 13:24:25 +0200 Subject: [PATCH 037/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 10 +- .../lollipop/megachat/calls/CallService.java | 3 +- .../megachat/calls/ChatCallActivity.java | 17 +- .../megachat/calls/MegaSurfaceRenderer.java | 61 +------ .../chatAdapters/GroupCallAdapter.java | 154 +++++++----------- 5 files changed, 80 insertions(+), 165 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 247042dbdb2..a07a1dcfc14 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -4,6 +4,8 @@ import android.graphics.Bitmap; import android.util.Log; import android.view.SurfaceHolder; +import android.widget.RelativeLayout; + import java.nio.ByteBuffer; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Util; @@ -49,8 +51,12 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = holder.localRenderer.CreateBitmap(width, height); - holder.widthX = width; - holder.heightX = height; +// holder.widthX = width; +// holder.heightX = height; +// log("#### width("+width+"), height("+height+")"); +// RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); +// lp.setMargins(50, 100, 0, 0); +// holder.microSurface.setLayoutParams(lp); Sholder.setFixedSize(holderWidth, holderHeight); } else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 1cfe6eaac45..339259ed8ec 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -187,8 +187,7 @@ public Bitmap setProfileContactAvatar(long userHandle, String fullName, String } private Bitmap getCircleBitmap(Bitmap bitmap) { - final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), - bitmap.getHeight(), Bitmap.Config.ARGB_8888); + final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final int color = Color.RED; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 5705b9ae58e..1214f9b2868 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -651,7 +651,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - log("1- Incoming call"); + log("Incoming call"); ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); @@ -683,7 +683,7 @@ protected void onCreate(Bundle savedInstanceState) { for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - log("1- Incoming call: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); + log("Incoming call: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); @@ -729,15 +729,14 @@ protected void onCreate(Bundle savedInstanceState) { if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - } - else { + }else { thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); thePlayer.setLooping(true); thePlayer.start(); } if(chat.isGroup()){ - log("2 Outgoing call"); + log("Outgoing call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -1325,7 +1324,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateSubTitle(); //contact joined the group call - log("5- Session Status: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); + log("Session Status: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); @@ -1347,7 +1346,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); for(int i=0;i left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); - dstRect.top += decreaseASide; - dstRect.bottom -= decreaseASide; -// Log.d("&&","&& DESPUES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); - + dstRect.top += decrease / 2; + dstRect.bottom -= decrease / 2; dstRectf = new RectF(dstRect); } else { - float newWidth = dstRect.height() * srcaspectratio; -// Log.d("&&","&& newWidth = dstRect.height("+dstRect.height()+") * srcaspectratio("+srcaspectratio+") = "+newWidth); - float decrease = dstRect.width() - newWidth; -// Log.d("&&","&& decrease = dstRect.width()("+dstRect.width()+") - newWidth("+newWidth+") = "+decrease); - float decreaseASide = decrease/2; - -// Log.d("&&","&& decreaseASide = "+decreaseASide); - -// Log.d("&&","&& ANTES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); - dstRect.left += (-1)*decreaseASide; - dstRect.right -= (newWidth - decreaseASide); - -// Log.d("&&","&& DESPUES -> left("+dstRect.left+" ---> "+dstRect.right+")right, top("+dstRect.top+" ---> "+dstRect.bottom+")bottom"); - + dstRect.left += decrease / 2; + dstRect.right -= decrease / 2; dstRectf = new RectF(dstRect); } } @@ -134,30 +109,6 @@ private void adjustAspectRatio() { } -// private void adjustAspectRatio() { -// if (bitmap != null && dstRect.height() != 0) { -// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); -// float dstaspectratio = (float) dstRect.width() / dstRect.height(); -// -// if (srcaspectratio != 0 && dstaspectratio != 0) { -// if (srcaspectratio > dstaspectratio) { -// float newHeight = dstRect.width() / srcaspectratio; -// float decrease = dstRect.height() - newHeight; -// dstRect.top += decrease / 2; -// dstRect.bottom -= decrease / 2; -// dstRectf = new RectF(dstRect); -// } else { -// float newWidth = dstRect.height() * srcaspectratio; -// float decrease = dstRect.width() - newWidth; -// dstRect.left += decrease / 2; -// dstRect.right -= decrease / 2; -// dstRectf = new RectF(dstRect); -// } -// } -// } -// } - - public void surfaceCreated(SurfaceHolder holder) { Canvas canvas = surfaceHolder.lockCanvas(); @@ -278,8 +229,8 @@ public void DrawBitmap(boolean flag) { Canvas canvas = surfaceHolder.lockCanvas(); if (canvas != null) { canvas.scale(-1, 1); - canvas.translate(-dstRect.width(), 0); - +// canvas.translate(-dstRect.width(), 0); + canvas.translate(-canvas.getWidth(), 0); if (flag) { paint.reset(); paint.setXfermode(modesrcover); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 77c91b86944..31fc1e29d8a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -137,13 +137,11 @@ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ TextView avatarInitialLetter; RelativeLayout surfaceViewLayout; ImageView microAvatar; - ImageView microSurface; + public ImageView microSurface; public SurfaceView surfaceView; public MegaSurfaceRenderer localRenderer; SurfaceHolder localSurfaceHolder; - public int widthX, heightX = 0; - public ViewHolderGroupCall(View itemView) { super(itemView); } @@ -247,119 +245,72 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } - if(peer.isVideoOn()) { log("Video ON"); holder.microAvatar.setVisibility(View.GONE); holder.avatarLayout.setVisibility(GONE); - holder.surfaceViewLayout.setVisibility(View.VISIBLE); - log("1-Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); - holder.surfaceViewLayout.removeView(holder.surfaceView); - holder.surfaceViewLayout.removeView(holder.microSurface); - if(holder.surfaceViewLayout.getChildCount() == 0){ - log("Video ON --> Create New SurfaceView"); - holder.surfaceView = new SurfaceView(context); - holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - holder.surfaceView.setZOrderMediaOverlay(true); -// SurfaceHolder localSurfaceHolder = holder.surfaceView.getHolder(); - holder.localSurfaceHolder = holder.surfaceView.getHolder(); - - holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); - holder.surfaceViewLayout.addView(holder.surfaceView); - - holder.microSurface.setImageResource(R.drawable.ic_mic_off); - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); - if(peer.isAudioOn()){ - holder.microSurface.setVisibility(View.GONE); - }else{ - holder.microSurface.setVisibility(View.VISIBLE); - } -// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - log("2-Video ON-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); + //Remove before create + if(holder.surfaceViewLayout.getChildCount() != 0){ + holder.surfaceViewLayout.removeAllViewsInLayout(); + } + if(peer.getListener() != null){ + peer.setListener(null); } - if (peer.getListener() == null) { - log("Video ON-> Create new Listener "); - GroupCallListener listenerPeer = new GroupCallListener(context, holder); - peer.setListener(listenerPeer); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video ON-> addChatLocalVideoListener() "); - megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); - - } else { - log("Video ON-> addChatRemoteVideoListener()"); - megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); - } + //Create Surface View + holder.surfaceView = new SurfaceView(context); + holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); + holder.surfaceView.setZOrderMediaOverlay(true); + holder.localSurfaceHolder = holder.surfaceView.getHolder(); + holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); + holder.surfaceViewLayout.addView(holder.surfaceView); + + //Update micro icon + holder.microSurface.setImageResource(R.drawable.ic_mic_off); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); + if(peer.isAudioOn()){ + holder.microSurface.setVisibility(View.GONE); + }else{ + holder.microSurface.setVisibility(View.VISIBLE); + } + + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + holder.surfaceViewLayout.setVisibility(View.VISIBLE); -// log("###### w: "+holder.widthX+", h: "+holder.heightX); -// holder.microSurface.setImageResource(R.drawable.ic_mic_off); -// RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); -// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); -// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); -// if((holder.widthX == 0)||(holder.heightX == 0)){ -// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); -// }else{ -// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); -// } -// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); -// if(peer.isAudioOn()){ -// holder.microSurface.setVisibility(View.GONE); -// }else{ -// holder.microSurface.setVisibility(View.VISIBLE); -// } + + //Create listener + GroupCallListener listenerPeer = new GroupCallListener(context, holder); + peer.setListener(listenerPeer); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video ON-> addChatLocalVideoListener() "); + megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); + + } else { + log("Video ON-> addChatRemoteVideoListener()"); + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); } }else{ log("Video OFF"); holder.microSurface.setVisibility(View.GONE); holder.surfaceViewLayout.setVisibility(View.VISIBLE); + holder.surfaceViewLayout.setVisibility(View.GONE); + //Remove Surface View + holder.surfaceViewLayout.removeAllViewsInLayout(); -// log("***** Video OFF- > Remove SurfaceView"); - log("1-Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); - if(holder.surfaceViewLayout.getChildCount()!=0){ - holder.surfaceViewLayout.removeView(holder.surfaceView); - holder.surfaceViewLayout.removeView(holder.microSurface); - } - log("2-Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); - - -// holder.surfaceViewLayout.removeView(holder.surfaceView); - // holder.localRenderer.surfaceDestroyed(holder.localSurfaceHolder); - -// log("Video OFF-> surfaceViewLayout child: "+holder.surfaceViewLayout.getChildCount()); -// if(holder.surfaceViewLayout.getChildCount() != 0){ -// log("Video OFF- > SurfaceLayout != 0 -----> Remove SurfaceView "); -// holder.surfaceViewLayout.removeAllViewsInLayout(); -// }else{ -// log("Video OFF- > SurfaceLayout == 0 -----> NADA "); -// } - - if(peer.getListener()!=null){ - log("Video OFF-> Remove Listener"); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video OFF-> removeChatMyVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); - peer.setListener(null); - }else{ - log("Video OFF-> removeChatVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); - peer.setListener(null); - } - } - + //Create the avatar if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video OFF-> my Avatar"); setProfileMyAvatar(holder); }else{ - log("Video OFF-> contact Avatar"); setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } + //Update micro icon if(peer.isAudioOn()){ holder.microAvatar.setVisibility(View.GONE); }else{ @@ -367,7 +318,17 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } holder.avatarLayout.setVisibility(View.VISIBLE); - holder.surfaceViewLayout.setVisibility(View.GONE); + + //Remove listener + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video OFF-> removeChatMyVideoListener()"); + megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); + peer.setListener(null); + }else{ + log("Video OFF-> removeChatVideoListener()"); + megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); + peer.setListener(null); + } } } @@ -629,5 +590,4 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } - } From 628cdc274d09ea2dcbcb77b9f067e9f1a49f753d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 27 Aug 2018 14:47:49 +0200 Subject: [PATCH 038/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 15 +++--- .../megachat/calls/ChatCallActivity.java | 52 ++++++++++--------- .../megachat/calls/MegaSurfaceRenderer.java | 21 +++++++- .../chatAdapters/GroupCallAdapter.java | 20 +++++-- 4 files changed, 70 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index a07a1dcfc14..d0893fd4e13 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -51,12 +51,15 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = holder.localRenderer.CreateBitmap(width, height); -// holder.widthX = width; -// holder.heightX = height; -// log("#### width("+width+"), height("+height+")"); -// RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); -// lp.setMargins(50, 100, 0, 0); -// holder.microSurface.setLayoutParams(lp); + + int marginTop = 50 + ((int)holder.localRenderer.getTopR()); + int marginRight = 50 + (viewWidth - (int)holder.localRenderer.getRightR()); + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); + lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); + lp.setMargins(0, marginTop, marginRight, 0); + holder.microSurface.setLayoutParams(lp); + Sholder.setFixedSize(holderWidth, holderHeight); } else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1214f9b2868..419d0875a1c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -653,21 +653,22 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); - MyRingerTask myRingerTask = new MyRingerTask(); - ringerTimer.schedule(myRingerTask, 0, 500); - - - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] pattern = {0, 1000, 500, 500, 1000}; - if (vibrator != null){ - if (vibrator.hasVibrator()){ - //FOR API>=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } + //*********** DESCOMENTAR ************ + +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -723,17 +724,18 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ + //*********** DESCOMENTAR ************ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("Outgoing call"); @@ -745,7 +747,7 @@ protected void onCreate(Bundle savedInstanceState) { peersOnCall.clear(); - log("2- Outgoing call: Add : "+megaChatApi.getMyFullname()+" my peer "); + log("Outgoing call: Add : "+megaChatApi.getMyFullname()+" my peer "); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 34b968a7723..43e769b3033 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -56,6 +56,9 @@ public class MegaSurfaceRenderer implements Callback { PorterDuffXfermode modesrcin; int surfaceWidth = 0; int surfaceHeight = 0; + + float rightR = 0; + float topR = 0; // SurfaceView surf; @@ -86,6 +89,7 @@ private void changeDestRect(int dstWidth, int dstHeight) { } private void adjustAspectRatio() { + if (bitmap != null && dstRect.height() != 0) { float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); float dstaspectratio = (float) dstRect.width() / dstRect.height(); @@ -96,12 +100,16 @@ private void adjustAspectRatio() { float decrease = dstRect.height() - newHeight; dstRect.top += decrease / 2; dstRect.bottom -= decrease / 2; + rightR = dstRect.right; + topR = dstRect.top; dstRectf = new RectF(dstRect); } else { float newWidth = dstRect.height() * srcaspectratio; float decrease = dstRect.width() - newWidth; dstRect.left += decrease / 2; dstRect.right -= decrease / 2; + rightR = dstRect.right; + topR = dstRect.top; dstRectf = new RectF(dstRect); } } @@ -111,6 +119,8 @@ private void adjustAspectRatio() { public void surfaceCreated(SurfaceHolder holder) { + Log.d("MegaSurfaceRenderer","surfaceCreated()"); + Canvas canvas = surfaceHolder.lockCanvas(); if(canvas != null) { Rect dst = surfaceHolder.getSurfaceFrame(); @@ -219,6 +229,7 @@ public void DrawByteBuffer() { } public void DrawBitmap(boolean flag) { + if(bitmap == null) return; @@ -265,7 +276,13 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { return output; } - public Bitmap getBitmap(){ - return bitmap; + public float getRightR() { + return rightR; } + + public float getTopR() { + return topR; + } + + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 31fc1e29d8a..5933d89b529 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -270,19 +270,29 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ //Update micro icon holder.microSurface.setImageResource(R.drawable.ic_mic_off); - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ holder.microSurface.setVisibility(View.VISIBLE); } - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + holder.surfaceViewLayout.addView(holder.microSurface); holder.surfaceViewLayout.setVisibility(View.VISIBLE); +// holder.microSurface.setImageResource(R.drawable.ic_mic_off); +// RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); +// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); +// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); +// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); +// if(peer.isAudioOn()){ +// holder.microSurface.setVisibility(View.GONE); +// }else{ +// holder.microSurface.setVisibility(View.VISIBLE); +// } +// +// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); +// holder.surfaceViewLayout.setVisibility(View.VISIBLE); + //Create listener GroupCallListener listenerPeer = new GroupCallListener(context, holder); From 199acb1ec21d1094cbca01a419a065eeb64f7c77 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 28 Aug 2018 11:27:12 +0200 Subject: [PATCH 039/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 19 ++++-- .../megachat/calls/ChatCallActivity.java | 66 +++++++++++-------- .../megachat/calls/MegaSurfaceRenderer.java | 7 +- .../chatAdapters/GroupCallAdapter.java | 11 ++-- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index d0893fd4e13..1de978184d4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -7,6 +7,8 @@ import android.widget.RelativeLayout; import java.nio.ByteBuffer; + +import mega.privacy.android.app.R; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaChatApiJava; @@ -47,6 +49,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei int holderWidth = viewWidth < width ? viewWidth : width; int holderHeight = holderWidth * viewHeight / viewWidth; if (holderHeight > viewHeight) { + holderHeight = viewHeight; holderWidth = holderHeight * viewWidth / viewHeight; } @@ -54,15 +57,17 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei int marginTop = 50 + ((int)holder.localRenderer.getTopR()); int marginRight = 50 + (viewWidth - (int)holder.localRenderer.getRightR()); - RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); - lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); - lp.setMargins(0, marginTop, marginRight, 0); - holder.microSurface.setLayoutParams(lp); + + holder.surfaceViewLayout.removeViewInLayout(holder.microSurface); + holder.microSurface.setImageResource(R.drawable.ic_mic_off); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, marginTop, marginRight, 0); + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); Sholder.setFixedSize(holderWidth, holderHeight); - } - else{ + }else{ this.width = -1; this.height = -1; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 419d0875a1c..f0235c2b21c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -653,22 +653,20 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ log("Incoming call"); - //*********** DESCOMENTAR ************ - -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -724,18 +722,17 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ - //*********** DESCOMENTAR ************ -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("Outgoing call"); @@ -1290,12 +1287,25 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("Terminating call of chat: "+chatId); if(chat.isGroup()){ - long userHandle = call.getPeerSessionStatusChange(); - log(userHandle+": finished the participation on the call"); + stopAudioSignals(); + rtcAudioManager.stop(); + MegaApplication.activityPaused(); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + super.finishAndRemoveTask(); + } + else { + super.finish(); + } } break; } + case MegaChatCall.CALL_STATUS_USER_NO_PRESENT:{ + log("CALL_STATUS_USER_NO_PRESENT"); + + break; + } case MegaChatCall.CALL_STATUS_DESTROYED:{ log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); //The group call has finished so I can not join again diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 43e769b3033..d47dcee1445 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -277,11 +277,14 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { } public float getRightR() { - return rightR; + return dstRectf.right; + } + public float getLeftR() { + return dstRectf.left; } public float getTopR() { - return topR; + return dstRectf.top; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 5933d89b529..748f2277e24 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -135,11 +135,12 @@ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ RelativeLayout avatarLayout; RoundedImageView avatarImage; TextView avatarInitialLetter; - RelativeLayout surfaceViewLayout; + public RelativeLayout surfaceViewLayout; ImageView microAvatar; public ImageView microSurface; public SurfaceView surfaceView; public MegaSurfaceRenderer localRenderer; + SurfaceHolder localSurfaceHolder; public ViewHolderGroupCall(View itemView) { @@ -269,14 +270,14 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.addView(holder.surfaceView); //Update micro icon - holder.microSurface.setImageResource(R.drawable.ic_mic_off); +// holder.microSurface.setImageResource(R.drawable.ic_mic_off); if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ holder.microSurface.setVisibility(View.VISIBLE); } - holder.surfaceViewLayout.addView(holder.microSurface); +// holder.surfaceViewLayout.addView(holder.microSurface); holder.surfaceViewLayout.setVisibility(View.VISIBLE); // holder.microSurface.setImageResource(R.drawable.ic_mic_off); @@ -309,10 +310,10 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ }else{ log("Video OFF"); holder.microSurface.setVisibility(View.GONE); - holder.surfaceViewLayout.setVisibility(View.VISIBLE); - holder.surfaceViewLayout.setVisibility(View.GONE); + //Remove Surface View holder.surfaceViewLayout.removeAllViewsInLayout(); + holder.surfaceViewLayout.setVisibility(View.GONE); //Create the avatar if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { From 84a39d9f898aa1eec5ea60d28bc337ac062abc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Tue, 28 Aug 2018 12:57:33 +0200 Subject: [PATCH 040/247] Add new video capture function with parameters --- .../privacy/android/app/MegaApplication.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index 4a512958762..64350b26f16 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -547,6 +547,32 @@ static public void startVideoCapture(long nativeAndroidVideoTrackSource, Surface videoCapturer.startCapture(videoWidth, videoHeight, videoFps); } + static public void startVideoCaptureWithParameters(int videoWidth, int videoHeight, int videoFps, long nativeAndroidVideoTrackSource, SurfaceTextureHelper surfaceTextureHelper) { + // Settings + boolean useCamera2 = false; + boolean captureToTexture = true; + + stopVideoCapture(); + Context context = ContextUtils.getApplicationContext(); + if (Camera2Enumerator.isSupported(context) && useCamera2) { + videoCapturer = createCameraCapturer(new Camera2Enumerator(context)); + } else { + videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTexture)); + } + + if (videoCapturer == null) { + log("Unable to create video capturer"); + return; + } + + // Link the capturer with the surfaceTextureHelper and the native video source + VideoCapturer.CapturerObserver capturerObserver = new AndroidVideoTrackSourceObserver(nativeAndroidVideoTrackSource); + videoCapturer.initialize(surfaceTextureHelper, context, capturerObserver); + + // Start the capture! + videoCapturer.startCapture(videoWidth, videoHeight, videoFps); + } + // private void initializeGA(){ // // Set the log level to verbose. // GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE); From b56668ece6b840857af0095de6303fa43c91d6d9 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 28 Aug 2018 13:05:30 +0200 Subject: [PATCH 041/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 1 - .../megachat/calls/ChatCallActivity.java | 43 +++++++++++++------ .../chatAdapters/GroupCallAdapter.java | 3 +- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 1de978184d4..3258c2b6550 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -59,7 +59,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei int marginRight = 50 + (viewWidth - (int)holder.localRenderer.getRightR()); holder.surfaceViewLayout.removeViewInLayout(holder.microSurface); - holder.microSurface.setImageResource(R.drawable.ic_mic_off); RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f0235c2b21c..38b5780e987 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -297,8 +297,8 @@ public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress"); if(chat.isGroup()){ - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width = RelativeLayout.LayoutParams.WRAP_CONTENT; } else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -317,12 +317,6 @@ public void updateScreenStatusInProgress(){ startClock(); } - public void updateNumberOfPeers(){ - if(chat.isGroup()){ - int totalParticipants = callChat.getNumParticipants(); - //redesign of screens: - } - } public void updateSubTitle(){ log("updateSubTitle"); @@ -723,7 +717,6 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -1248,13 +1241,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { int callStatus = callChat.getStatus(); switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ - log("4 CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS"); if(chat.isGroup()){ if(call.isIncoming()){ log("incoming call"); peersBeforeCall.clear(); - log("4 IN_PROGRESS - Add : "+megaChatApi.getMyFullname()+" my peer "); + log("IN_PROGRESS-Incoming - Add : "+megaChatApi.getMyFullname()+" my peer "); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); @@ -1267,6 +1260,32 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); + }else{ + + peersBeforeCall.clear(); + boolean iAm = false; + for(int i=0;i 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + recyclerView.setAdapter(adapter); + } } } @@ -1308,7 +1327,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } case MegaChatCall.CALL_STATUS_DESTROYED:{ log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); - //The group call has finished so I can not join again + //The group call has finished but I can not join again stopAudioSignals(); rtcAudioManager.stop(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 748f2277e24..ef479fe9b66 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -270,7 +270,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.addView(holder.surfaceView); //Update micro icon -// holder.microSurface.setImageResource(R.drawable.ic_mic_off); + holder.microSurface.setImageResource(R.drawable.ic_mic_off); if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ @@ -292,7 +292,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ // } // // holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); -// holder.surfaceViewLayout.setVisibility(View.VISIBLE); //Create listener From 37531c8eb0dabf87d55590bfcc92edc94c4d9285 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 28 Aug 2018 14:29:51 +0200 Subject: [PATCH 042/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 106 +++++++++++------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 38b5780e987..946c5336e00 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -299,20 +299,21 @@ public void updateScreenStatusInProgress(){ if(chat.isGroup()){ relativeVideo.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width = RelativeLayout.LayoutParams.WRAP_CONTENT; - } - else{ + + }else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; flagMyAvatar = false; setProfileMyAvatar(); flagContactAvatar = true; setProfileContactAvatar(); - updateLocalVideoStatus(); - updateLocalAudioStatus(); - updateRemoteAudioStatus(-1); - updateRemoteVideoStatus(-1); } + updateLocalVideoStatus(); + updateLocalAudioStatus(); + updateRemoteAudioStatus(-1); + updateRemoteVideoStatus(-1); + stopAudioSignals(); startClock(); } @@ -645,8 +646,6 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - log("Incoming call"); - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -663,6 +662,8 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ + log("Incoming call - group"); + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); @@ -699,6 +700,8 @@ protected void onCreate(Bundle savedInstanceState) { } }else{ + log("Incoming call - individual "); + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); @@ -728,7 +731,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Outgoing call"); + log("Outgoing call - group"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -756,8 +759,9 @@ protected void onCreate(Bundle savedInstanceState) { }else{ recyclerView.setVisibility(View.VISIBLE); } - }else{ + log("Outgoing call - individual"); + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); @@ -767,10 +771,9 @@ protected void onCreate(Bundle savedInstanceState) { flagContactAvatar = true; setProfileContactAvatar(); myAvatarLayout.setVisibility(View.VISIBLE); - } -// updateLocalVideoStatus(); -// updateLocalAudioStatus(); + updateLocalVideoStatus(); + updateLocalAudioStatus(); } } } @@ -1175,6 +1178,7 @@ else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ log("Ok answer with NO video - "); // updateLocalVideoStatus(); } + updateLocalVideoStatus(); } else{ @@ -1287,6 +1291,22 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { recyclerView.setAdapter(adapter); } } + }else{ + flagMyAvatar = true; + setProfileMyAvatar(); + flagContactAvatar = false; + setProfileContactAvatar(); + if (localCameraFragmentFS != null) { + localCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(localCameraFragmentFS); + localCameraFragmentFS = null; + contactAvatarLayout.setVisibility(View.VISIBLE); + parentLocalFS.setVisibility(View.GONE); + fragmentContainerLocalCameraFS.setVisibility(View.GONE); + } + updateLocalVideoStatus(); + updateRemoteVideoStatus(-1); } videoFAB.setOnClickListener(null); @@ -1394,6 +1414,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } + updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); updateLocalVideoStatus(); @@ -1404,6 +1425,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ updateSubTitle(); } + updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); updateLocalVideoStatus(); @@ -1895,7 +1917,10 @@ public void updateLocalVideoStatus(){ videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + log("callStatus: CALL_STATUS_REQUEST_SENT"); + if(localCameraFragmentFS == null){ + log("CREATE localCameraFragmentFS"); localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); @@ -1905,14 +1930,16 @@ public void updateLocalVideoStatus(){ parentLocalFS.setVisibility(View.VISIBLE); fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); - }else{ + }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("callStatus: CALL_STATUS_IN_PROGRESS"); + if(localCameraFragment == null){ + log("CREATE localCameraFragment"); localCameraFragment = LocalCameraCallFragment.newInstance(chatId); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); ft.commitNowAllowingStateLoss(); } - myAvatarLayout.setVisibility(GONE); parentLocal.setVisibility(View.VISIBLE); fragmentContainerLocalCamera.setVisibility(View.VISIBLE); @@ -1924,29 +1951,32 @@ public void updateLocalVideoStatus(){ videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ + log("callStatus: CALL_STATUS_REQUEST_SENT"); if (localCameraFragmentFS != null) { + log("REMOVE localCameraFragmentFS"); localCameraFragmentFS.setVideoFrame(false); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); localCameraFragmentFS = null; - } - contactAvatarLayout.setVisibility(View.VISIBLE); parentLocalFS.setVisibility(View.GONE); fragmentContainerLocalCameraFS.setVisibility(View.GONE); + contactAvatarLayout.setVisibility(View.VISIBLE); - }else{ + }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("callStatus: CALL_STATUS_IN_PROGRESS"); if (localCameraFragment != null) { + log("REMOVE localCameraFragment"); localCameraFragment.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(localCameraFragment); localCameraFragment = null; } - myAvatarLayout.setVisibility(View.VISIBLE); parentLocal.setVisibility(View.GONE); fragmentContainerLocalCamera.setVisibility(View.GONE); + myAvatarLayout.setVisibility(View.VISIBLE); } } } @@ -2035,6 +2065,8 @@ public void updateRemoteVideoStatus(long userHandle){ } } else{ + log("is individual"); + MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ @@ -2042,29 +2074,25 @@ public void updateRemoteVideoStatus(long userHandle){ if(userSession!=null && userSession.hasVideo()){ log("Video remote connected"); isRemoteVideo = REMOTE_VIDEO_ENABLED; - if (contactAvatarLayout.getVisibility() == View.VISIBLE) { - if(remoteCameraFragmentFS == null){ - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); - } - contactAvatarLayout.setOnClickListener(null); - contactAvatarLayout.setVisibility(GONE); - parentRemoteFS.setVisibility(View.VISIBLE); - fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); - - } else { - log("No needed to refresh"); + if(remoteCameraFragmentFS == null){ + log("CREATE remoteCameraFragmentFS"); + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); } + contactAvatarLayout.setOnClickListener(null); + contactAvatarLayout.setVisibility(GONE); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); }else{ log("Video remote NOT connected"); isRemoteVideo = REMOTE_VIDEO_DISABLED; - if (remoteCameraFragmentFS != null) { + log("REMOVE remoteCameraFragmentFS"); remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); @@ -2077,10 +2105,10 @@ public void updateRemoteVideoStatus(long userHandle){ } }else{ if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ - isRemoteVideo = REMOTE_VIDEO_DISABLED; if (remoteCameraFragmentFS != null) { + log("REMOVE remoteCameraFragmentFS"); remoteCameraFragmentFS.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); @@ -2092,26 +2120,20 @@ public void updateRemoteVideoStatus(long userHandle){ fragmentContainerRemoteCameraFS.setVisibility(View.GONE); }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ - isRemoteVideo = REMOTE_VIDEO_ENABLED; - if (contactAvatarLayout.getVisibility() == View.VISIBLE) { if(remoteCameraFragmentFS == null){ + log("CREATE remoteCameraFragmentFS"); remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); ft.commitNowAllowingStateLoss(); } - - contactAvatarLayout.setOnClickListener(null); contactAvatarLayout.setVisibility(GONE); parentRemoteFS.setVisibility(View.VISIBLE); fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); - } else { - log("No needed to refresh"); - } } } } From f7654137126a4461c913a6b682cfe36e5b43c3d6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 29 Aug 2018 11:17:39 +0200 Subject: [PATCH 043/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 12 +- .../lollipop/megachat/calls/CallService.java | 3 + .../megachat/calls/ChatCallActivity.java | 11 +- .../megachat/calls/MegaSurfaceRenderer.java | 29 +- .../calls/MegaSurfaceRendererGroup.java | 301 ++++++++++++++++++ .../chatAdapters/GroupCallAdapter.java | 111 +++---- .../res/layout/item_camera_group_call.xml | 8 - 7 files changed, 377 insertions(+), 98 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 3258c2b6550..47831ddc725 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -40,6 +40,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.width = width; this.height = height; + SurfaceHolder Sholder = holder.surfaceView.getHolder(); if (Sholder != null) { int viewWidth = holder.surfaceView.getWidth(); @@ -54,17 +55,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = holder.localRenderer.CreateBitmap(width, height); - - int marginTop = 50 + ((int)holder.localRenderer.getTopR()); - int marginRight = 50 + (viewWidth - (int)holder.localRenderer.getRightR()); - - holder.surfaceViewLayout.removeViewInLayout(holder.microSurface); - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, marginTop, marginRight, 0); - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - Sholder.setFixedSize(holderWidth, holderHeight); }else{ this.width = -1; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 339259ed8ec..4b056a01f5e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -162,6 +162,9 @@ public Bitmap setProfileContactAvatar(long userHandle, String fullName, String avatar = new File(context.getCacheDir().getAbsolutePath(), email + ".jpg"); } +// return createDefaultAvatar(userHandle, fullName); + + if (avatar.exists()) { if (avatar.length() > 0) { BitmapFactory.Options bOpts = new BitmapFactory.Options(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 946c5336e00..4cc09200ae4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -646,6 +646,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -662,7 +663,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Incoming call - group"); + log("Incoming group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -700,7 +701,7 @@ protected void onCreate(Bundle savedInstanceState) { } }else{ - log("Incoming call - individual "); + log("Incoming individual call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -731,7 +732,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Outgoing call - group"); + log("Outgoing group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -760,7 +761,7 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setVisibility(View.VISIBLE); } }else{ - log("Outgoing call - individual"); + log("Outgoing individual call"); relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -1290,6 +1291,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); recyclerView.setAdapter(adapter); } + updateLocalVideoStatus(); + } }else{ flagMyAvatar = true; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index d47dcee1445..96c6b0769f9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -57,10 +57,6 @@ public class MegaSurfaceRenderer implements Callback { int surfaceWidth = 0; int surfaceHeight = 0; - float rightR = 0; - float topR = 0; -// SurfaceView surf; - public MegaSurfaceRenderer(SurfaceView view) { Log.d("MegaSurfaceRenderer","MegaSurfaceRenderer() "); @@ -78,7 +74,8 @@ public MegaSurfaceRenderer(SurfaceView view) { // surfaceChanged and surfaceCreated share this function private void changeDestRect(int dstWidth, int dstHeight) { Log.d("MegaSurfaceRenderer","changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); - + surfaceWidth = dstWidth; + surfaceHeight = dstHeight; dstRect.top = 0; dstRect.left = 0; dstRect.right = dstWidth; @@ -91,6 +88,12 @@ private void changeDestRect(int dstWidth, int dstHeight) { private void adjustAspectRatio() { if (bitmap != null && dstRect.height() != 0) { + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = surfaceWidth; + dstRect.bottom = surfaceHeight; + + dstRectf = new RectF(dstRect); float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); float dstaspectratio = (float) dstRect.width() / dstRect.height(); @@ -100,16 +103,12 @@ private void adjustAspectRatio() { float decrease = dstRect.height() - newHeight; dstRect.top += decrease / 2; dstRect.bottom -= decrease / 2; - rightR = dstRect.right; - topR = dstRect.top; dstRectf = new RectF(dstRect); } else { float newWidth = dstRect.height() * srcaspectratio; float decrease = dstRect.width() - newWidth; dstRect.left += decrease / 2; dstRect.right -= decrease / 2; - rightR = dstRect.right; - topR = dstRect.top; dstRectf = new RectF(dstRect); } } @@ -276,16 +275,4 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { return output; } - public float getRightR() { - return dstRectf.right; - } - public float getLeftR() { - return dstRectf.left; - } - - public float getTopR() { - return dstRectf.top; - } - - } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java new file mode 100644 index 00000000000..de325dbaa4f --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -0,0 +1,301 @@ +package mega.privacy.android.app.lollipop.megachat.calls; +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; + +import org.webrtc.Logging; + +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + +// The following four imports are needed saveBitmapToJPEG which +// is for debug only +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.util.Log; +import android.util.TypedValue; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.SurfaceHolder.Callback; + +import org.webrtc.Logging; + +import mega.privacy.android.app.R; + +public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { + + private final static String TAG = "WEBRTC"; + + // the bitmap used for drawing. + private Bitmap bitmap = null; + private ByteBuffer byteBuffer = null; + private SurfaceHolder surfaceHolder; + // Rect of the source bitmap to draw + private Rect srcRect = new Rect(); + // Rect of the destination canvas to draw to + private Rect dstRect = new Rect(); + private RectF dstRectf = new RectF(); + Paint paint; + PorterDuffXfermode modesrcover; + PorterDuffXfermode modesrcin; + int surfaceWidth = 0; + int surfaceHeight = 0; + + + public MegaSurfaceRendererGroup(SurfaceView view) { + Log.d("MegaSurfaceRenderer","MegaSurfaceRenderer() "); + +// this.surf = view; + surfaceHolder = view.getHolder(); + if(surfaceHolder == null) + return; + surfaceHolder.addCallback(this); + paint = new Paint(); + modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); + modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); + } + + // surfaceChanged and surfaceCreated share this function + private void changeDestRect(int dstWidth, int dstHeight) { + Log.d("SurfaceRendererGroup","changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); + surfaceWidth = dstWidth; + surfaceHeight = dstHeight; + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = dstWidth; + dstRect.bottom = dstHeight; + dstRectf = new RectF(dstRect); + + adjustAspectRatio(); + } + + private void adjustAspectRatio() { + + if (bitmap != null && dstRect.height() != 0) { + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = surfaceWidth; + dstRect.bottom = surfaceHeight; + + dstRectf = new RectF(dstRect); + float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); + float dstaspectratio = (float) dstRect.width() / dstRect.height(); + + if (srcaspectratio != 0 && dstaspectratio != 0) { + if (srcaspectratio > dstaspectratio) { + float newHeight = dstRect.width() / srcaspectratio; + float decrease = dstRect.height() - newHeight; +// dstRect.top += decrease / 2; +// dstRect.bottom -= decrease / 2; +// surfaceHolder.setFixedSize(surfaceWidth,surfaceHeight); + dstRectf = new RectF(dstRect); + } else { + float newWidth = dstRect.height() * srcaspectratio; + float decrease = dstRect.width() - newWidth; +// dstRect.left += decrease / 2; +// dstRect.right -= decrease / 2; +// surfaceHolder.setFixedSize(surfaceWidth,surfaceHeight); + + dstRectf = new RectF(dstRect); + } + } + } + } + + + + public void surfaceCreated(SurfaceHolder holder) { + Log.d("MegaSurfaceRenderer","surfaceCreated()"); + + Canvas canvas = surfaceHolder.lockCanvas(); + if(canvas != null) { + Rect dst = surfaceHolder.getSurfaceFrame(); + if(dst != null) { + changeDestRect(dst.right - dst.left, dst.bottom - dst.top); + Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + + " dst.left:" + dst.left + + " dst.top:" + dst.top + + " dst.right:" + dst.right + + " dst.bottom:" + dst.bottom + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + } + surfaceHolder.unlockCanvasAndPost(canvas); + } + } + + public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { + Log.d("MegaSurfaceRenderer","surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); + changeDestRect(in_width, in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + + " in_width:" + in_width + " in_height:" + in_height + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + } + + public void surfaceDestroyed(SurfaceHolder holder) { + Log.d("MegaSurfaceRenderer","surfaceDestroyed(): "); + + Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); + bitmap = null; + byteBuffer = null; + } + + public Bitmap CreateBitmap(int width, int height) { + Log.d("MegaSurfaceRenderer","CreateBitmap(): width = "+width+", height = "+height); + + Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); + if (bitmap == null) { + try { + android.os.Process.setThreadPriority( + android.os.Process.THREAD_PRIORITY_DISPLAY); + } + catch (Exception e) { + } + } + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + srcRect.left = 0; + srcRect.top = 0; + srcRect.bottom = height; + srcRect.right = width; + +// adjustAspectRatio(); + + return bitmap; + } + + public ByteBuffer CreateByteBuffer(int width, int height) { + Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); + if (bitmap == null) { + bitmap = CreateBitmap(width, height); + byteBuffer = ByteBuffer.allocateDirect(width * height * 2); + } + return byteBuffer; + } + + // It saves bitmap data to a JPEG picture, this function is for debug only. + private void saveBitmapToJPEG(int width, int height) { + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); + + try{ + FileOutputStream output = new FileOutputStream(String.format( + "/sdcard/render_%d.jpg", System.currentTimeMillis())); + output.write(byteOutStream.toByteArray()); + output.flush(); + output.close(); + } + catch (FileNotFoundException e) { + } + catch (IOException e) { + } + } + + public void DrawByteBuffer() { + if(byteBuffer == null) + return; + byteBuffer.rewind(); + bitmap.copyPixelsFromBuffer(byteBuffer); + DrawBitmap(false); + } + + public void DrawBitmap(boolean flag) { + + if(bitmap == null) + return; + + if (surfaceHolder == null){ + return; + } + + Canvas canvas = surfaceHolder.lockCanvas(); + if (canvas != null) { + canvas.scale(-1, 1); +// canvas.translate(-dstRect.width(), 0); + canvas.translate(-canvas.getWidth(), 0); + if (flag) { + paint.reset(); + paint.setXfermode(modesrcover); + canvas.drawRoundRect(dstRectf, 20, 20, paint); + paint.setXfermode(modesrcin); + canvas.drawBitmap(bitmap, srcRect, dstRect, paint); + } else { + canvas.drawBitmap(bitmap, srcRect, dstRect, null); + } + + surfaceHolder.unlockCanvasAndPost(canvas); + } + } + + public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + + final Paint paint = new Paint(); + final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); + final RectF rectF = new RectF(rect); + final float roundPx = pixels; + + paint.setAntiAlias(true); + canvas.drawARGB(0, 0, 0, 0); + paint.setColor(Color.BLUE); + canvas.drawRoundRect(rectF, roundPx, roundPx, paint); + + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); + canvas.drawBitmap(bitmap, rect, rect, paint); + + return output; + } + + +} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index ef479fe9b66..a27b23d80c2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -41,7 +41,7 @@ import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; import mega.privacy.android.app.lollipop.megachat.calls.InfoPeerGroupCall; import mega.privacy.android.app.lollipop.megachat.calls.LocalCameraCallFullScreenFragment; -import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRenderer; +import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRendererGroup; import mega.privacy.android.app.lollipop.megachat.calls.RemoteCameraCallFullScreenFragment; import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; @@ -139,7 +139,7 @@ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ ImageView microAvatar; public ImageView microSurface; public SurfaceView surfaceView; - public MegaSurfaceRenderer localRenderer; + public MegaSurfaceRendererGroup localRenderer; SurfaceHolder localSurfaceHolder; @@ -173,55 +173,53 @@ public ViewHolderGroupCallGrid(View v) { maxScreenHeight = parent.getMeasuredHeight(); maxScreenWidth = parent.getMeasuredWidth(); - if (viewType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); + int numPeersOnCall = getItemCount(); - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); - int numPeersOnCall = getItemCount(); + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - if(numPeersOnCall <= 3){ + if(numPeersOnCall <= 3){ + lp.height = maxScreenHeight / numPeersOnCall; + lp.width = maxScreenWidth; - lp.height = maxScreenHeight / numPeersOnCall; - lp.width = maxScreenWidth; + }else if(numPeersOnCall == 4){ + lp.height = maxScreenHeight / 2; + lp.width = maxScreenWidth/2; - }else if(numPeersOnCall == 4){ - lp.height = maxScreenHeight / 2; - lp.width = maxScreenWidth/2; + }else if(numPeersOnCall == 5){ + lp.height = maxScreenHeight / 3; + lp.width = maxScreenWidth/2; + log("****** For 5 peers: maxWidth: "+(maxScreenWidth/2)+", maxHeight: "+(maxScreenHeight/3)); - }else if((numPeersOnCall > 4)&&(numPeersOnCall<7)){ - lp.height = maxScreenHeight / 3; - lp.width = maxScreenWidth/2; - - } + }else if((numPeersOnCall > 5)&&(numPeersOnCall<7)){ + lp.height = maxScreenHeight / 3; + lp.width = maxScreenWidth/2; + } - v.setLayoutParams(lp); + v.setLayoutParams(lp); - holderGrid = new ViewHolderGroupCallGrid(v); - holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - holderGrid.rlGeneral.setOnClickListener(this); - holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); - holderGrid.surfaceViewLayout.removeAllViewsInLayout(); + holderGrid = new ViewHolderGroupCallGrid(v); + holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); + holderGrid.rlGeneral.setOnClickListener(this); + holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); + holderGrid.surfaceViewLayout.removeAllViewsInLayout(); - holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); - holderGrid.avatarLayout.setLayoutParams(layoutParams); + holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holderGrid.avatarLayout.setLayoutParams(layoutParams); - holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); + holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); - holderGrid.microSurface = new ImageView(context); - holderGrid.microSurface.setVisibility(View.GONE); + holderGrid.microSurface = new ImageView(context); + holderGrid.microSurface.setVisibility(View.GONE); - holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); - holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); + holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); + holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - v.setTag(holderGrid); - return holderGrid; + v.setTag(holderGrid); + return holderGrid; - }else{ - return null; - - } } @Override @@ -246,6 +244,17 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } + int numPeers = getItemCount(); + if((numPeers == 5) && (peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ + log("*******onBindViewHolderGrid() 5 peers and This is me-> maxWidth: "+maxScreenWidth+", maxHeight: "+(maxScreenHeight/3)); + + ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParams.width = maxScreenWidth; + layoutParams.height = (maxScreenHeight/3); + holder.rlGeneral.setLayoutParams(layoutParams); + + } + if(peer.isVideoOn()) { log("Video ON"); holder.microAvatar.setVisibility(View.GONE); @@ -266,34 +275,25 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceView.setZOrderMediaOverlay(true); holder.localSurfaceHolder = holder.surfaceView.getHolder(); holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRenderer(holder.surfaceView); + holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView); holder.surfaceViewLayout.addView(holder.surfaceView); //Update micro icon holder.microSurface.setImageResource(R.drawable.ic_mic_off); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, 50, 50, 0); + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ holder.microSurface.setVisibility(View.VISIBLE); } -// holder.surfaceViewLayout.addView(holder.microSurface); holder.surfaceViewLayout.setVisibility(View.VISIBLE); -// holder.microSurface.setImageResource(R.drawable.ic_mic_off); -// RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); -// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); -// paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); -// paramsMicroSurface.setMargins(0, Util.scaleWidthPx(10, outMetrics), Util.scaleWidthPx(10, outMetrics), 0); -// if(peer.isAudioOn()){ -// holder.microSurface.setVisibility(View.GONE); -// }else{ -// holder.microSurface.setVisibility(View.VISIBLE); -// } -// -// holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - - //Create listener GroupCallListener listenerPeer = new GroupCallListener(context, holder); peer.setListener(listenerPeer); @@ -316,8 +316,11 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ //Create the avatar if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + holder.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileMyAvatar(holder); }else{ + holder.rlGeneral.setBackgroundColor(Color.BLUE); + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } //Update micro icon diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 0f536202f0b..96836e0b732 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,9 +4,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - - From d277669f3fd4e79954d5b20e5c0043de36d209b7 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 29 Aug 2018 12:19:28 +0200 Subject: [PATCH 044/247] Feature#9775-Group calls UI --- .../lollipop/megachat/calls/CallService.java | 3 -- .../chatAdapters/GroupCallAdapter.java | 47 +++++++++++++++---- .../res/layout/item_camera_group_call.xml | 3 +- app/src/main/res/values/attrs.xml | 1 + 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 4b056a01f5e..339259ed8ec 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -162,9 +162,6 @@ public Bitmap setProfileContactAvatar(long userHandle, String fullName, String avatar = new File(context.getCacheDir().getAbsolutePath(), email + ".jpg"); } -// return createDefaultAvatar(userHandle, fullName); - - if (avatar.exists()) { if (avatar.length() > 0) { BitmapFactory.Options bOpts = new BitmapFactory.Options(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index a27b23d80c2..07be7dd63c9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -178,7 +178,7 @@ public ViewHolderGroupCallGrid(View v) { CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - if(numPeersOnCall <= 3){ + if(numPeersOnCall < 4) { lp.height = maxScreenHeight / numPeersOnCall; lp.width = maxScreenWidth; @@ -189,7 +189,6 @@ public ViewHolderGroupCallGrid(View v) { }else if(numPeersOnCall == 5){ lp.height = maxScreenHeight / 3; lp.width = maxScreenWidth/2; - log("****** For 5 peers: maxWidth: "+(maxScreenWidth/2)+", maxHeight: "+(maxScreenHeight/3)); }else if((numPeersOnCall > 5)&&(numPeersOnCall<7)){ lp.height = maxScreenHeight / 3; @@ -201,6 +200,7 @@ public ViewHolderGroupCallGrid(View v) { holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); holderGrid.rlGeneral.setOnClickListener(this); + holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.surfaceViewLayout.removeAllViewsInLayout(); @@ -244,15 +244,44 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } - int numPeers = getItemCount(); - if((numPeers == 5) && (peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ - log("*******onBindViewHolderGrid() 5 peers and This is me-> maxWidth: "+maxScreenWidth+", maxHeight: "+(maxScreenHeight/3)); + int numPeersOnCall = getItemCount(); + + if(numPeersOnCall == 2){ + holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(20, outMetrics),0,Util.scaleWidthPx(20, outMetrics),0); + + }else if(numPeersOnCall == 3){ + holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(74, outMetrics),0,Util.scaleWidthPx(74, outMetrics),0); + + }else if(numPeersOnCall == 4){ + if((position < 2)){ + holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + }else{ + holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(144, outMetrics)); + } + + }else if(numPeersOnCall == 5){ + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParams.width = maxScreenWidth; + layoutParams.height = (maxScreenHeight/3); + holder.rlGeneral.setLayoutParams(layoutParams); + holder.rlGeneral.setPadding(Util.scaleWidthPx(90, outMetrics),0,Util.scaleWidthPx(90, outMetrics),Util.scaleWidthPx(50, outMetrics)); + }else{ + if((position < 2)){ + holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); + }else{ + holderGrid.rlGeneral.setPadding(0,0,0,0); + } + } + + }else if(numPeersOnCall == 6){ + if((position < 2)){ + holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); - ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParams.width = maxScreenWidth; - layoutParams.height = (maxScreenHeight/3); - holder.rlGeneral.setLayoutParams(layoutParams); + }else if(position > 3){ + holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(50, outMetrics)); + } } if(peer.isVideoOn()) { diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 96836e0b732..744b97814b0 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -2,7 +2,8 @@ xmlns:rounded="http://schemas.android.com/apk/res-auto" android:id="@+id/general" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/black"> + From 8a678921b28562e36b85045ca059551a40663f2c Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 29 Aug 2018 13:03:34 +0200 Subject: [PATCH 045/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 1 + .../chatAdapters/GroupCallAdapter.java | 109 +++++++++++++++--- .../res/layout/item_camera_group_call.xml | 1 + 3 files changed, 92 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 4cc09200ae4..aeed248415b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -721,6 +721,7 @@ protected void onCreate(Bundle savedInstanceState) { }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 07be7dd63c9..ac8336766e6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -245,45 +245,116 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } int numPeersOnCall = getItemCount(); - if(numPeersOnCall == 2){ - holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(20, outMetrics),0,Util.scaleWidthPx(20, outMetrics),0); + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParams.width = Util.scaleWidthPx(320, outMetrics); + layoutParams.height = Util.scaleWidthPx(320, outMetrics); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParams); }else if(numPeersOnCall == 3){ - holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(74, outMetrics),0,Util.scaleWidthPx(74, outMetrics),0); + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParams.width = Util.scaleWidthPx(212, outMetrics); + layoutParams.height = Util.scaleWidthPx(212, outMetrics); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParams); }else if(numPeersOnCall == 4){ + + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParams.width = Util.scaleWidthPx(180, outMetrics); + layoutParams.height = Util.scaleWidthPx(180, outMetrics); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + if((position < 2)){ - holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); }else{ - holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(144, outMetrics)); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } + holder.surfaceViewLayout.setLayoutParams(layoutParams); + }else if(numPeersOnCall == 5){ + + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParams.width = Util.scaleWidthPx(180, outMetrics); + layoutParams.height = Util.scaleWidthPx(180, outMetrics); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + + }else if(position > 3){ + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + + holder.surfaceViewLayout.setLayoutParams(layoutParams); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParams.width = maxScreenWidth; - layoutParams.height = (maxScreenHeight/3); - holder.rlGeneral.setLayoutParams(layoutParams); - holder.rlGeneral.setPadding(Util.scaleWidthPx(90, outMetrics),0,Util.scaleWidthPx(90, outMetrics),Util.scaleWidthPx(50, outMetrics)); - }else{ - if((position < 2)){ - holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); - }else{ - holderGrid.rlGeneral.setPadding(0,0,0,0); - } + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = (maxScreenHeight/3); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); } }else if(numPeersOnCall == 6){ + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParams.width = Util.scaleWidthPx(180, outMetrics); + layoutParams.height = Util.scaleWidthPx(180, outMetrics); + layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + if((position < 2)){ - holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); }else if(position > 3){ - holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(50, outMetrics)); - + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } + holder.surfaceViewLayout.setLayoutParams(layoutParams); + } + +// if(numPeersOnCall == 2){ +// holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(20, outMetrics),0,Util.scaleWidthPx(20, outMetrics),0); +// +// }else if(numPeersOnCall == 3){ +// holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(74, outMetrics),0,Util.scaleWidthPx(74, outMetrics),0); +// +// }else if(numPeersOnCall == 4){ +// if((position < 2)){ +// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); +// }else{ +// holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(144, outMetrics)); +// } +// +// }else if(numPeersOnCall == 5){ +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ +// ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParams.width = maxScreenWidth; +// layoutParams.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParams); +// holder.rlGeneral.setPadding(Util.scaleWidthPx(90, outMetrics),0,Util.scaleWidthPx(90, outMetrics),Util.scaleWidthPx(50, outMetrics)); +// }else{ +// if((position < 2)){ +// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); +// }else{ +// holderGrid.rlGeneral.setPadding(0,0,0,0); +// } +// } +// +// }else if(numPeersOnCall == 6){ +// if((position < 2)){ +// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); +// +// }else if(position > 3){ +// holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(50, outMetrics)); +// +// } +// } + if(peer.isVideoOn()) { log("Video ON"); holder.microAvatar.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 744b97814b0..d3592db9411 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -11,6 +11,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" + android:layout_centerInParent="true" android:background="@android:color/transparent" android:visibility="gone"> From 9a74074ec6ec8eb0e69d66629f31c2e534d87e7c Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 30 Aug 2018 10:23:57 +0200 Subject: [PATCH 046/247] Feature #9774: Management of group calls --- .../main/java/mega/privacy/android/app/MegaApplication.java | 5 +++-- .../android/app/lollipop/megachat/calls/CallService.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index 4a512958762..4297283d7ab 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -1124,7 +1124,7 @@ else if(msg.getType()==MegaChatMessage.TYPE_TRUNCATE){ @Override public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { - log("onChatCallUpdate"); + log("onChatCallUpdate: "+call.getStatus()); if (call.getStatus() == MegaChatCall.CALL_STATUS_DESTROYED) { log("Call destroyed: "+call.getTermCode()); @@ -1207,6 +1207,8 @@ public void launchCallActivity(MegaChatCall call){ log("launchCallActivity: "+call.getStatus()); MegaApplication.setShowPinScreen(false); + MegaApplication.setOpenCallChatId(call.getChatid()); + Intent i = new Intent(this, ChatCallActivity.class); i.putExtra("chatHandle", call.getChatid()); i.putExtra("callId", call.getId()); @@ -1216,7 +1218,6 @@ public void launchCallActivity(MegaChatCall call){ MegaChatRoom chatRoom = megaChatApi.getChatRoom(call.getChatid()); log("Launch call: "+chatRoom.getTitle()); - } public void clearIncomingCallNotification(long chatCallId) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 339259ed8ec..73e22ad4b1b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -82,7 +82,9 @@ public int onStartCommand(Intent intent, int flags, int startId) { log("Chat handle to call: " + chatId); } - MegaApplication.setOpenCallChatId(chatId); + if(MegaApplication.getOpenCallChatId()!=chatId){ + MegaApplication.setOpenCallChatId(chatId); + } showCallInProgressNotification(); return START_NOT_STICKY; From da155f8cac3c60b6875a9d17a9108bc288ee7a01 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 30 Aug 2018 10:45:03 +0200 Subject: [PATCH 047/247] Feature #9774: Management of group calls --- .../lollipop/megachat/calls/CallService.java | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 73e22ad4b1b..3f456a8a4c0 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -133,14 +133,26 @@ public void showCallInProgressNotification(){ MegaChatRoom chat = megaChatApi.getChatRoom(chatId); if(chat!=null){ title = chat.getTitle(); - userHandle = chat.getPeerHandle(0); - email = chat.getPeerEmail(0); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - Bitmap largeIcon = setProfileContactAvatar(userHandle, title, email); - if(largeIcon!=null){ - mBuilderCompat.setLargeIcon(largeIcon); + + if(chat.isGroup()){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + Bitmap largeIcon = createDefaultAvatar(-1, title); + if(largeIcon!=null){ + mBuilderCompat.setLargeIcon(largeIcon); + } } } + else{ + userHandle = chat.getPeerHandle(0); + email = chat.getPeerEmail(0); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + Bitmap largeIcon = setProfileContactAvatar(userHandle, title, email); + if(largeIcon!=null){ + mBuilderCompat.setLargeIcon(largeIcon); + } + } + } + mBuilderCompat.setContentTitle(title); mBuilderCompat.setContentText(getString(R.string.title_notification_call_in_progress)); } @@ -218,13 +230,18 @@ public Bitmap createDefaultAvatar(long userHandle, String fullName){ Paint paintText = new Paint(); Paint paintCircle = new Paint(); - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if (color != null) { - log("The color to set the avatar is " + color); - paintCircle.setColor(Color.parseColor(color)); - } else { - log("Default color to the avatar"); - paintCircle.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + if(userHandle!=-1){ + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + log("The color to set the avatar is " + color); + paintCircle.setColor(Color.parseColor(color)); + } else { + log("Default color to the avatar"); + paintCircle.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } + } + else{ + paintCircle.setColor(ContextCompat.getColor(context,R.color.divider_upgrade_account)); } paintText.setColor(Color.WHITE); From 56c6ca9130bf7375be1d1336cc089982f23eb23f Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 30 Aug 2018 14:34:46 +0200 Subject: [PATCH 048/247] Feature#9775-Group calls UI --- .../lollipop/megachat/calls/CallService.java | 10 +- .../megachat/calls/ChatCallActivity.java | 285 +++++++++---- .../calls/MegaSurfaceRendererGroup.java | 88 +--- .../chatAdapters/GroupCallAdapter.java | 400 +++++++++++++----- .../main/res/layout/activity_calls_chat.xml | 12 - .../res/layout/item_camera_group_call.xml | 83 ++-- 6 files changed, 540 insertions(+), 338 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java index 3f456a8a4c0..128d877a3d7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/CallService.java @@ -185,17 +185,13 @@ public Bitmap setProfileContactAvatar(long userHandle, String fullName, String bitmap = getCircleBitmap(bitmap); if (bitmap != null) { return bitmap; - - } - else{ + }else{ return createDefaultAvatar(userHandle, fullName); } - } - else{ + }else{ return createDefaultAvatar(userHandle, fullName); } - } - else{ + }else{ return createDefaultAvatar(userHandle, fullName); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index aeed248415b..08f27e7e528 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -294,11 +294,75 @@ public boolean onOptionsItemSelected(MenuItem item) { } public void updateScreenStatusInProgress(){ - log("updateScreenStatusInProgress"); + log("updateScreenStatusInProgress()"); if(chat.isGroup()){ - relativeVideo.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width = RelativeLayout.LayoutParams.WRAP_CONTENT; + + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.requestLayout(); + + log("updateScreenStatusInProgress()- callChat.getNumParticipants() = "+ callChat.getNumParticipants()); + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } + + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + log("updateScreenStatusInProgress() peersOnCall has items"); + + + }else{ + log("updateScreenStatusInProgress() peersOnCall is empty"); + for(int i = 0; i < callChat.getParticipants().size(); i++){ + long userHandle = callChat.getParticipants().get(i); + if(userHandle == megaChatApi.getMyUserHandle()){ + log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + peersOnCall.add(myPeer); + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + }else{ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession!=null){ + if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + peersOnCall.add(0, userPeer); + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + }else{ + log("updateScreenStatusInProgress()-userSession.getStatus(): "+userSession.getStatus()); + } + } + + } + + } + } }else{ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -669,16 +733,20 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); - //Get all the peers, add them to peersBeforeCall array, show the AVATARS only + //Get all the participants, add them to peersBeforeCall array and show only the avatars + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } - peersBeforeCall.clear(); - peersOnCall.clear(); + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + peersOnCall.clear(); + } if(callChat.getParticipants().size()!=0){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - log("Incoming call: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); + log("onCreate()-Incoming Call: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); @@ -687,11 +755,9 @@ protected void onCreate(Bundle savedInstanceState) { }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ @@ -716,12 +782,12 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("CALL_STATUS_IN_PROGRESS"); + log("onCreate()-InProgress"); + updateScreenStatusInProgress(); }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -738,11 +804,16 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - peersBeforeCall.clear(); - peersOnCall.clear(); + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + peersOnCall.clear(); + } + + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } - log("Outgoing call: Add : "+megaChatApi.getMyFullname()+" my peer "); + log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); @@ -751,11 +822,9 @@ protected void onCreate(Bundle savedInstanceState) { }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ @@ -1101,7 +1170,6 @@ public void onDestroy(){ peersBeforeCall.clear(); stopAudioSignals(); mSensorManager.unregisterListener(this); - MegaApplication.activityPaused(); super.onDestroy(); @@ -1242,7 +1310,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { this.callChat = call; if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){ - log("CHANGE_TYPE_STATUS"); + log("++++ CHANGE_TYPE_STATUS"); int callStatus = callChat.getStatus(); switch (callStatus){ @@ -1250,38 +1318,23 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_IN_PROGRESS"); if(chat.isGroup()){ - if(call.isIncoming()){ - log("incoming call"); - peersBeforeCall.clear(); - log("IN_PROGRESS-Incoming - Add : "+megaChatApi.getMyFullname()+" my peer "); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); - peersOnCall.add(myPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - recyclerView.setAdapter(adapter); - }else{ + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); - boolean iAm = false; - for(int i=0;i 3)&&(peersOnCall.size() <= 6)){ @@ -1289,12 +1342,37 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + } + }else{ + log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + peersOnCall.add(myPeer); + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); } - updateLocalVideoStatus(); } + updateLocalVideoStatus(); + updateLocalAudioStatus(); + }else{ flagMyAvatar = true; setProfileMyAvatar(); @@ -1371,6 +1449,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("CHANGE_TYPE_SESSION_STATUS"); if(chat.isGroup()){ + + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } long userHandle = call.getPeerSessionStatusChange(); MegaChatSession userSession = callChat.getMegaChatSession(userHandle); @@ -1379,20 +1461,35 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateSubTitle(); //contact joined the group call - log("Session Status: Add : "+chat.getPeerFullnameByHandle(userHandle)+" peer "); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); - peersOnCall.add(0, userPeer); + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + boolean peerContain = false; + for(InfoPeerGroupCall peer : peersOnCall) { + if (peer.getHandle().equals(userHandle)) { + peerContain = true; + break; + } + } + if(!peerContain){ + log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + peersOnCall.add(0, userPeer); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + } } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - recyclerView.setAdapter(adapter); - }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ updateSubTitle(); @@ -1401,7 +1498,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); for(int i=0;i 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } + boolean isMe = false; + for(InfoPeerGroupCall peer : peersBeforeCall) { + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + isMe = true; + break; + } + } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID); - recyclerView.setAdapter(adapter); + if(!isMe){ + //Get all participant and add them + for(int i = 0; i < call.getParticipants().size(); i++){ + long userHandle = call.getParticipants().get(i); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + log("CHANGE_TYPE_CALL_COMPOSITION: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); + peersBeforeCall.add(0, userPeer); + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); } + } } } + }else{ log("other: "+call.getChanges()); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index de325dbaa4f..f27be3e51f1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -105,40 +105,16 @@ private void changeDestRect(int dstWidth, int dstHeight) { } private void adjustAspectRatio() { - if (bitmap != null && dstRect.height() != 0) { + float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); dstRect.top = 0; dstRect.left = 0; dstRect.right = surfaceWidth; - dstRect.bottom = surfaceHeight; - + dstRect.bottom = (int)(surfaceWidth/srcaspectratio); dstRectf = new RectF(dstRect); - float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); - float dstaspectratio = (float) dstRect.width() / dstRect.height(); - - if (srcaspectratio != 0 && dstaspectratio != 0) { - if (srcaspectratio > dstaspectratio) { - float newHeight = dstRect.width() / srcaspectratio; - float decrease = dstRect.height() - newHeight; -// dstRect.top += decrease / 2; -// dstRect.bottom -= decrease / 2; -// surfaceHolder.setFixedSize(surfaceWidth,surfaceHeight); - dstRectf = new RectF(dstRect); - } else { - float newWidth = dstRect.height() * srcaspectratio; - float decrease = dstRect.width() - newWidth; -// dstRect.left += decrease / 2; -// dstRect.right -= decrease / 2; -// surfaceHolder.setFixedSize(surfaceWidth,surfaceHeight); - - dstRectf = new RectF(dstRect); - } - } } } - - public void surfaceCreated(SurfaceHolder holder) { Log.d("MegaSurfaceRenderer","surfaceCreated()"); @@ -208,47 +184,11 @@ public Bitmap CreateBitmap(int width, int height) { srcRect.top = 0; srcRect.bottom = height; srcRect.right = width; - -// adjustAspectRatio(); + adjustAspectRatio(); return bitmap; } - public ByteBuffer CreateByteBuffer(int width, int height) { - Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); - if (bitmap == null) { - bitmap = CreateBitmap(width, height); - byteBuffer = ByteBuffer.allocateDirect(width * height * 2); - } - return byteBuffer; - } - - // It saves bitmap data to a JPEG picture, this function is for debug only. - private void saveBitmapToJPEG(int width, int height) { - ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); - - try{ - FileOutputStream output = new FileOutputStream(String.format( - "/sdcard/render_%d.jpg", System.currentTimeMillis())); - output.write(byteOutStream.toByteArray()); - output.flush(); - output.close(); - } - catch (FileNotFoundException e) { - } - catch (IOException e) { - } - } - - public void DrawByteBuffer() { - if(byteBuffer == null) - return; - byteBuffer.rewind(); - bitmap.copyPixelsFromBuffer(byteBuffer); - DrawBitmap(false); - } - public void DrawBitmap(boolean flag) { if(bitmap == null) @@ -261,7 +201,6 @@ public void DrawBitmap(boolean flag) { Canvas canvas = surfaceHolder.lockCanvas(); if (canvas != null) { canvas.scale(-1, 1); -// canvas.translate(-dstRect.width(), 0); canvas.translate(-canvas.getWidth(), 0); if (flag) { paint.reset(); @@ -277,25 +216,4 @@ public void DrawBitmap(boolean flag) { } } - public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { - Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); - final RectF rectF = new RectF(rect); - final float roundPx = pixels; - - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(Color.BLUE); - canvas.drawRoundRect(rectF, roundPx, roundPx, paint); - - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, rect, rect, paint); - - return output; - } - - } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index ac8336766e6..5113b02fb45 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -71,6 +71,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers) { boolean avatarRequested = false; private int adapterType; - public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType) { + public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType, boolean isCallInProgress) { log("GroupCallAdapter( peers: "+peers.size()+")"); this.context = context; @@ -98,6 +99,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList 3){ - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } - - holder.surfaceViewLayout.setLayoutParams(layoutParams); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = (maxScreenHeight/3); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - }else if(numPeersOnCall == 6){ - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParams.width = Util.scaleWidthPx(180, outMetrics); - layoutParams.height = Util.scaleWidthPx(180, outMetrics); - layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - - }else if(position > 3){ - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } - holder.surfaceViewLayout.setLayoutParams(layoutParams); - - } - - -// if(numPeersOnCall == 2){ -// holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(20, outMetrics),0,Util.scaleWidthPx(20, outMetrics),0); +// if(numPeersOnCall == 1){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = maxScreenWidth; +// layoutParamsAvatar.height = maxScreenWidth; +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = maxScreenWidth; +// layoutParamsSurface.height = maxScreenWidth; +// layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// }else if(numPeersOnCall == 2){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); // // }else if(numPeersOnCall == 3){ -// holderGrid.rlGeneral.setPadding(Util.scaleWidthPx(74, outMetrics),0,Util.scaleWidthPx(74, outMetrics),0); +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); // // }else if(numPeersOnCall == 4){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else{ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// // if((position < 2)){ -// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); // }else{ -// holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(144, outMetrics)); +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); // } +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); // // }else if(numPeersOnCall == 5){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// // if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParams.width = maxScreenWidth; -// layoutParams.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParams); -// holder.rlGeneral.setPadding(Util.scaleWidthPx(90, outMetrics),0,Util.scaleWidthPx(90, outMetrics),Util.scaleWidthPx(50, outMetrics)); -// }else{ -// if((position < 2)){ -// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); -// }else{ -// holderGrid.rlGeneral.setPadding(0,0,0,0); -// } +// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParamsPeer.width = maxScreenWidth; +// layoutParamsPeer.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParamsPeer); // } // -// }else if(numPeersOnCall == 6){ +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// // if((position < 2)){ -// holderGrid.rlGeneral.setPadding(0,Util.scaleWidthPx(50, outMetrics),0,0); +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ +// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParamsPeer.width = maxScreenWidth; +// layoutParamsPeer.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParamsPeer); +// } +// +// }else if(numPeersOnCall == 6){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); // +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); // }else if(position > 3){ -// holderGrid.rlGeneral.setPadding(0,0,0,Util.scaleWidthPx(50, outMetrics)); +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); // +// if((position < 2)){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// +// }else if(position > 3){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); // } +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// // } if(peer.isVideoOn()) { log("Video ON"); + if(numPeersOnCall == 1){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = maxScreenWidth; + layoutParamsSurface.height = maxScreenWidth; + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 2){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 3){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 4){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 5){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else if(position > 3){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = (maxScreenHeight/3); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + + }else if(numPeersOnCall == 6){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + + }else if(position > 3){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + } + + holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); - holder.avatarLayout.setVisibility(GONE); - //Remove before create + //Clear surfaceViewLayout if(holder.surfaceViewLayout.getChildCount() != 0){ holder.surfaceViewLayout.removeAllViewsInLayout(); } - if(peer.getListener() != null){ peer.setListener(null); } @@ -389,7 +501,11 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ - holder.microSurface.setVisibility(View.VISIBLE); + if(isCallInProgress) { + holder.microSurface.setVisibility(View.VISIBLE); + }else{ + holder.microSurface.setVisibility(View.GONE); + } } holder.surfaceViewLayout.setVisibility(View.VISIBLE); @@ -408,29 +524,105 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ }else{ log("Video OFF"); + if(numPeersOnCall == 1){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = maxScreenWidth; + layoutParamsAvatar.height = maxScreenWidth; + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 2){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 3){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 4){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 5){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else if(position > 3){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = (maxScreenHeight/3); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + + }else if(numPeersOnCall == 6){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else if(position > 3){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + } + holder.microSurface.setVisibility(View.GONE); - //Remove Surface View + //Clear surfaceViewLayout holder.surfaceViewLayout.removeAllViewsInLayout(); holder.surfaceViewLayout.setVisibility(View.GONE); //Create the avatar if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - holder.rlGeneral.setBackgroundColor(Color.YELLOW); setProfileMyAvatar(holder); }else{ - holder.rlGeneral.setBackgroundColor(Color.BLUE); - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } + //Update micro icon if(peer.isAudioOn()){ holder.microAvatar.setVisibility(View.GONE); }else{ - holder.microAvatar.setVisibility(View.VISIBLE); + if(isCallInProgress){ + holder.microAvatar.setVisibility(View.VISIBLE); + }else{ + holder.microAvatar.setVisibility(View.GONE); + } } - holder.avatarLayout.setVisibility(View.VISIBLE); + holder.avatarMicroLayout.setVisibility(View.VISIBLE); //Remove listener if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 8ca2e4a9776..97daa453451 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -35,18 +35,6 @@ android:scrollbars="horizontal" android:layout_centerHorizontal="true" android:nestedScrollingEnabled="false"/> - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index d3592db9411..c767d78573f 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -14,53 +14,60 @@ android:layout_centerInParent="true" android:background="@android:color/transparent" android:visibility="gone"> - - - + android:background="@android:color/transparent" + android:visibility="gone"> + + + + + - + + - + - + android:visibility="gone" + android:src="@drawable/ic_mic_off"/> - - + From 90d9f15857d540cfbbbdba0e5ac545b1f435cfe1 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 30 Aug 2018 15:18:47 +0200 Subject: [PATCH 049/247] Feature#9775-Group calls UI --- .../privacy/android/app/MegaApplication.java | 2 +- .../megachat/calls/AppRTCAudioManager.java | 4 +- .../megachat/calls/ChatCallActivity.java | 60 +++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index 4297283d7ab..df9e30d82c8 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -1149,6 +1149,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { MegaChatCall callToLaunch = megaChatApi.getChatCall(chatId); if (callToLaunch != null) { if (callToLaunch.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS) { + log("Launch call with status: "+callToLaunch.getStatus()); launchCallActivity(callToLaunch); } else { log("Launch not in correct status"); @@ -1206,7 +1207,6 @@ public void checkQueuedCalls(){ public void launchCallActivity(MegaChatCall call){ log("launchCallActivity: "+call.getStatus()); MegaApplication.setShowPinScreen(false); - MegaApplication.setOpenCallChatId(call.getChatid()); Intent i = new Intent(this, ChatCallActivity.class); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/AppRTCAudioManager.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/AppRTCAudioManager.java index c214eaa53b0..aa3801db1c3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/AppRTCAudioManager.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/AppRTCAudioManager.java @@ -276,7 +276,9 @@ public void onAudioFocusChange(int focusChange) { selectedAudioDevice = AudioDevice.NONE; audioDevices.clear(); - proximitySensor.start(); + if(proximitySensor != null) { + proximitySensor.start(); + } // Initialize and start Bluetooth if a BT device is available or initiate // detection of new (enabled) BT devices. diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 08f27e7e528..66b0aefd13d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -308,11 +308,63 @@ public void updateScreenStatusInProgress(){ } if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - log("updateScreenStatusInProgress() peersOnCall has items"); - + for(int i = 0; i < callChat.getParticipants().size(); i++){ + long userHandle = callChat.getParticipants().get(i); + if((peersOnCall != null)&&(peersOnCall.size() != 0)) { + boolean peerContain = false; + for (InfoPeerGroupCall peer : peersOnCall) { + if (peer.getHandle().equals(userHandle)) { + peerContain = true; + break; + } + } + if (!peerContain) { + if(userHandle == megaChatApi.getMyUserHandle()){ + log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + peersOnCall.add(myPeer); + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + }else{ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession!=null){ + if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + peersOnCall.add(0, userPeer); + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + } + } + } + } + } + } }else{ - log("updateScreenStatusInProgress() peersOnCall is empty"); for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ @@ -1310,7 +1362,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { this.callChat = call; if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){ - log("++++ CHANGE_TYPE_STATUS"); + log("CHANGE_TYPE_STATUS"); int callStatus = callChat.getStatus(); switch (callStatus){ From 42b72503ca38cc7a55e8835886f6f2586491722b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 5 Sep 2018 15:02:47 +0200 Subject: [PATCH 050/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 446 ++++++++++-------- .../calls/MegaSurfaceRendererGroup.java | 72 ++- 2 files changed, 314 insertions(+), 204 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 66b0aefd13d..dca817b288e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -273,23 +273,15 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { log("onOptionsItemSelected"); -// ((MegaApplication) getApplication()).sendSignalPresenceActivity(); -// -// int id = item.getItemId(); -// switch (id) { -// case android.R.id.home: { -// log("Hang call"); -// megaChatApi.hangChatCall(chatId, null); -// MegaApplication.activityPaused(); -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// super.finishAndRemoveTask(); -// } -// else { -// super.finish(); -// } -// break; -// } -// } + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + int id = item.getItemId(); + switch (id) { + case android.R.id.home: { + log("Hang call"); + onBackPressed(); + break; + } + } return super.onOptionsItemSelected(item); } @@ -308,6 +300,7 @@ public void updateScreenStatusInProgress(){ } if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if((peersOnCall != null)&&(peersOnCall.size() != 0)) { @@ -323,20 +316,21 @@ public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + changes = true; + +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ @@ -344,47 +338,53 @@ public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + changes = true; +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } } } } } } } + + if(changes){ + createNewAdapter(peersOnCall.size()); + } + }else{ + boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + changes = true; +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ @@ -392,27 +392,29 @@ public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + changes = true; +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } }else{ log("updateScreenStatusInProgress()-userSession.getStatus(): "+userSession.getStatus()); } } } - + } + if(changes){ + createNewAdapter(peersOnCall.size()); } } @@ -591,10 +593,9 @@ protected void onCreate(Bundle savedInstanceState) { tB.setVisibility(View.VISIBLE); setSupportActionBar(tB); aB = getSupportActionBar(); - log("aB.setHomeAsUpIndicator_1"); aB.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white); - aB.setHomeButtonEnabled(false); - aB.setDisplayHomeAsUpEnabled(false); + aB.setHomeButtonEnabled(true); + aB.setDisplayHomeAsUpEnabled(true); aB.setTitle(" "); myChrono = new Chronometer(context); @@ -868,20 +869,20 @@ protected void onCreate(Bundle savedInstanceState) { log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + createNewAdapter(peersOnCall.size()); +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } }else{ log("Outgoing individual call"); @@ -1387,40 +1388,42 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + createNewAdapter(peersOnCall.size()); +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } } }else{ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + createNewAdapter(peersOnCall.size()); +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1508,73 +1511,81 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ long userHandle = call.getPeerSessionStatusChange(); MegaChatSession userSession = callChat.getMegaChatSession(userHandle); - if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + if(userSession != null){ + if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - updateSubTitle(); - - //contact joined the group call - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - boolean peerContain = false; - for(InfoPeerGroupCall peer : peersOnCall) { - if (peer.getHandle().equals(userHandle)) { - peerContain = true; - break; - } - } - if(!peerContain){ - log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); - peersOnCall.add(0, userPeer); + updateSubTitle(); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); + //contact joined the group call + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + boolean peerContain = false; + for(InfoPeerGroupCall peer : peersOnCall) { + if (peer.getHandle().equals(userHandle)) { + peerContain = true; + break; + } } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); + if(!peerContain){ + log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + peersOnCall.add(0, userPeer); + createNewAdapter(peersOnCall.size()); +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } } } - } - }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ + }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ - updateSubTitle(); + updateSubTitle(); - //contact left the group call - log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); - for(int i=0;i 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); + if(changes){ + createNewAdapter(peersOnCall.size()); + } + +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } } + updateRemoteVideoStatus(userHandle); + updateRemoteAudioStatus(userHandle); + updateLocalVideoStatus(); + updateLocalAudioStatus(); } - updateRemoteVideoStatus(userHandle); - updateRemoteAudioStatus(userHandle); - updateLocalVideoStatus(); - updateLocalAudioStatus(); } else{ @@ -1634,21 +1645,20 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("CHANGE_TYPE_CALL_COMPOSITION: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); + } - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } - + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); } } } @@ -2513,4 +2523,66 @@ public void animationAlphaArrows(final ImageView arrow){ arrow.startAnimation(alphaAnimArrows); } + + public void createNewAdapter(int numOfPeers){ + log("createNewAdapter"); + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } + +// if(numOfPeers == 1 ){ +// recyclerView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); +// }else if(numOfPeers == 2){ +// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); +// params.width = (Util.scaleWidthPx(320, outMetrics)); +// params.height= (Util.scaleWidthPx(320, outMetrics))*2; +// recyclerView.setLayoutParams(params); +// recyclerView.setColumnWidth(Util.scaleWidthPx(320, outMetrics)); +// log("#### 5Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*2)"); +// +//// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); +//// params.width = (int) widthScreenPX; +//// params.height= (int) heightScreenPX; +//// recyclerView.setLayoutParams(params); +//// recyclerView.setColumnWidth((int) widthScreenPX); +//// log("#### 4Recycler: peers("+numOfPeers+") ---> (w "+widthScreenPX+", h "+heightScreenPX+")"); +// +// }else if(numOfPeers == 4){ +// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); +// params.width = (Util.scaleWidthPx(180, outMetrics))*2; +// params.height= (Util.scaleWidthPx(180, outMetrics))*2; +// recyclerView.setLayoutParams(params); +// recyclerView.setColumnWidth(Util.scaleWidthPx(180, outMetrics)); +// log("#### 5Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*2)"); +// +// }else if(numOfPeers > 4){ +// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); +// params.width = (Util.scaleWidthPx(180, outMetrics))*2; +// params.height= (Util.scaleWidthPx(180, outMetrics))*3; +// recyclerView.setLayoutParams(params); +// recyclerView.setColumnWidth(Util.scaleWidthPx(180, outMetrics)); +// log("#### 6Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*3)"); +// } +// +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } + } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index f27be3e51f1..a943346abda 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -101,19 +101,19 @@ private void changeDestRect(int dstWidth, int dstHeight) { dstRect.bottom = dstHeight; dstRectf = new RectF(dstRect); - adjustAspectRatio(); +// adjustAspectRatio(); } - private void adjustAspectRatio() { - if (bitmap != null && dstRect.height() != 0) { - float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); - dstRect.top = 0; - dstRect.left = 0; - dstRect.right = surfaceWidth; - dstRect.bottom = (int)(surfaceWidth/srcaspectratio); - dstRectf = new RectF(dstRect); - } - } +// private void adjustAspectRatio() { +// if (bitmap != null && dstRect.height() != 0) { +// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); +// dstRect.top = 0; +// dstRect.left = 0; +// dstRect.right = surfaceWidth; +// dstRect.bottom = (int)(surfaceWidth/srcaspectratio); +// dstRectf = new RectF(dstRect); +// } +// } public void surfaceCreated(SurfaceHolder holder) { Log.d("MegaSurfaceRenderer","surfaceCreated()"); @@ -179,12 +179,50 @@ public Bitmap CreateBitmap(int width, int height) { catch (Exception e) { } } - bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - srcRect.left = 0; - srcRect.top = 0; - srcRect.bottom = height; - srcRect.right = width; - adjustAspectRatio(); + + if(height == width){ + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + srcRect.top = 0; + srcRect.bottom = height; + srcRect.left = 0; + srcRect.right = width; + + }else if(height > width){ + int newHeight = width; + bitmap = Bitmap.createBitmap(width, newHeight, Bitmap.Config.ARGB_8888); + srcRect.top = 0; + srcRect.bottom = newHeight; + srcRect.left = 0; + srcRect.right = width; +// float decrease = height - newHeight; +// int decreaseHalf = (int) (decrease/2); +// +// srcRect.top = decreaseHalf; +// srcRect.bottom = (height - decreaseHalf); +// srcRect.left = 0; +// srcRect.right = width; + }else{ + int newWidth = height; + bitmap = Bitmap.createBitmap(newWidth, height, Bitmap.Config.ARGB_8888); + srcRect.left = 0; + srcRect.right = newWidth; + srcRect.top = 0; + srcRect.bottom = height; +// float decrease = width - newWidth; +// int decreaseHalf = (int) (decrease/2); +// +// srcRect.left = decreaseHalf; +// srcRect.right = (width - decreaseHalf); +// srcRect.top = 0; +// srcRect.bottom = height; + } + +// bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); +// srcRect.left = 0; +// srcRect.top = 0; +// srcRect.bottom = height; +// srcRect.right = width; +// adjustAspectRatio(); return bitmap; } From 78638fca828b54ee8838181ba4a43bc6b3b270de Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 6 Sep 2018 12:59:31 +0200 Subject: [PATCH 051/247] Feature#9775-Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 11 ++ .../megachat/calls/ChatCallActivity.java | 183 ++---------------- .../RemoteCameraCallFullScreenFragment.java | 11 +- .../chatAdapters/GroupCallAdapter.java | 8 +- 4 files changed, 44 insertions(+), 169 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 47831ddc725..fc7b9651c5f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -19,11 +19,13 @@ public class GroupCallListener implements MegaChatVideoListenerInterface { Context context; GroupCallAdapter.ViewHolderGroupCall holder; + int width; int height; Bitmap bitmap; public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall holder) { + log("GroupCallListener"); this.context = context; this.holder = holder; this.width = 0; @@ -72,6 +74,15 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } } + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + private static void log(String log) { Util.log("GroupCallListener", log); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index dca817b288e..42005f6d46f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -317,20 +317,6 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; - -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ @@ -339,19 +325,6 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); changes = true; -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } } } } @@ -360,7 +333,7 @@ public void updateScreenStatusInProgress(){ } if(changes){ - createNewAdapter(peersOnCall.size()); + createNewAdapter(); } }else{ @@ -372,19 +345,6 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ @@ -393,19 +353,6 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); changes = true; -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } }else{ log("updateScreenStatusInProgress()-userSession.getStatus(): "+userSession.getStatus()); } @@ -414,7 +361,7 @@ public void updateScreenStatusInProgress(){ } } if(changes){ - createNewAdapter(peersOnCall.size()); + createNewAdapter(); } } @@ -869,20 +816,7 @@ protected void onCreate(Bundle savedInstanceState) { log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(peersOnCall.size()); -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } + createNewAdapter(); }else{ log("Outgoing individual call"); @@ -1191,9 +1125,18 @@ public void onPause(){ @Override protected void onResume() { log("onResume"); + if(peersOnCall!=null){ + if(peersOnCall.size()!=0){ + for(InfoPeerGroupCall peer :peersOnCall){ + if(peer.getListener()!=null){ + peer.getListener().setHeight(0); + peer.getListener().setWidth(0); + } + + } + } + } -// this.width=0; -// this.height=0; super.onResume(); // adapter.notifyDataSetChanged(); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); @@ -1204,6 +1147,8 @@ protected void onResume() { if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){ ((MegaApplication) getApplication()).sendSignalPresenceActivity(); } + + } @Override @@ -1388,42 +1333,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(peersOnCall.size()); -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } + createNewAdapter(); } }else{ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(peersOnCall.size()); - -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } + createNewAdapter(); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1529,20 +1445,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - createNewAdapter(peersOnCall.size()); -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } + createNewAdapter(); } } @@ -1563,7 +1466,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(changes){ - createNewAdapter(peersOnCall.size()); + createNewAdapter(); } // if(peersOnCall.size() <= 3){ @@ -2524,9 +2427,8 @@ public void animationAlphaArrows(final ImageView arrow){ } - public void createNewAdapter(int numOfPeers){ + public void createNewAdapter(){ log("createNewAdapter"); - if(peersOnCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ @@ -2540,49 +2442,6 @@ public void createNewAdapter(int numOfPeers){ }else{ recyclerView.setVisibility(View.VISIBLE); } - -// if(numOfPeers == 1 ){ -// recyclerView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); -// }else if(numOfPeers == 2){ -// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); -// params.width = (Util.scaleWidthPx(320, outMetrics)); -// params.height= (Util.scaleWidthPx(320, outMetrics))*2; -// recyclerView.setLayoutParams(params); -// recyclerView.setColumnWidth(Util.scaleWidthPx(320, outMetrics)); -// log("#### 5Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*2)"); -// -//// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); -//// params.width = (int) widthScreenPX; -//// params.height= (int) heightScreenPX; -//// recyclerView.setLayoutParams(params); -//// recyclerView.setColumnWidth((int) widthScreenPX); -//// log("#### 4Recycler: peers("+numOfPeers+") ---> (w "+widthScreenPX+", h "+heightScreenPX+")"); -// -// }else if(numOfPeers == 4){ -// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); -// params.width = (Util.scaleWidthPx(180, outMetrics))*2; -// params.height= (Util.scaleWidthPx(180, outMetrics))*2; -// recyclerView.setLayoutParams(params); -// recyclerView.setColumnWidth(Util.scaleWidthPx(180, outMetrics)); -// log("#### 5Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*2)"); -// -// }else if(numOfPeers > 4){ -// ViewGroup.LayoutParams params=recyclerView.getLayoutParams(); -// params.width = (Util.scaleWidthPx(180, outMetrics))*2; -// params.height= (Util.scaleWidthPx(180, outMetrics))*3; -// recyclerView.setLayoutParams(params); -// recyclerView.setColumnWidth(Util.scaleWidthPx(180, outMetrics)); -// log("#### 6Recycler: peers("+numOfPeers+") ---> (w 180*2, h 180*3)"); -// } -// -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index 620c9cf8f43..ee5d7c77e91 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -83,8 +83,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa } @Override - public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) - { + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer){ + log("onChatVideoData"); + if((width == 0) || (height == 0)){ return; } @@ -127,15 +128,20 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei @Override public void onAttach(Context context) { + log("onAttach"); + super.onAttach(context); this.context = context; } @Override public void onDestroy(){ + log("onDestroy"); + megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); } + @Override public void onResume() { log("onResume"); @@ -145,6 +151,7 @@ public void onResume() { } public void setVideoFrame(boolean visible){ + log("setVideoFrame"); if(visible){ remoteFullScreenSurfaceView.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 5113b02fb45..8c302d8731e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -10,6 +10,7 @@ import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; +import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; @@ -115,7 +116,6 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList "+peers.size()); return peers.size(); }else{ - log("getItemCount() -> 0"); return 0; } } public Object getItem(int position) { - log("getItem()"); + log("getItem() position "+position); if (peers != null){ return peers.get(position); @@ -659,7 +657,7 @@ public Object getItem(int position) { public InfoPeerGroupCall getNodeAt(int position) { - log("getNodeAt() position-> "+position); + log("getNodeAt() position "+position); try { if (peers != null) { From 0b92b90b12ed354485e3d4c4520dbf7c62e9b5f2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 6 Sep 2018 14:37:08 +0200 Subject: [PATCH 052/247] Feature#9775-Group calls UI --- .../megachat/ChatActivityLollipop.java | 20 ++-- .../megachat/calls/ChatCallActivity.java | 106 ++++++++---------- .../chatAdapters/GroupCallAdapter.java | 1 - .../main/res/layout/activity_calls_chat.xml | 1 - app/src/main/res/layout/activity_chat.xml | 24 ---- 5 files changed, 57 insertions(+), 95 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index a6448aac4f9..6e203730fe7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1741,6 +1741,7 @@ public void startCall(){ } public boolean checkPermissionsCall(){ + log("checkPermissionsCall() "); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean hasCameraPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED); @@ -2260,16 +2261,17 @@ public void onClick(View v) { // break; // } case R.id.call_in_progress_layout:{ - MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); - if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ - megaChatApi.startChatCall(idChat, false, null); - } - else{ - Intent intent = new Intent(this, ChatCallActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + if(checkPermissionsCall()){ + MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); + if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + megaChatApi.startChatCall(idChat, false, null); + }else{ + Intent intent = new Intent(this, ChatCallActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setAction(Long.toString(System.currentTimeMillis())); - intent.putExtra("chatHandle", idChat); - startActivity(intent); + intent.putExtra("chatHandle", idChat); + startActivity(intent); + } } break; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 42005f6d46f..58c1c90e73d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -333,7 +333,7 @@ public void updateScreenStatusInProgress(){ } if(changes){ - createNewAdapter(); + createNewAdapter(true); } }else{ @@ -361,7 +361,7 @@ public void updateScreenStatusInProgress(){ } } if(changes){ - createNewAdapter(); + createNewAdapter(true); } } @@ -743,26 +743,17 @@ protected void onCreate(Bundle savedInstanceState) { } if(callChat.getParticipants().size()!=0){ + boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); log("onCreate()-Incoming Call: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); - - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); - } + changes = true; + } + if(changes){ + createNewAdapter(false); } } @@ -816,7 +807,7 @@ protected void onCreate(Bundle savedInstanceState) { log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(); + createNewAdapter(true); }else{ log("Outgoing individual call"); @@ -835,7 +826,6 @@ protected void onCreate(Bundle savedInstanceState) { } } } - if(checkPermissions()){ showInitialFABConfiguration(); } @@ -1333,13 +1323,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(); + createNewAdapter(true); } }else{ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); - createNewAdapter(); + createNewAdapter(true); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1445,7 +1435,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - createNewAdapter(); + createNewAdapter(true); } } @@ -1466,22 +1456,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(changes){ - createNewAdapter(); + createNewAdapter(true); } -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1541,6 +1518,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if(!isMe){ + boolean changes = false; //Get all participant and add them for(int i = 0; i < call.getParticipants().size(); i++){ long userHandle = call.getParticipants().get(i); @@ -1548,20 +1526,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("CHANGE_TYPE_CALL_COMPOSITION: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); + changes = true; } - - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, false); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ - recyclerView.setVisibility(View.VISIBLE); + if(changes){ + createNewAdapter(false); } } } @@ -2427,21 +2395,39 @@ public void animationAlphaArrows(final ImageView arrow){ } - public void createNewAdapter(){ + public void createNewAdapter(boolean flag){ log("createNewAdapter"); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, true); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); + + if(flag){ + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } }else{ - recyclerView.setVisibility(View.VISIBLE); + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } } + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 8c302d8731e..266980f9b43 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -130,7 +130,6 @@ public void onClick(View v) { } } - /*private view holder class*/ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ RelativeLayout rlGeneral; diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 97daa453451..bf86f94a874 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -20,7 +20,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - - - - - - - - - - - - - - - - - - - From 0eaddd8bdc860c870b9733c2561935e92df4ac28 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 7 Sep 2018 08:35:10 +0200 Subject: [PATCH 053/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 1 + .../chatAdapters/GroupCallAdapter.java | 143 ------------------ 2 files changed, 1 insertion(+), 143 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 58c1c90e73d..567f3f2c8b3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -779,6 +779,7 @@ protected void onCreate(Bundle savedInstanceState) { }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 266980f9b43..e60571033e2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -248,149 +248,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } int numPeersOnCall = getItemCount(); -// if(numPeersOnCall == 1){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = maxScreenWidth; -// layoutParamsAvatar.height = maxScreenWidth; -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = maxScreenWidth; -// layoutParamsSurface.height = maxScreenWidth; -// layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 2){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 3){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 4){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else{ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else{ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 5){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParamsPeer.width = maxScreenWidth; -// layoutParamsPeer.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParamsPeer); -// } -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParamsPeer.width = maxScreenWidth; -// layoutParamsPeer.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParamsPeer); -// } -// -// }else if(numPeersOnCall == 6){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// -// }else if(position > 3){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// } - if(peer.isVideoOn()) { log("Video ON"); if(numPeersOnCall == 1){ From d7bc9abdba57681ac19b683008f566dbade2f584 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 7 Sep 2018 13:22:42 +0200 Subject: [PATCH 054/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 16 ++- .../chatAdapters/GroupCallAdapter.java | 97 +++++++++++++------ 2 files changed, 80 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 567f3f2c8b3..f921e8d9eb6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -710,7 +710,6 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -778,8 +777,6 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ - - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -2400,6 +2397,19 @@ public void createNewAdapter(boolean flag){ log("createNewAdapter"); if(flag){ + if(peersOnCall.size() <= 4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + recyclerView.setLayoutParams(params); + + }else{ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(540, outMetrics); + recyclerView.setLayoutParams(params); + + } if(peersOnCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e60571033e2..c543a99c7c6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -179,6 +179,23 @@ public ViewHolderGroupCallGrid(View v) { CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); +// if(numPeersOnCall < 4) { +// lp.height = maxScreenHeight / numPeersOnCall; +// lp.width = maxScreenWidth; +// +// }else if(numPeersOnCall == 4){ +// lp.height = maxScreenHeight / 2; +// lp.width = maxScreenWidth/2; +// +// }else if(numPeersOnCall == 5){ +// lp.height = maxScreenHeight / 3; +// lp.width = maxScreenWidth/2; +// +// }else if((numPeersOnCall > 5)&&(numPeersOnCall<7)){ +// lp.height = maxScreenHeight / 3; +// lp.width = maxScreenWidth/2; +// } + if(numPeersOnCall < 4) { lp.height = maxScreenHeight / numPeersOnCall; lp.width = maxScreenWidth; @@ -187,13 +204,10 @@ public ViewHolderGroupCallGrid(View v) { lp.height = maxScreenHeight / 2; lp.width = maxScreenWidth/2; - }else if(numPeersOnCall == 5){ - lp.height = maxScreenHeight / 3; + }else if(numPeersOnCall > 4){ + lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; - }else if((numPeersOnCall > 5)&&(numPeersOnCall<7)){ - lp.height = maxScreenHeight / 3; - lp.width = maxScreenWidth/2; } v.setLayoutParams(lp); @@ -294,21 +308,36 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else if(position > 3){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = (maxScreenHeight/3); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); } + +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// +// if((position < 2)){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ +// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParamsPeer.width = maxScreenWidth; +// layoutParamsPeer.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParamsPeer); +// } + }else if(numPeersOnCall == 6){ //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); @@ -316,12 +345,12 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - if((position < 2)){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - - }else if(position > 3){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } +// if((position < 2)){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// +// }else if(position > 3){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); } @@ -424,33 +453,41 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - if((position < 2)){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else if(position > 3){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = (maxScreenHeight/3); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); } +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ +// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParamsPeer.width = maxScreenWidth; +// layoutParamsPeer.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParamsPeer); +// } + }else if(numPeersOnCall == 6){ //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - if((position < 2)){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else if(position > 3){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); } From d214c8c2ae9fd4c3e04aec3948f6ef561316124d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 11 Sep 2018 10:41:15 +0200 Subject: [PATCH 055/247] Feature#9775-Group calls UI --- .../listeners/BigGroupCallListener.java | 87 +++ .../megachat/calls/ChatCallActivity.java | 141 ++-- .../megachat/calls/InfoPeerGroupCall.java | 18 +- .../chatAdapters/BigGroupCallAdapter.java | 737 ++++++++++++++++++ .../main/res/layout/activity_calls_chat.xml | 6 + 5 files changed, 943 insertions(+), 46 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java new file mode 100644 index 00000000000..6f1145eead8 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java @@ -0,0 +1,87 @@ +package mega.privacy.android.app.lollipop.listeners; + +import android.content.Context; +import android.graphics.Bitmap; +import android.view.SurfaceHolder; + +import java.nio.ByteBuffer; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; + +public class BigGroupCallListener implements MegaChatVideoListenerInterface { + + Context context; + BigGroupCallAdapter.ViewHolderGroupCall holder; + + int width; + int height; + Bitmap bitmap; + + public BigGroupCallListener(Context context, BigGroupCallAdapter.ViewHolderGroupCall holder) { + log("BigGroupCallListener"); + this.context = context; + this.holder = holder; + this.width = 0; + this.height = 0; + } + + @Override + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { + if((width == 0) || (height == 0)){ + return; + } + + if (this.width != width || this.height != height) { + this.width = width; + this.height = height; + + + SurfaceHolder Sholder = holder.surfaceView.getHolder(); + if (Sholder != null) { + int viewWidth = holder.surfaceView.getWidth(); + int viewHeight = holder.surfaceView.getHeight(); + + if ((viewWidth != 0) && (viewHeight != 0)) { + int holderWidth = viewWidth < width ? viewWidth : width; + int holderHeight = holderWidth * viewHeight / viewWidth; + if (holderHeight > viewHeight) { + + holderHeight = viewHeight; + holderWidth = holderHeight * viewWidth / viewHeight; + } + this.bitmap = holder.localRenderer.CreateBitmap(width, height); + Sholder.setFixedSize(holderWidth, holderHeight); + }else{ + this.width = -1; + this.height = -1; + } + } + } + + if (bitmap != null) { + bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); + + // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. + // The renderer has been modified a bit and an update of WebRTC could break our app + holder.localRenderer.DrawBitmap(false); + } + } + + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + + private static void log(String log) { + Util.log("GroupCallListener", log); + } + +} + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f921e8d9eb6..dfc11901577 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -35,6 +35,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; @@ -78,6 +79,7 @@ import mega.privacy.android.app.lollipop.LoginActivityLollipop; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; @@ -144,7 +146,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ArrayList peersOnCall = new ArrayList<>(); ArrayList peersBeforeCall = new ArrayList<>(); - Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; @@ -154,7 +155,12 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout bigElementsGroupCallLayout; CustomizedGridCallRecyclerView recyclerView; + + LinearLayoutManager layoutManager; + RecyclerView BigRecyclerView; + GroupCallAdapter adapter; + BigGroupCallAdapter BigAdapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -314,7 +320,7 @@ public void updateScreenStatusInProgress(){ if (!peerContain) { if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null, null); peersOnCall.add(myPeer); changes = true; }else{ @@ -322,7 +328,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null, null); peersOnCall.add(0, userPeer); changes = true; } @@ -342,7 +348,7 @@ public void updateScreenStatusInProgress(){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); peersOnCall.add(myPeer); changes = true; }else{ @@ -350,7 +356,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null, null); peersOnCall.add(0, userPeer); changes = true; }else{ @@ -599,12 +605,20 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsGroupCallLayout = (RelativeLayout) findViewById(R.id.big_elements_group_call); bigElementsGroupCallLayout.setVisibility(GONE); + //Recycler View for 1-6 peers recyclerView = (CustomizedGridCallRecyclerView) findViewById(R.id.recycler_view_cameras); recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); recyclerView.setColumnWidth((int) widthScreenPX); recyclerView.setItemAnimator(new DefaultItemAnimator()); + recyclerView.setVisibility(GONE); + + //Recycler View for 6-8 peers + layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); + BigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); + BigRecyclerView.setLayoutManager(layoutManager); + BigRecyclerView.setVisibility(GONE); //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); @@ -747,7 +761,7 @@ protected void onCreate(Bundle savedInstanceState) { long userHandle = callChat.getParticipants().get(i); log("onCreate()-Incoming Call: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null,null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -803,7 +817,7 @@ protected void onCreate(Bundle savedInstanceState) { } log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null,null); peersOnCall.add(myPeer); createNewAdapter(true); }else{ @@ -1319,13 +1333,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); peersOnCall.add(myPeer); createNewAdapter(true); } }else{ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); peersOnCall.add(myPeer); createNewAdapter(true); } @@ -1431,7 +1445,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(!peerContain){ log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null,null); peersOnCall.add(0, userPeer); createNewAdapter(true); } @@ -1522,7 +1536,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ long userHandle = call.getParticipants().get(i); log("CHANGE_TYPE_CALL_COMPOSITION: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null,null, null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -2397,46 +2411,85 @@ public void createNewAdapter(boolean flag){ log("createNewAdapter"); if(flag){ - if(peersOnCall.size() <= 4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.MATCH_PARENT; - recyclerView.setLayoutParams(params); + //arrayList-> peersOnCall + if(peersOnCall.size() < 7){ + BigRecyclerView.setAdapter(null); + BigRecyclerView.setVisibility(GONE); - }else{ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(540, outMetrics); - recyclerView.setLayoutParams(params); + if(peersOnCall.size() <= 4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + recyclerView.setLayoutParams(params); - } - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); + }else{ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(540, outMetrics); + recyclerView.setLayoutParams(params); + + } + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } }else{ - recyclerView.setVisibility(View.VISIBLE); + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); + + BigRecyclerView.setAdapter(null); + BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersOnCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + BigRecyclerView.setAdapter(BigAdapter); + if (BigAdapter.getItemCount() == 0){ + BigRecyclerView.setVisibility(View.GONE); + }else{ + BigRecyclerView.setVisibility(View.VISIBLE); + } } + }else{ - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); + //arrayList-> peersBeforeCall + + if(peersOnCall.size() < 7) { + BigRecyclerView.setAdapter(null); + BigRecyclerView.setVisibility(GONE); + + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + recyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + recyclerView.setVisibility(View.GONE); + }else{ + recyclerView.setVisibility(View.VISIBLE); + } }else{ - recyclerView.setVisibility(View.VISIBLE); + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); + + BigRecyclerView.setAdapter(null); + BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersBeforeCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + BigRecyclerView.setAdapter(BigAdapter); + if (BigAdapter.getItemCount() == 0){ + BigRecyclerView.setVisibility(View.GONE); + }else{ + BigRecyclerView.setVisibility(View.VISIBLE); + } } + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java index 9a2da36eab4..e66ca11cbbd 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java @@ -3,6 +3,7 @@ import android.view.SurfaceView; +import mega.privacy.android.app.lollipop.listeners.BigGroupCallListener; import mega.privacy.android.app.lollipop.listeners.GroupCallListener; public class InfoPeerGroupCall { @@ -10,16 +11,20 @@ public class InfoPeerGroupCall { String name; boolean videoOn; boolean audioOn; - GroupCallListener listener; + GroupCallListener listener = null; + BigGroupCallListener listenerB = null; + SurfaceView surfaceview; - public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener, SurfaceView surfaceview) { + public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener, BigGroupCallListener listenerB, SurfaceView surfaceview) { this.handle = handle; this.name = name; this.videoOn = videoOn; this.audioOn = audioOn; this.listener = listener; this.surfaceview = surfaceview; + this.listenerB = listenerB; + } public Long getHandle() { @@ -62,6 +67,15 @@ public void setListener(GroupCallListener listener) { this.listener = listener; } + public BigGroupCallListener getListenerB() { + return listenerB; + } + + public void setListenerB(BigGroupCallListener listenerB) { + this.listenerB = listenerB; + } + + public SurfaceView getSurfaceview() { return surfaceview; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java new file mode 100644 index 00000000000..281d4f0fc8c --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java @@ -0,0 +1,737 @@ +package mega.privacy.android.app.lollipop.megachat.chatAdapters; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.PixelFormat; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.RecyclerView; +import android.util.DisplayMetrics; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.io.File; +import java.util.ArrayList; +import java.util.Locale; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.components.CustomizedGridRecyclerView; +import mega.privacy.android.app.components.RoundedImageView; +import mega.privacy.android.app.lollipop.listeners.BigGroupCallListener; +import mega.privacy.android.app.lollipop.listeners.GroupCallListener; +import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; +import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; +import mega.privacy.android.app.lollipop.megachat.calls.InfoPeerGroupCall; +import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRendererGroup; +import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatApiAndroid; + +import static android.view.View.GONE; + + +public class BigGroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener { + + public static final int ITEM_VIEW_TYPE_GRID = 1; + + Context context; + MegaApiAndroid megaApi; + MegaChatApiAndroid megaChatApi = null; + Display display; + DisplayMetrics outMetrics; + float density; + float scaleW; + float scaleH; + float widthScreenPX, heightScreenPX; + boolean isCallInProgress = false; + + RecyclerView recyclerViewFragment; + + public ArrayList getPeers() { + return peers; + } + + public void setPeers(ArrayList peers) { + this.peers = peers; + } + + ArrayList peers; + long chatId; + + int maxScreenWidth, maxScreenHeight; + + boolean avatarRequested = false; + private int adapterType; + + public BigGroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType, boolean isCallInProgress) { + log("BigGroupCallAdapter( peers: "+peers.size()+")"); + + this.context = context; + this.recyclerViewFragment = recyclerView; + this.peers = peers; + this.chatId = chatId; + this.adapterType = adapterType; + this.isCallInProgress = isCallInProgress; + + MegaApplication app = (MegaApplication) ((Activity) context).getApplication(); + if (megaApi == null) { + megaApi = app.getMegaApi(); + } + + log("retryPendingConnections()"); + if (megaApi != null) { + log("---------retryPendingConnections"); + megaApi.retryPendingConnections(); + } + + if (megaChatApi == null) { + megaChatApi = app.getMegaChatApi(); + } + } + + @Override + public void onClick(View v) { + log("onClick"); + ((MegaApplication) ((Activity)context).getApplication()).sendSignalPresenceActivity(); + switch (v.getId()) { + case R.id.general:{ + ((ChatCallActivity) context).remoteCameraClick(); + break; + } + } + } + + public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ + + RelativeLayout rlGeneral; + RelativeLayout avatarMicroLayout; + RelativeLayout avatarLayout; + RoundedImageView avatarImage; + ImageView microAvatar; + TextView avatarInitialLetter; + public RelativeLayout surfaceViewLayout; + public ImageView microSurface; + public SurfaceView surfaceView; + public MegaSurfaceRendererGroup localRenderer; + SurfaceHolder localSurfaceHolder; + + public ViewHolderGroupCall(View itemView) { + super(itemView); + } + + } + + public class ViewHolderGroupCallGrid extends BigGroupCallAdapter.ViewHolderGroupCall { + public ViewHolderGroupCallGrid(View v) { + super(v); + } + + } + + BigGroupCallAdapter.ViewHolderGroupCallGrid holderGrid = null; + + @Override public BigGroupCallAdapter.ViewHolderGroupCall onCreateViewHolder(ViewGroup parent, int viewType) { + log("onCreateViewHolder()"); + + display = ((ChatCallActivity) context).getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics(); + display.getMetrics(outMetrics); + widthScreenPX = outMetrics.widthPixels; + heightScreenPX = outMetrics.heightPixels; + density = context.getResources().getDisplayMetrics().density; + scaleW = Util.getScaleW(outMetrics, density); + scaleH = Util.getScaleH(outMetrics, density); + + maxScreenHeight = parent.getMeasuredHeight(); + maxScreenWidth = parent.getMeasuredWidth(); + + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); + int numPeersOnCall = getItemCount(); + + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); + + + if(numPeersOnCall < 4) { + lp.height = maxScreenHeight / numPeersOnCall; + lp.width = maxScreenWidth; + + }else if(numPeersOnCall == 4){ + lp.height = maxScreenHeight / 2; + lp.width = maxScreenWidth/2; + + }else if(numPeersOnCall > 4){ + lp.height = Util.scaleWidthPx(180, outMetrics); + lp.width = maxScreenWidth/2; + + } + + v.setLayoutParams(lp); + + holderGrid = new BigGroupCallAdapter.ViewHolderGroupCallGrid(v); + holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); + holderGrid.rlGeneral.setOnClickListener(this); + + holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); + holderGrid.surfaceViewLayout.removeAllViewsInLayout(); + + holderGrid.avatarMicroLayout = (RelativeLayout) v.findViewById(R.id.layout_avatar_micro); + + holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holderGrid.avatarLayout.setLayoutParams(layoutParams); + + holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); + + holderGrid.microSurface = new ImageView(context); + holderGrid.microSurface.setVisibility(View.GONE); + + holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); + holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); + + v.setTag(holderGrid); + return holderGrid; + + } + + @Override + public int getItemViewType(int position) { + return adapterType; + } + + @Override + public void onBindViewHolder(BigGroupCallAdapter.ViewHolderGroupCall holder, int position) { + log("onBindViewHolder"); + if (adapterType == BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID){ + BigGroupCallAdapter.ViewHolderGroupCallGrid holderGrid2 = (BigGroupCallAdapter.ViewHolderGroupCallGrid) holder; + onBindViewHolderGrid(holderGrid2, position); + } + } + + public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid holder, int position){ + log("onBindViewHolderGrid()"); + + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + + int numPeersOnCall = getItemCount(); + if(peer.isVideoOn()) { + log("Video ON"); + if(numPeersOnCall == 1){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = maxScreenWidth; + layoutParamsSurface.height = maxScreenWidth; + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 2){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 3){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 4){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 5){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + + + }else if(numPeersOnCall == 6){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + +// if((position < 2)){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// +// }else if(position > 3){ +// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + } + + holder.avatarMicroLayout.setVisibility(GONE); + holder.microAvatar.setVisibility(View.GONE); + + //Clear surfaceViewLayout + if(holder.surfaceViewLayout.getChildCount() != 0){ + holder.surfaceViewLayout.removeAllViewsInLayout(); + } + if(peer.getListenerB() != null){ + peer.setListenerB(null); + } + + //Create Surface View + holder.surfaceView = new SurfaceView(context); + holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); + holder.surfaceView.setZOrderMediaOverlay(true); + holder.localSurfaceHolder = holder.surfaceView.getHolder(); + holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView); + holder.surfaceViewLayout.addView(holder.surfaceView); + + //Update micro icon + holder.microSurface.setImageResource(R.drawable.ic_mic_off); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, 50, 50, 0); + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + + if(peer.isAudioOn()){ + holder.microSurface.setVisibility(View.GONE); + }else{ + if(isCallInProgress) { + holder.microSurface.setVisibility(View.VISIBLE); + }else{ + holder.microSurface.setVisibility(View.GONE); + } + } + + holder.surfaceViewLayout.setVisibility(View.VISIBLE); + + //Create listener + BigGroupCallListener listenerPeer = new BigGroupCallListener(context, holder); + peer.setListenerB(listenerPeer); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video ON-> addChatLocalVideoListener() "); + megaChatApi.addChatLocalVideoListener(chatId, peer.getListenerB()); + + } else { + log("Video ON-> addChatRemoteVideoListener()"); + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListenerB()); + } + + }else{ + log("Video OFF"); + if(numPeersOnCall == 1){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = maxScreenWidth; + layoutParamsAvatar.height = maxScreenWidth; + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 2){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 3){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 4){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 5){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + +// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ +// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); +// layoutParamsPeer.width = maxScreenWidth; +// layoutParamsPeer.height = (maxScreenHeight/3); +// holder.rlGeneral.setLayoutParams(layoutParamsPeer); +// } + + }else if(numPeersOnCall == 6){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + +// if((position < 2)){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); +// }else if(position > 3){ +// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); +// } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + } + + holder.microSurface.setVisibility(View.GONE); + + //Clear surfaceViewLayout + holder.surfaceViewLayout.removeAllViewsInLayout(); + holder.surfaceViewLayout.setVisibility(View.GONE); + + //Create the avatar + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + setProfileMyAvatar(holder); + }else{ + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); + } + + //Update micro icon + if(peer.isAudioOn()){ + holder.microAvatar.setVisibility(View.GONE); + }else{ + if(isCallInProgress){ + holder.microAvatar.setVisibility(View.VISIBLE); + }else{ + holder.microAvatar.setVisibility(View.GONE); + } + } + + holder.avatarMicroLayout.setVisibility(View.VISIBLE); + + //Remove listener + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + log("Video OFF-> removeChatMyVideoListener()"); + megaChatApi.removeChatVideoListener(chatId, -1, peer.getListenerB()); + peer.setListenerB(null); + }else{ + log("Video OFF-> removeChatVideoListener()"); + megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListenerB()); + peer.setListenerB(null); + } + } + } + + @Override + public int getItemCount() { + if (peers != null){ + return peers.size(); + }else{ + return 0; + } + } + + public Object getItem(int position) { + log("getItem() position "+position); + + if (peers != null){ + return peers.get(position); + } + return null; + } + + + public InfoPeerGroupCall getNodeAt(int position) { + log("getNodeAt() position "+position); + + try { + if (peers != null) { + return peers.get(position); + } + } catch (IndexOutOfBoundsException e) { + } + return null; + } + + //My AVATAR + public void setProfileMyAvatar(BigGroupCallAdapter.ViewHolderGroupCall holder) { + log("setProfileMyAvatar()"); + + Bitmap myBitmap = null; + File avatar = null; + if (context != null) { + log("context is not null"); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } + } + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); + if (myBitmap != null) { + holder.avatarImage.setImageBitmap(myBitmap); + holder.avatarInitialLetter.setVisibility(GONE); + } + else{ + createMyDefaultAvatar(holder); + } + } + else { + createMyDefaultAvatar(holder); + } + } else { + createMyDefaultAvatar(holder); + } + } + + public void createMyDefaultAvatar(BigGroupCallAdapter.ViewHolderGroupCall holder) { + log("createMyDefaultAvatar()"); + + String myFullName = megaChatApi.getMyFullname(); + String myFirstLetter=myFullName.charAt(0) + ""; + myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); + long userHandle = megaChatApi.getMyUserHandle(); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels,outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + + if(color!=null){ + log("The color to set the avatar is "+color); + p.setColor(Color.parseColor(color)); + } + else{ + log("Default color to the avatar"); + p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) + radius = defaultAvatar.getWidth()/2; + else + radius = defaultAvatar.getHeight()/2; + + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + holder.avatarImage.setImageBitmap(defaultAvatar); + holder.avatarInitialLetter.setText(myFirstLetter); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + + } + + + public void setProfileContactAvatar(long userHandle, String fullName, BigGroupCallAdapter.ViewHolderGroupCall holder){ + log("setProfileContactAvatar"); + Bitmap bitmap = null; + File avatar = null; + String contactMail = megaChatApi.getContactEmail(userHandle); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); + if (bitmap != null) { + holder.avatarImage.setVisibility(View.VISIBLE); + holder.avatarImage.setImageBitmap(bitmap); + holder.avatarInitialLetter.setVisibility(GONE); + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + avatar.delete(); + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatar(userHandle, fullName, holder); + } + } + + public void createDefaultAvatar(long userHandle, String fullName, BigGroupCallAdapter.ViewHolderGroupCall holder) { + log("createDefaultAvatar"); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + p.setColor(Color.parseColor(color)); + } else { + p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + holder.avatarImage.setVisibility(View.VISIBLE); + holder.avatarImage.setImageBitmap(defaultAvatar); + String contactFirstLetter = fullName.charAt(0) + ""; + contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); + holder.avatarInitialLetter.setText(contactFirstLetter); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + + } + + public void setAdapterType(int adapterType){ + this.adapterType = adapterType; + } + private static void log(String log) { + Util.log("BigGroupCallAdapter", log); + } + + public RecyclerView getListFragment() { + return recyclerViewFragment; + } + + public void setListFragment(RecyclerView recyclerViewFragment) { + this.recyclerViewFragment = recyclerViewFragment; + } + + + public void changesInAudio(int position, BigGroupCallAdapter.ViewHolderGroupCall holder){ + log("changesInAudio"); + if(holder == null){ + holder = (BigGroupCallAdapter.ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + if(peer.isAudioOn()){ + log("Audio ON"); + holder.microAvatar.setVisibility(View.GONE); + holder.microSurface.setVisibility(View.GONE); + }else{ + log("Audio OFF"); + if(!peer.isVideoOn()){ + holder.microAvatar.setVisibility(View.VISIBLE); + holder.microSurface.setVisibility(View.GONE); + }else{ + holder.microSurface.setVisibility(View.VISIBLE); + holder.microAvatar.setVisibility(View.GONE); + } + } + }else{ + log("holder is NULL"); + notifyItemChanged(position); + } + } + +} diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index bf86f94a874..efbfdc69de5 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -35,6 +35,12 @@ android:layout_centerHorizontal="true" android:nestedScrollingEnabled="false"/> + + From 245c99373c6d1553e89f04fc3810b5c60795d993 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 11 Sep 2018 14:21:36 +0200 Subject: [PATCH 056/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 143 +++++++++++++- .../chatAdapters/BigGroupCallAdapter.java | 174 +----------------- .../main/res/layout/activity_calls_chat.xml | 13 +- .../res/layout/item_big_camera_group_call.xml | 73 ++++++++ 4 files changed, 217 insertions(+), 186 deletions(-) create mode 100644 app/src/main/res/layout/item_big_camera_group_call.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index dfc11901577..b8e8885784a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -615,6 +615,7 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setVisibility(GONE); //Recycler View for 6-8 peers + log("onCreate()"); layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); BigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); BigRecyclerView.setLayoutManager(layoutManager); @@ -724,6 +725,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -791,6 +793,7 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -1941,7 +1944,11 @@ public void updateLocalVideoStatus(){ if(!item.isVideoOn()){ log("activate Local Video for "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(true); - adapter.notifyItemChanged(peersOnCall.size()-1); + if(peersOnCall.size()<7){ + BigAdapter.notifyItemChanged(peersOnCall.size()-1); + }else{ + adapter.notifyItemChanged(peersOnCall.size()-1); + } } } }else { @@ -1953,7 +1960,11 @@ public void updateLocalVideoStatus(){ if(item.isVideoOn()){ log("remove Local Video fot "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(false); - adapter.notifyItemChanged(peersOnCall.size()-1); + if(peersOnCall.size()<7){ + BigAdapter.notifyItemChanged(peersOnCall.size()-1); + }else{ + adapter.notifyItemChanged(peersOnCall.size()-1); + } } } } @@ -2047,6 +2058,11 @@ public void updateLocalAudioStatus(){ item.setAudioOn(true); int position = peersOnCall.size() -1; adapter.changesInAudio(position,null); + if(peersOnCall.size()<7){ + BigAdapter.changesInAudio(position,null); + }else{ + adapter.changesInAudio(position,null); + } } } }else{ @@ -2058,7 +2074,11 @@ public void updateLocalAudioStatus(){ if(item.isAudioOn()){ item.setAudioOn(false); int position = peersOnCall.size() -1; - adapter.changesInAudio(position,null); + if(peersOnCall.size()<7){ + BigAdapter.changesInAudio(position,null); + }else{ + adapter.changesInAudio(position,null); + } } } @@ -2092,7 +2112,11 @@ public void updateRemoteVideoStatus(long userHandle){ if(!peersOnCall.get(i).isVideoOn()){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera TRUE"); peersOnCall.get(i).setVideoOn(true); - adapter.notifyItemChanged(i); + if(peersOnCall.size()<7){ + BigAdapter.notifyItemChanged(i); + }else{ + adapter.notifyItemChanged(i); + } break; } } @@ -2106,7 +2130,11 @@ public void updateRemoteVideoStatus(long userHandle){ if(peersOnCall.get(i).isVideoOn()){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera FALSE"); peersOnCall.get(i).setVideoOn(false); - adapter.notifyItemChanged(i); + if(peersOnCall.size()<7){ + BigAdapter.notifyItemChanged(i); + }else{ + adapter.notifyItemChanged(i); + } break; } } @@ -2202,7 +2230,11 @@ public void updateRemoteAudioStatus(long userHandle){ if(!peersOnCall.get(i).isAudioOn()){ log("remove Remote Audio for "+peersOnCall.get(i).getName()+" micro TRUE"); peersOnCall.get(i).setAudioOn(true); - adapter.changesInAudio(i,null); + if(peersOnCall.size()<7){ + BigAdapter.changesInAudio(i,null); + }else{ + adapter.changesInAudio(i,null); + } break; } } @@ -2216,7 +2248,11 @@ public void updateRemoteAudioStatus(long userHandle){ if(peersOnCall.get(i).isAudioOn()){ log("remove Remote Audio for "+peersOnCall.get(i).getName()+" micro FALSE"); peersOnCall.get(i).setAudioOn(false); - adapter.changesInAudio(i,null); + if(peersOnCall.size()<7){ + BigAdapter.changesInAudio(i,null); + }else{ + adapter.changesInAudio(i,null); + } break; } } @@ -2407,12 +2443,99 @@ public void animationAlphaArrows(final ImageView arrow){ } +// public void createNewAdapter(boolean flag){ +// log("createNewAdapter"); +// +// if(flag){ +// //arrayList-> peersOnCall +// if(peersOnCall.size() < 7){ +// BigRecyclerView.setAdapter(null); +// BigRecyclerView.setVisibility(GONE); +// +// if(peersOnCall.size() <= 4){ +// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); +// params.width = ViewGroup.LayoutParams.MATCH_PARENT; +// params.height = ViewGroup.LayoutParams.MATCH_PARENT; +// recyclerView.setLayoutParams(params); +// +// }else{ +// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); +// params.width = ViewGroup.LayoutParams.MATCH_PARENT; +// params.height = Util.scaleWidthPx(540, outMetrics); +// recyclerView.setLayoutParams(params); +// +// } +// if(peersOnCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } +// }else{ +// recyclerView.setAdapter(null); +// recyclerView.setVisibility(GONE); +// +// BigRecyclerView.setAdapter(null); +// BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersOnCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); +// BigRecyclerView.setAdapter(BigAdapter); +// if (BigAdapter.getItemCount() == 0){ +// BigRecyclerView.setVisibility(View.GONE); +// }else{ +// BigRecyclerView.setVisibility(View.VISIBLE); +// } +// } +// +// }else{ +// //arrayList-> peersBeforeCall +// +// if(peersOnCall.size() < 7) { +// BigRecyclerView.setAdapter(null); +// BigRecyclerView.setVisibility(GONE); +// +// if(peersBeforeCall.size() <= 3){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// } +// recyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); +// recyclerView.setAdapter(adapter); +// if (adapter.getItemCount() == 0){ +// recyclerView.setVisibility(View.GONE); +// }else{ +// recyclerView.setVisibility(View.VISIBLE); +// } +// }else{ +// recyclerView.setAdapter(null); +// recyclerView.setVisibility(GONE); +// +// BigRecyclerView.setAdapter(null); +// BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersBeforeCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); +// BigRecyclerView.setAdapter(BigAdapter); +// if (BigAdapter.getItemCount() == 0){ +// BigRecyclerView.setVisibility(View.GONE); +// }else{ +// BigRecyclerView.setVisibility(View.VISIBLE); +// } +// } +// +// } +// +// } + public void createNewAdapter(boolean flag){ log("createNewAdapter"); if(flag){ //arrayList-> peersOnCall - if(peersOnCall.size() < 7){ + if(peersOnCall.size() > 7){ BigRecyclerView.setAdapter(null); BigRecyclerView.setVisibility(GONE); @@ -2443,6 +2566,7 @@ public void createNewAdapter(boolean flag){ recyclerView.setVisibility(View.VISIBLE); } }else{ + log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); @@ -2459,7 +2583,7 @@ public void createNewAdapter(boolean flag){ }else{ //arrayList-> peersBeforeCall - if(peersOnCall.size() < 7) { + if(peersOnCall.size() > 7) { BigRecyclerView.setAdapter(null); BigRecyclerView.setVisibility(GONE); @@ -2494,4 +2618,5 @@ public void createNewAdapter(boolean flag){ } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java index 281d4f0fc8c..32b196ab8b5 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java @@ -158,27 +158,7 @@ public ViewHolderGroupCallGrid(View v) { maxScreenHeight = parent.getMeasuredHeight(); maxScreenWidth = parent.getMeasuredWidth(); - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); - int numPeersOnCall = getItemCount(); - - CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - - - if(numPeersOnCall < 4) { - lp.height = maxScreenHeight / numPeersOnCall; - lp.width = maxScreenWidth; - - }else if(numPeersOnCall == 4){ - lp.height = maxScreenHeight / 2; - lp.width = maxScreenWidth/2; - - }else if(numPeersOnCall > 4){ - lp.height = Util.scaleWidthPx(180, outMetrics); - lp.width = maxScreenWidth/2; - - } - - v.setLayoutParams(lp); + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_big_camera_group_call, parent, false); holderGrid = new BigGroupCallAdapter.ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); @@ -232,76 +212,7 @@ public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid ho int numPeersOnCall = getItemCount(); if(peer.isVideoOn()) { log("Video ON"); - if(numPeersOnCall == 1){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = maxScreenWidth; - layoutParamsSurface.height = maxScreenWidth; - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 2){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 3){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 4){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else{ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 5){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - - }else if(numPeersOnCall == 6){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); // -// }else if(position > 3){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - } holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -328,7 +239,7 @@ public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid ho RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, 50, 50, 0); + paramsMicroSurface.setMargins(0, 4, 4, 0); holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); if(peer.isAudioOn()){ @@ -357,87 +268,6 @@ public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid ho }else{ log("Video OFF"); - if(numPeersOnCall == 1){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = maxScreenWidth; - layoutParamsAvatar.height = maxScreenWidth; - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 2){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 3){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 4){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else{ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 5){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParamsPeer.width = maxScreenWidth; -// layoutParamsPeer.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParamsPeer); -// } - - }else if(numPeersOnCall == 6){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - } holder.microSurface.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index efbfdc69de5..0232b4b00fb 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -35,11 +35,14 @@ android:layout_centerHorizontal="true" android:nestedScrollingEnabled="false"/> - + diff --git a/app/src/main/res/layout/item_big_camera_group_call.xml b/app/src/main/res/layout/item_big_camera_group_call.xml new file mode 100644 index 00000000000..95b859667d3 --- /dev/null +++ b/app/src/main/res/layout/item_big_camera_group_call.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + From b2b49891dcdec48062f0d446b3db7dcb8dc5badb Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 12 Sep 2018 14:58:59 +0200 Subject: [PATCH 057/247] Feature#9775-Group calls UI --- .idea/misc.xml | 2 +- .../listeners/BigGroupCallListener.java | 15 ++- .../megachat/calls/ChatCallActivity.java | 26 +++-- .../calls/MegaSurfaceRendererGroup.java | 100 ++++++++---------- .../chatAdapters/BigGroupCallAdapter.java | 31 ++++-- .../chatAdapters/GroupCallAdapter.java | 2 +- 6 files changed, 102 insertions(+), 74 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 635999df1e8..ba7052b8197 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java index 6f1145eead8..ebe1351e6f4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java @@ -21,7 +21,6 @@ public class BigGroupCallListener implements MegaChatVideoListenerInterface { Bitmap bitmap; public BigGroupCallListener(Context context, BigGroupCallAdapter.ViewHolderGroupCall holder) { - log("BigGroupCallListener"); this.context = context; this.holder = holder; this.width = 0; @@ -38,7 +37,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.width = width; this.height = height; - SurfaceHolder Sholder = holder.surfaceView.getHolder(); if (Sholder != null) { int viewWidth = holder.surfaceView.getWidth(); @@ -48,12 +46,12 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei int holderWidth = viewWidth < width ? viewWidth : width; int holderHeight = holderWidth * viewHeight / viewWidth; if (holderHeight > viewHeight) { - holderHeight = viewHeight; holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = holder.localRenderer.CreateBitmap(width, height); Sholder.setFixedSize(holderWidth, holderHeight); + }else{ this.width = -1; this.height = -1; @@ -63,7 +61,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app holder.localRenderer.DrawBitmap(false); @@ -79,8 +76,16 @@ public void setHeight(int height) { this.height = height; } + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + private static void log(String log) { - Util.log("GroupCallListener", log); + Util.log("BigGroupCallListener", log); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b8e8885784a..cdc711c588b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -794,6 +794,7 @@ protected void onCreate(Bundle savedInstanceState) { }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -1132,13 +1133,26 @@ protected void onResume() { log("onResume"); if(peersOnCall!=null){ if(peersOnCall.size()!=0){ - for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListener()!=null){ - peer.getListener().setHeight(0); - peer.getListener().setWidth(0); + if(peersOnCall.size()<7){ + for(InfoPeerGroupCall peer :peersOnCall){ + if(peer.getListenerB()!=null){ + if(peer.getListenerB().getHeight() != 0){ + peer.getListenerB().setHeight(0); + } + if(peer.getListenerB().getWidth() != 0){ + peer.getListenerB().setWidth(0); + } + } + } + }else{ + for(InfoPeerGroupCall peer :peersOnCall){ + if(peer.getListener()!=null){ + peer.getListener().setHeight(0); + peer.getListener().setWidth(0); + } } - } + } } @@ -1152,8 +1166,6 @@ protected void onResume() { if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){ ((MegaApplication) getApplication()).sendSignalPresenceActivity(); } - - } @Override diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index a943346abda..f33a11613d1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -36,6 +36,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -56,6 +58,8 @@ import org.webrtc.Logging; import mega.privacy.android.app.R; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; +import mega.privacy.android.app.utils.Util; public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { @@ -75,24 +79,28 @@ public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { PorterDuffXfermode modesrcin; int surfaceWidth = 0; int surfaceHeight = 0; + Long handleUser; + protected List listeners; - public MegaSurfaceRendererGroup(SurfaceView view) { - Log.d("MegaSurfaceRenderer","MegaSurfaceRenderer() "); -// this.surf = view; + public MegaSurfaceRendererGroup(SurfaceView view, Long handle) { + surfaceHolder = view.getHolder(); if(surfaceHolder == null) return; + surfaceHolder.addCallback(this); paint = new Paint(); modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); + this.handleUser = handle; + listeners = new ArrayList(); } // surfaceChanged and surfaceCreated share this function private void changeDestRect(int dstWidth, int dstHeight) { - Log.d("SurfaceRendererGroup","changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); + log("changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); surfaceWidth = dstWidth; surfaceHeight = dstHeight; dstRect.top = 0; @@ -100,28 +108,16 @@ private void changeDestRect(int dstWidth, int dstHeight) { dstRect.right = dstWidth; dstRect.bottom = dstHeight; dstRectf = new RectF(dstRect); - -// adjustAspectRatio(); } -// private void adjustAspectRatio() { -// if (bitmap != null && dstRect.height() != 0) { -// float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); -// dstRect.top = 0; -// dstRect.left = 0; -// dstRect.right = surfaceWidth; -// dstRect.bottom = (int)(surfaceWidth/srcaspectratio); -// dstRectf = new RectF(dstRect); -// } -// } - public void surfaceCreated(SurfaceHolder holder) { - Log.d("MegaSurfaceRenderer","surfaceCreated()"); + log("surfaceCreated()"); - Canvas canvas = surfaceHolder.lockCanvas(); + Canvas canvas = holder.lockCanvas(); if(canvas != null) { - Rect dst = surfaceHolder.getSurfaceFrame(); + Rect dst = holder.getSurfaceFrame(); if(dst != null) { + notifyStateToAll(); changeDestRect(dst.right - dst.left, dst.bottom - dst.top); Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + " dst.left:" + dst.left + @@ -137,12 +133,12 @@ public void surfaceCreated(SurfaceHolder holder) { " dstRect.right:" + dstRect.right + " dstRect.bottom:" + dstRect.bottom); } - surfaceHolder.unlockCanvasAndPost(canvas); + holder.unlockCanvasAndPost(canvas); } } public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - Log.d("MegaSurfaceRenderer","surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); changeDestRect(in_width, in_height); @@ -160,21 +156,21 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - Log.d("MegaSurfaceRenderer","surfaceDestroyed(): "); - + log("surfaceDestroyed(): "); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; + surfaceWidth = 0; + surfaceHeight = 0; } public Bitmap CreateBitmap(int width, int height) { - Log.d("MegaSurfaceRenderer","CreateBitmap(): width = "+width+", height = "+height); + log("CreateBitmap(): width = "+width+", height = "+height); Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); if (bitmap == null) { try { - android.os.Process.setThreadPriority( - android.os.Process.THREAD_PRIORITY_DISPLAY); + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY); } catch (Exception e) { } @@ -194,13 +190,6 @@ public Bitmap CreateBitmap(int width, int height) { srcRect.bottom = newHeight; srcRect.left = 0; srcRect.right = width; -// float decrease = height - newHeight; -// int decreaseHalf = (int) (decrease/2); -// -// srcRect.top = decreaseHalf; -// srcRect.bottom = (height - decreaseHalf); -// srcRect.left = 0; -// srcRect.right = width; }else{ int newWidth = height; bitmap = Bitmap.createBitmap(newWidth, height, Bitmap.Config.ARGB_8888); @@ -208,30 +197,14 @@ public Bitmap CreateBitmap(int width, int height) { srcRect.right = newWidth; srcRect.top = 0; srcRect.bottom = height; -// float decrease = width - newWidth; -// int decreaseHalf = (int) (decrease/2); -// -// srcRect.left = decreaseHalf; -// srcRect.right = (width - decreaseHalf); -// srcRect.top = 0; -// srcRect.bottom = height; } - -// bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); -// srcRect.left = 0; -// srcRect.top = 0; -// srcRect.bottom = height; -// srcRect.right = width; -// adjustAspectRatio(); - return bitmap; } public void DrawBitmap(boolean flag) { - - if(bitmap == null) + if(bitmap == null){ return; - + } if (surfaceHolder == null){ return; } @@ -249,9 +222,30 @@ public void DrawBitmap(boolean flag) { } else { canvas.drawBitmap(bitmap, srcRect, dstRect, null); } - surfaceHolder.unlockCanvasAndPost(canvas); } } + private static void log(String log) { + Util.log("MegaSurfaceRendererGroup", log); + } + private void notifyStateToAll() { + for(MegaSurfaceRendererGroupListener listener : listeners) + notifyState(listener); + } + + public void addListener(MegaSurfaceRendererGroupListener l) { + listeners.add(l); + notifyState(l); + } + + private void notifyState(MegaSurfaceRendererGroupListener listener) { + if(listener == null) + return; + listener.resetSize(handleUser); + } + + public interface MegaSurfaceRendererGroupListener { + public void resetSize(Long handle); + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java index 32b196ab8b5..5ed314a7beb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java @@ -43,7 +43,7 @@ import static android.view.View.GONE; -public class BigGroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener { +public class BigGroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { public static final int ITEM_VIEW_TYPE_GRID = 1; @@ -114,6 +114,24 @@ public void onClick(View v) { } } + @Override + public void resetSize(Long userHandle) { + if(getItemCount()!=0){ + for(InfoPeerGroupCall peer:peers){ + if(peer.getHandle() == userHandle){ + if(peer.getListenerB()!=null){ + if(peer.getListenerB().getWidth()!=0){ + peer.getListenerB().setWidth(0); + } + if(peer.getListenerB().getHeight()!=0){ + peer.getListenerB().setHeight(0); + } + } + } + } + } + } + public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ RelativeLayout rlGeneral; @@ -209,10 +227,8 @@ public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid ho return; } - int numPeersOnCall = getItemCount(); if(peer.isVideoOn()) { log("Video ON"); -// holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -231,8 +247,9 @@ public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid ho holder.surfaceView.setZOrderMediaOverlay(true); holder.localSurfaceHolder = holder.surfaceView.getHolder(); holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView); + holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); + holder.localRenderer.addListener(this); //Update micro icon holder.microSurface.setImageResource(R.drawable.ic_mic_off); @@ -521,9 +538,6 @@ public void createDefaultAvatar(long userHandle, String fullName, BigGroupCallA public void setAdapterType(int adapterType){ this.adapterType = adapterType; } - private static void log(String log) { - Util.log("BigGroupCallAdapter", log); - } public RecyclerView getListFragment() { return recyclerViewFragment; @@ -563,5 +577,8 @@ public void changesInAudio(int position, BigGroupCallAdapter.ViewHolderGroupCall notifyItemChanged(position); } } + private static void log(String log) { + Util.log("BigGroupCallAdapter", log); + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index c543a99c7c6..df6ad73bf86 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -372,7 +372,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceView.setZOrderMediaOverlay(true); holder.localSurfaceHolder = holder.surfaceView.getHolder(); holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView); + holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); //Update micro icon From d3c8f1ca8e22a1aa9b91509fb88e73fdc4b5828b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 13 Sep 2018 11:04:57 +0200 Subject: [PATCH 058/247] Feature#9775-Group calls UI --- .../listeners/BigGroupCallListener.java | 92 --- .../lollipop/listeners/GroupCallListener.java | 8 + .../megachat/calls/ChatCallActivity.java | 290 +++------ .../megachat/calls/InfoPeerGroupCall.java | 16 +- .../calls/MegaSurfaceRendererGroup.java | 1 - .../chatAdapters/BigGroupCallAdapter.java | 584 ------------------ .../chatAdapters/GroupCallAdapter.java | 182 +++--- .../res/layout/item_big_camera_group_call.xml | 73 --- .../res/layout/item_camera_group_call.xml | 2 - 9 files changed, 191 insertions(+), 1057 deletions(-) delete mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java delete mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java delete mode 100644 app/src/main/res/layout/item_big_camera_group_call.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java deleted file mode 100644 index ebe1351e6f4..00000000000 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/BigGroupCallListener.java +++ /dev/null @@ -1,92 +0,0 @@ -package mega.privacy.android.app.lollipop.listeners; - -import android.content.Context; -import android.graphics.Bitmap; -import android.view.SurfaceHolder; - -import java.nio.ByteBuffer; -import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; -import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; -import mega.privacy.android.app.utils.Util; -import nz.mega.sdk.MegaChatApiJava; -import nz.mega.sdk.MegaChatVideoListenerInterface; - -public class BigGroupCallListener implements MegaChatVideoListenerInterface { - - Context context; - BigGroupCallAdapter.ViewHolderGroupCall holder; - - int width; - int height; - Bitmap bitmap; - - public BigGroupCallListener(Context context, BigGroupCallAdapter.ViewHolderGroupCall holder) { - this.context = context; - this.holder = holder; - this.width = 0; - this.height = 0; - } - - @Override - public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { - if((width == 0) || (height == 0)){ - return; - } - - if (this.width != width || this.height != height) { - this.width = width; - this.height = height; - - SurfaceHolder Sholder = holder.surfaceView.getHolder(); - if (Sholder != null) { - int viewWidth = holder.surfaceView.getWidth(); - int viewHeight = holder.surfaceView.getHeight(); - - if ((viewWidth != 0) && (viewHeight != 0)) { - int holderWidth = viewWidth < width ? viewWidth : width; - int holderHeight = holderWidth * viewHeight / viewWidth; - if (holderHeight > viewHeight) { - holderHeight = viewHeight; - holderWidth = holderHeight * viewWidth / viewHeight; - } - this.bitmap = holder.localRenderer.CreateBitmap(width, height); - Sholder.setFixedSize(holderWidth, holderHeight); - - }else{ - this.width = -1; - this.height = -1; - } - } - } - - if (bitmap != null) { - bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. - // The renderer has been modified a bit and an update of WebRTC could break our app - holder.localRenderer.DrawBitmap(false); - } - } - - - public void setWidth(int width) { - this.width = width; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - private static void log(String log) { - Util.log("BigGroupCallListener", log); - } - -} - diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index fc7b9651c5f..eee2e968036 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -83,6 +83,14 @@ public void setHeight(int height) { this.height = height; } + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + private static void log(String log) { Util.log("GroupCallListener", log); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index cdc711c588b..7b760b75b21 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -79,7 +79,6 @@ import mega.privacy.android.app.lollipop.LoginActivityLollipop; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; -import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; @@ -157,10 +156,10 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque CustomizedGridCallRecyclerView recyclerView; LinearLayoutManager layoutManager; - RecyclerView BigRecyclerView; + RecyclerView bigRecyclerView; GroupCallAdapter adapter; - BigGroupCallAdapter BigAdapter; +// BigGroupCallAdapter BigAdapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -320,7 +319,7 @@ public void updateScreenStatusInProgress(){ if (!peerContain) { if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; }else{ @@ -328,7 +327,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); changes = true; } @@ -348,7 +347,7 @@ public void updateScreenStatusInProgress(){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; }else{ @@ -356,7 +355,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null); peersOnCall.add(0, userPeer); changes = true; }else{ @@ -617,9 +616,9 @@ protected void onCreate(Bundle savedInstanceState) { //Recycler View for 6-8 peers log("onCreate()"); layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); - BigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); - BigRecyclerView.setLayoutManager(layoutManager); - BigRecyclerView.setVisibility(GONE); + bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); + bigRecyclerView.setLayoutManager(layoutManager); + bigRecyclerView.setVisibility(GONE); //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); @@ -726,20 +725,22 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); - MyRingerTask myRingerTask = new MyRingerTask(); - ringerTimer.schedule(myRingerTask, 0, 500); - - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] pattern = {0, 1000, 500, 500, 1000}; - if (vibrator != null){ - if (vibrator.hasVibrator()){ - //FOR API>=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } + //**** Descomentar + +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ log("Incoming group call"); @@ -763,7 +764,7 @@ protected void onCreate(Bundle savedInstanceState) { long userHandle = callChat.getParticipants().get(i); log("onCreate()-Incoming Call: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -793,17 +794,18 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ + //**** Descomentar - - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } +// +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("Outgoing group call"); @@ -821,7 +823,7 @@ protected void onCreate(Bundle savedInstanceState) { } log("onCreate()-OutgoingCall: peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); createNewAdapter(true); }else{ @@ -1135,12 +1137,12 @@ protected void onResume() { if(peersOnCall.size()!=0){ if(peersOnCall.size()<7){ for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListenerB()!=null){ - if(peer.getListenerB().getHeight() != 0){ - peer.getListenerB().setHeight(0); + if(peer.getListener()!=null){ + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); } - if(peer.getListenerB().getWidth() != 0){ - peer.getListenerB().setWidth(0); + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); } } } @@ -1348,13 +1350,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); peersOnCall.add(myPeer); createNewAdapter(true); } }else{ log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); peersOnCall.add(myPeer); createNewAdapter(true); } @@ -1460,7 +1462,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(!peerContain){ log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); createNewAdapter(true); } @@ -1551,7 +1553,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ long userHandle = call.getParticipants().get(i); log("CHANGE_TYPE_CALL_COMPOSITION: peersBeforeCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null,null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -1956,11 +1958,7 @@ public void updateLocalVideoStatus(){ if(!item.isVideoOn()){ log("activate Local Video for "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(true); - if(peersOnCall.size()<7){ - BigAdapter.notifyItemChanged(peersOnCall.size()-1); - }else{ - adapter.notifyItemChanged(peersOnCall.size()-1); - } + adapter.notifyItemChanged(peersOnCall.size()-1); } } }else { @@ -1972,11 +1970,7 @@ public void updateLocalVideoStatus(){ if(item.isVideoOn()){ log("remove Local Video fot "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(false); - if(peersOnCall.size()<7){ - BigAdapter.notifyItemChanged(peersOnCall.size()-1); - }else{ - adapter.notifyItemChanged(peersOnCall.size()-1); - } + adapter.notifyItemChanged(peersOnCall.size()-1); } } } @@ -2070,11 +2064,7 @@ public void updateLocalAudioStatus(){ item.setAudioOn(true); int position = peersOnCall.size() -1; adapter.changesInAudio(position,null); - if(peersOnCall.size()<7){ - BigAdapter.changesInAudio(position,null); - }else{ - adapter.changesInAudio(position,null); - } + } } }else{ @@ -2086,11 +2076,7 @@ public void updateLocalAudioStatus(){ if(item.isAudioOn()){ item.setAudioOn(false); int position = peersOnCall.size() -1; - if(peersOnCall.size()<7){ - BigAdapter.changesInAudio(position,null); - }else{ - adapter.changesInAudio(position,null); - } + adapter.changesInAudio(position,null); } } @@ -2124,11 +2110,7 @@ public void updateRemoteVideoStatus(long userHandle){ if(!peersOnCall.get(i).isVideoOn()){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera TRUE"); peersOnCall.get(i).setVideoOn(true); - if(peersOnCall.size()<7){ - BigAdapter.notifyItemChanged(i); - }else{ - adapter.notifyItemChanged(i); - } + adapter.notifyItemChanged(i); break; } } @@ -2142,21 +2124,15 @@ public void updateRemoteVideoStatus(long userHandle){ if(peersOnCall.get(i).isVideoOn()){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera FALSE"); peersOnCall.get(i).setVideoOn(false); - if(peersOnCall.size()<7){ - BigAdapter.notifyItemChanged(i); - }else{ - adapter.notifyItemChanged(i); - } + adapter.notifyItemChanged(i); break; } } } } } - } - else{ + }else{ log("is individual"); - MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ @@ -2242,11 +2218,7 @@ public void updateRemoteAudioStatus(long userHandle){ if(!peersOnCall.get(i).isAudioOn()){ log("remove Remote Audio for "+peersOnCall.get(i).getName()+" micro TRUE"); peersOnCall.get(i).setAudioOn(true); - if(peersOnCall.size()<7){ - BigAdapter.changesInAudio(i,null); - }else{ - adapter.changesInAudio(i,null); - } + adapter.changesInAudio(i,null); break; } } @@ -2260,11 +2232,7 @@ public void updateRemoteAudioStatus(long userHandle){ if(peersOnCall.get(i).isAudioOn()){ log("remove Remote Audio for "+peersOnCall.get(i).getName()+" micro FALSE"); peersOnCall.get(i).setAudioOn(false); - if(peersOnCall.size()<7){ - BigAdapter.changesInAudio(i,null); - }else{ - adapter.changesInAudio(i,null); - } + adapter.changesInAudio(i,null); break; } } @@ -2273,8 +2241,7 @@ public void updateRemoteAudioStatus(long userHandle){ } } - } - else{ + }else{ supportInvalidateOptionsMenu(); } } @@ -2454,102 +2421,17 @@ public void animationAlphaArrows(final ImageView arrow){ arrow.startAnimation(alphaAnimArrows); } - -// public void createNewAdapter(boolean flag){ -// log("createNewAdapter"); -// -// if(flag){ -// //arrayList-> peersOnCall -// if(peersOnCall.size() < 7){ -// BigRecyclerView.setAdapter(null); -// BigRecyclerView.setVisibility(GONE); -// -// if(peersOnCall.size() <= 4){ -// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); -// params.width = ViewGroup.LayoutParams.MATCH_PARENT; -// params.height = ViewGroup.LayoutParams.MATCH_PARENT; -// recyclerView.setLayoutParams(params); -// -// }else{ -// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); -// params.width = ViewGroup.LayoutParams.MATCH_PARENT; -// params.height = Util.scaleWidthPx(540, outMetrics); -// recyclerView.setLayoutParams(params); -// -// } -// if(peersOnCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } -// }else{ -// recyclerView.setAdapter(null); -// recyclerView.setVisibility(GONE); -// -// BigRecyclerView.setAdapter(null); -// BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersOnCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); -// BigRecyclerView.setAdapter(BigAdapter); -// if (BigAdapter.getItemCount() == 0){ -// BigRecyclerView.setVisibility(View.GONE); -// }else{ -// BigRecyclerView.setVisibility(View.VISIBLE); -// } -// } -// -// }else{ -// //arrayList-> peersBeforeCall -// -// if(peersOnCall.size() < 7) { -// BigRecyclerView.setAdapter(null); -// BigRecyclerView.setVisibility(GONE); -// -// if(peersBeforeCall.size() <= 3){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// } -// recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); -// recyclerView.setAdapter(adapter); -// if (adapter.getItemCount() == 0){ -// recyclerView.setVisibility(View.GONE); -// }else{ -// recyclerView.setVisibility(View.VISIBLE); -// } -// }else{ -// recyclerView.setAdapter(null); -// recyclerView.setVisibility(GONE); -// -// BigRecyclerView.setAdapter(null); -// BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersBeforeCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); -// BigRecyclerView.setAdapter(BigAdapter); -// if (BigAdapter.getItemCount() == 0){ -// BigRecyclerView.setVisibility(View.GONE); -// }else{ -// BigRecyclerView.setVisibility(View.VISIBLE); -// } -// } -// -// } -// -// } - public void createNewAdapter(boolean flag){ log("createNewAdapter"); if(flag){ + //arrayList-> peersOnCall - if(peersOnCall.size() > 7){ - BigRecyclerView.setAdapter(null); - BigRecyclerView.setVisibility(GONE); + if(peersOnCall.size() < 7){ + log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" < 7"); + + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); if(peersOnCall.size() <= 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); @@ -2562,67 +2444,75 @@ public void createNewAdapter(boolean flag){ params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = Util.scaleWidthPx(540, outMetrics); recyclerView.setLayoutParams(params); - } + if(peersOnCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ recyclerView.setVisibility(View.VISIBLE); } + }else{ - log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()); + log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" >= 7"); + recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); - BigRecyclerView.setAdapter(null); - BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersOnCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); - BigRecyclerView.setAdapter(BigAdapter); - if (BigAdapter.getItemCount() == 0){ - BigRecyclerView.setVisibility(View.GONE); + bigRecyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + bigRecyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + bigRecyclerView.setVisibility(View.GONE); }else{ - BigRecyclerView.setVisibility(View.VISIBLE); + bigRecyclerView.setVisibility(View.VISIBLE); } } }else{ + //arrayList-> peersBeforeCall + if(peersBeforeCall.size() < 7) { + log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" < 7"); - if(peersOnCall.size() > 7) { - BigRecyclerView.setAdapter(null); - BigRecyclerView.setVisibility(GONE); + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); if(peersBeforeCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); } + recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, GroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); }else{ recyclerView.setVisibility(View.VISIBLE); } + }else{ + log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 7"); + recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); - BigRecyclerView.setAdapter(null); - BigAdapter = new BigGroupCallAdapter(this, BigRecyclerView, peersBeforeCall, chatId, BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID, flag); - BigRecyclerView.setAdapter(BigAdapter); - if (BigAdapter.getItemCount() == 0){ - BigRecyclerView.setVisibility(View.GONE); + bigRecyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); + bigRecyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ + bigRecyclerView.setVisibility(View.GONE); }else{ - BigRecyclerView.setVisibility(View.VISIBLE); + bigRecyclerView.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java index e66ca11cbbd..1d0385b0847 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java @@ -3,7 +3,6 @@ import android.view.SurfaceView; -import mega.privacy.android.app.lollipop.listeners.BigGroupCallListener; import mega.privacy.android.app.lollipop.listeners.GroupCallListener; public class InfoPeerGroupCall { @@ -12,18 +11,15 @@ public class InfoPeerGroupCall { boolean videoOn; boolean audioOn; GroupCallListener listener = null; - BigGroupCallListener listenerB = null; - SurfaceView surfaceview; - public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener, BigGroupCallListener listenerB, SurfaceView surfaceview) { + public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, GroupCallListener listener, SurfaceView surfaceview) { this.handle = handle; this.name = name; this.videoOn = videoOn; this.audioOn = audioOn; this.listener = listener; this.surfaceview = surfaceview; - this.listenerB = listenerB; } @@ -67,15 +63,6 @@ public void setListener(GroupCallListener listener) { this.listener = listener; } - public BigGroupCallListener getListenerB() { - return listenerB; - } - - public void setListenerB(BigGroupCallListener listenerB) { - this.listenerB = listenerB; - } - - public SurfaceView getSurfaceview() { return surfaceview; } @@ -83,5 +70,4 @@ public SurfaceView getSurfaceview() { public void setSurfaceview(SurfaceView surfaceview) { this.surfaceview = surfaceview; } - } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index f33a11613d1..8d4b187585e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -58,7 +58,6 @@ import org.webrtc.Logging; import mega.privacy.android.app.R; -import mega.privacy.android.app.lollipop.megachat.chatAdapters.BigGroupCallAdapter; import mega.privacy.android.app.utils.Util; public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java deleted file mode 100644 index 5ed314a7beb..00000000000 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/BigGroupCallAdapter.java +++ /dev/null @@ -1,584 +0,0 @@ -package mega.privacy.android.app.lollipop.megachat.chatAdapters; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PixelFormat; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.RecyclerView; -import android.util.DisplayMetrics; -import android.view.Display; -import android.view.LayoutInflater; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import java.io.File; -import java.util.ArrayList; -import java.util.Locale; - -import mega.privacy.android.app.MegaApplication; -import mega.privacy.android.app.R; -import mega.privacy.android.app.components.CustomizedGridRecyclerView; -import mega.privacy.android.app.components.RoundedImageView; -import mega.privacy.android.app.lollipop.listeners.BigGroupCallListener; -import mega.privacy.android.app.lollipop.listeners.GroupCallListener; -import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; -import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; -import mega.privacy.android.app.lollipop.megachat.calls.InfoPeerGroupCall; -import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRendererGroup; -import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; -import mega.privacy.android.app.utils.Util; -import nz.mega.sdk.MegaApiAndroid; -import nz.mega.sdk.MegaChatApiAndroid; - -import static android.view.View.GONE; - - -public class BigGroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { - - public static final int ITEM_VIEW_TYPE_GRID = 1; - - Context context; - MegaApiAndroid megaApi; - MegaChatApiAndroid megaChatApi = null; - Display display; - DisplayMetrics outMetrics; - float density; - float scaleW; - float scaleH; - float widthScreenPX, heightScreenPX; - boolean isCallInProgress = false; - - RecyclerView recyclerViewFragment; - - public ArrayList getPeers() { - return peers; - } - - public void setPeers(ArrayList peers) { - this.peers = peers; - } - - ArrayList peers; - long chatId; - - int maxScreenWidth, maxScreenHeight; - - boolean avatarRequested = false; - private int adapterType; - - public BigGroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType, boolean isCallInProgress) { - log("BigGroupCallAdapter( peers: "+peers.size()+")"); - - this.context = context; - this.recyclerViewFragment = recyclerView; - this.peers = peers; - this.chatId = chatId; - this.adapterType = adapterType; - this.isCallInProgress = isCallInProgress; - - MegaApplication app = (MegaApplication) ((Activity) context).getApplication(); - if (megaApi == null) { - megaApi = app.getMegaApi(); - } - - log("retryPendingConnections()"); - if (megaApi != null) { - log("---------retryPendingConnections"); - megaApi.retryPendingConnections(); - } - - if (megaChatApi == null) { - megaChatApi = app.getMegaChatApi(); - } - } - - @Override - public void onClick(View v) { - log("onClick"); - ((MegaApplication) ((Activity)context).getApplication()).sendSignalPresenceActivity(); - switch (v.getId()) { - case R.id.general:{ - ((ChatCallActivity) context).remoteCameraClick(); - break; - } - } - } - - @Override - public void resetSize(Long userHandle) { - if(getItemCount()!=0){ - for(InfoPeerGroupCall peer:peers){ - if(peer.getHandle() == userHandle){ - if(peer.getListenerB()!=null){ - if(peer.getListenerB().getWidth()!=0){ - peer.getListenerB().setWidth(0); - } - if(peer.getListenerB().getHeight()!=0){ - peer.getListenerB().setHeight(0); - } - } - } - } - } - } - - public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ - - RelativeLayout rlGeneral; - RelativeLayout avatarMicroLayout; - RelativeLayout avatarLayout; - RoundedImageView avatarImage; - ImageView microAvatar; - TextView avatarInitialLetter; - public RelativeLayout surfaceViewLayout; - public ImageView microSurface; - public SurfaceView surfaceView; - public MegaSurfaceRendererGroup localRenderer; - SurfaceHolder localSurfaceHolder; - - public ViewHolderGroupCall(View itemView) { - super(itemView); - } - - } - - public class ViewHolderGroupCallGrid extends BigGroupCallAdapter.ViewHolderGroupCall { - public ViewHolderGroupCallGrid(View v) { - super(v); - } - - } - - BigGroupCallAdapter.ViewHolderGroupCallGrid holderGrid = null; - - @Override public BigGroupCallAdapter.ViewHolderGroupCall onCreateViewHolder(ViewGroup parent, int viewType) { - log("onCreateViewHolder()"); - - display = ((ChatCallActivity) context).getWindowManager().getDefaultDisplay(); - outMetrics = new DisplayMetrics(); - display.getMetrics(outMetrics); - widthScreenPX = outMetrics.widthPixels; - heightScreenPX = outMetrics.heightPixels; - density = context.getResources().getDisplayMetrics().density; - scaleW = Util.getScaleW(outMetrics, density); - scaleH = Util.getScaleH(outMetrics, density); - - maxScreenHeight = parent.getMeasuredHeight(); - maxScreenWidth = parent.getMeasuredWidth(); - - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_big_camera_group_call, parent, false); - - holderGrid = new BigGroupCallAdapter.ViewHolderGroupCallGrid(v); - holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - holderGrid.rlGeneral.setOnClickListener(this); - - holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); - holderGrid.surfaceViewLayout.removeAllViewsInLayout(); - - holderGrid.avatarMicroLayout = (RelativeLayout) v.findViewById(R.id.layout_avatar_micro); - - holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holderGrid.avatarLayout.getLayoutParams(); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); - holderGrid.avatarLayout.setLayoutParams(layoutParams); - - holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); - - holderGrid.microSurface = new ImageView(context); - holderGrid.microSurface.setVisibility(View.GONE); - - holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); - holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - - v.setTag(holderGrid); - return holderGrid; - - } - - @Override - public int getItemViewType(int position) { - return adapterType; - } - - @Override - public void onBindViewHolder(BigGroupCallAdapter.ViewHolderGroupCall holder, int position) { - log("onBindViewHolder"); - if (adapterType == BigGroupCallAdapter.ITEM_VIEW_TYPE_GRID){ - BigGroupCallAdapter.ViewHolderGroupCallGrid holderGrid2 = (BigGroupCallAdapter.ViewHolderGroupCallGrid) holder; - onBindViewHolderGrid(holderGrid2, position); - } - } - - public void onBindViewHolderGrid (BigGroupCallAdapter.ViewHolderGroupCallGrid holder, int position){ - log("onBindViewHolderGrid()"); - - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; - } - - if(peer.isVideoOn()) { - log("Video ON"); - - holder.avatarMicroLayout.setVisibility(GONE); - holder.microAvatar.setVisibility(View.GONE); - - //Clear surfaceViewLayout - if(holder.surfaceViewLayout.getChildCount() != 0){ - holder.surfaceViewLayout.removeAllViewsInLayout(); - } - if(peer.getListenerB() != null){ - peer.setListenerB(null); - } - - //Create Surface View - holder.surfaceView = new SurfaceView(context); - holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - holder.surfaceView.setZOrderMediaOverlay(true); - holder.localSurfaceHolder = holder.surfaceView.getHolder(); - holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); - holder.surfaceViewLayout.addView(holder.surfaceView); - holder.localRenderer.addListener(this); - - //Update micro icon - holder.microSurface.setImageResource(R.drawable.ic_mic_off); - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, 4, 4, 0); - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - - if(peer.isAudioOn()){ - holder.microSurface.setVisibility(View.GONE); - }else{ - if(isCallInProgress) { - holder.microSurface.setVisibility(View.VISIBLE); - }else{ - holder.microSurface.setVisibility(View.GONE); - } - } - - holder.surfaceViewLayout.setVisibility(View.VISIBLE); - - //Create listener - BigGroupCallListener listenerPeer = new BigGroupCallListener(context, holder); - peer.setListenerB(listenerPeer); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video ON-> addChatLocalVideoListener() "); - megaChatApi.addChatLocalVideoListener(chatId, peer.getListenerB()); - - } else { - log("Video ON-> addChatRemoteVideoListener()"); - megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListenerB()); - } - - }else{ - log("Video OFF"); - - holder.microSurface.setVisibility(View.GONE); - - //Clear surfaceViewLayout - holder.surfaceViewLayout.removeAllViewsInLayout(); - holder.surfaceViewLayout.setVisibility(View.GONE); - - //Create the avatar - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - setProfileMyAvatar(holder); - }else{ - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); - } - - //Update micro icon - if(peer.isAudioOn()){ - holder.microAvatar.setVisibility(View.GONE); - }else{ - if(isCallInProgress){ - holder.microAvatar.setVisibility(View.VISIBLE); - }else{ - holder.microAvatar.setVisibility(View.GONE); - } - } - - holder.avatarMicroLayout.setVisibility(View.VISIBLE); - - //Remove listener - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video OFF-> removeChatMyVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, -1, peer.getListenerB()); - peer.setListenerB(null); - }else{ - log("Video OFF-> removeChatVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListenerB()); - peer.setListenerB(null); - } - } - } - - @Override - public int getItemCount() { - if (peers != null){ - return peers.size(); - }else{ - return 0; - } - } - - public Object getItem(int position) { - log("getItem() position "+position); - - if (peers != null){ - return peers.get(position); - } - return null; - } - - - public InfoPeerGroupCall getNodeAt(int position) { - log("getNodeAt() position "+position); - - try { - if (peers != null) { - return peers.get(position); - } - } catch (IndexOutOfBoundsException e) { - } - return null; - } - - //My AVATAR - public void setProfileMyAvatar(BigGroupCallAdapter.ViewHolderGroupCall holder) { - log("setProfileMyAvatar()"); - - Bitmap myBitmap = null; - File avatar = null; - if (context != null) { - log("context is not null"); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } - } - if (avatar.exists()) { - if (avatar.length() > 0) { - BitmapFactory.Options bOpts = new BitmapFactory.Options(); - bOpts.inPurgeable = true; - bOpts.inInputShareable = true; - myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); - if (myBitmap != null) { - holder.avatarImage.setImageBitmap(myBitmap); - holder.avatarInitialLetter.setVisibility(GONE); - } - else{ - createMyDefaultAvatar(holder); - } - } - else { - createMyDefaultAvatar(holder); - } - } else { - createMyDefaultAvatar(holder); - } - } - - public void createMyDefaultAvatar(BigGroupCallAdapter.ViewHolderGroupCall holder) { - log("createMyDefaultAvatar()"); - - String myFullName = megaChatApi.getMyFullname(); - String myFirstLetter=myFullName.charAt(0) + ""; - myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); - long userHandle = megaChatApi.getMyUserHandle(); - - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels,outMetrics.widthPixels, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint p = new Paint(); - p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); - - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - - if(color!=null){ - log("The color to set the avatar is "+color); - p.setColor(Color.parseColor(color)); - } - else{ - log("Default color to the avatar"); - p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); - } - - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) - radius = defaultAvatar.getWidth()/2; - else - radius = defaultAvatar.getHeight()/2; - - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - holder.avatarImage.setImageBitmap(defaultAvatar); - holder.avatarInitialLetter.setText(myFirstLetter); - holder.avatarInitialLetter.setVisibility(View.VISIBLE); - - } - - - public void setProfileContactAvatar(long userHandle, String fullName, BigGroupCallAdapter.ViewHolderGroupCall holder){ - log("setProfileContactAvatar"); - Bitmap bitmap = null; - File avatar = null; - String contactMail = megaChatApi.getContactEmail(userHandle); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } - - if (avatar.exists()) { - if (avatar.length() > 0) { - BitmapFactory.Options bOpts = new BitmapFactory.Options(); - bOpts.inPurgeable = true; - bOpts.inInputShareable = true; - bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); - if (bitmap != null) { - holder.avatarImage.setVisibility(View.VISIBLE); - holder.avatarImage.setImageBitmap(bitmap); - holder.avatarInitialLetter.setVisibility(GONE); - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - avatar.delete(); - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - - createDefaultAvatar(userHandle, fullName, holder); - } - } - else{ - UserAvatarListener listener = new UserAvatarListener(context); - - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - - createDefaultAvatar(userHandle, fullName, holder); - } - } - else{ - UserAvatarListener listener = new UserAvatarListener(context); - - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - - createDefaultAvatar(userHandle, fullName, holder); - } - } - - public void createDefaultAvatar(long userHandle, String fullName, BigGroupCallAdapter.ViewHolderGroupCall holder) { - log("createDefaultAvatar"); - - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint p = new Paint(); - p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); - - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if (color != null) { - p.setColor(Color.parseColor(color)); - } else { - p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); - } - - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { - radius = defaultAvatar.getWidth() / 2; - }else { - radius = defaultAvatar.getHeight() / 2; - } - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - holder.avatarImage.setVisibility(View.VISIBLE); - holder.avatarImage.setImageBitmap(defaultAvatar); - String contactFirstLetter = fullName.charAt(0) + ""; - contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); - holder.avatarInitialLetter.setText(contactFirstLetter); - holder.avatarInitialLetter.setVisibility(View.VISIBLE); - - } - - public void setAdapterType(int adapterType){ - this.adapterType = adapterType; - } - - public RecyclerView getListFragment() { - return recyclerViewFragment; - } - - public void setListFragment(RecyclerView recyclerViewFragment) { - this.recyclerViewFragment = recyclerViewFragment; - } - - - public void changesInAudio(int position, BigGroupCallAdapter.ViewHolderGroupCall holder){ - log("changesInAudio"); - if(holder == null){ - holder = (BigGroupCallAdapter.ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); - } - if(holder!=null){ - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; - } - if(peer.isAudioOn()){ - log("Audio ON"); - holder.microAvatar.setVisibility(View.GONE); - holder.microSurface.setVisibility(View.GONE); - }else{ - log("Audio OFF"); - if(!peer.isVideoOn()){ - holder.microAvatar.setVisibility(View.VISIBLE); - holder.microSurface.setVisibility(View.GONE); - }else{ - holder.microSurface.setVisibility(View.VISIBLE); - holder.microAvatar.setVisibility(View.GONE); - } - } - }else{ - log("holder is NULL"); - notifyItemChanged(position); - } - } - private static void log(String log) { - Util.log("BigGroupCallAdapter", log); - } - -} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index df6ad73bf86..61be44a0a8a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -59,9 +59,7 @@ import static mega.privacy.android.app.utils.Util.percScreenLogin; -public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener { - - public static final int ITEM_VIEW_TYPE_GRID = 1; +public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { Context context; MegaApiAndroid megaApi; @@ -76,14 +74,6 @@ public class GroupCallAdapter extends RecyclerView.Adapter getPeers() { - return peers; - } - - public void setPeers(ArrayList peers) { - this.peers = peers; - } - ArrayList peers; long chatId; @@ -92,7 +82,8 @@ public void setPeers(ArrayList peers) { boolean avatarRequested = false; private int adapterType; - public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, int adapterType, boolean isCallInProgress) { + + public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress) { log("GroupCallAdapter( peers: "+peers.size()+")"); this.context = context; @@ -118,6 +109,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList 5)&&(numPeersOnCall<7)){ -// lp.height = maxScreenHeight / 3; -// lp.width = maxScreenWidth/2; -// } - if(numPeersOnCall < 4) { lp.height = maxScreenHeight / numPeersOnCall; lp.width = maxScreenWidth; @@ -204,12 +197,10 @@ public ViewHolderGroupCallGrid(View v) { lp.height = maxScreenHeight / 2; lp.width = maxScreenWidth/2; - }else if(numPeersOnCall > 4){ + }else if((numPeersOnCall > 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; - } - v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); @@ -234,6 +225,48 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); + if(numPeersOnCall < 7){ + log("onCreateViewHolder() - peers < 7"); + + ViewGroup.LayoutParams paramsGeneral = (ViewGroup.LayoutParams) holderGrid.rlGeneral.getLayoutParams(); + paramsGeneral.width = ViewGroup.LayoutParams.MATCH_PARENT; + paramsGeneral.height = ViewGroup.LayoutParams.MATCH_PARENT; + holderGrid.rlGeneral.setLayoutParams(paramsGeneral); + + holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); + + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); + paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); + holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); + holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); + holderGrid.avatarInitialLetter.setTextSize(Util.scaleWidthPx(25, outMetrics)); + + }else{ + + ViewGroup.LayoutParams paramsGeneral = (ViewGroup.LayoutParams) holderGrid.rlGeneral.getLayoutParams(); + paramsGeneral.width = Util.scaleWidthPx(90, outMetrics); + paramsGeneral.height = Util.scaleWidthPx(90, outMetrics); + holderGrid.rlGeneral.setLayoutParams(paramsGeneral); + + holderGrid.avatarMicroLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent_black)); + + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); + paramsMicroAvatar.setMargins(0, 0, 0, 0); + holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(60, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); + holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); + + holderGrid.avatarInitialLetter.setTextSize(Util.scaleWidthPx(30, outMetrics)); + } v.setTag(holderGrid); return holderGrid; @@ -247,10 +280,9 @@ public int getItemViewType(int position) { @Override public void onBindViewHolder(ViewHolderGroupCall holder, int position) { log("onBindViewHolder"); - if (adapterType == GroupCallAdapter.ITEM_VIEW_TYPE_GRID){ - ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder; - onBindViewHolderGrid(holderGrid2, position); - } + ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder; + onBindViewHolderGrid(holderGrid2, position); + } public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ @@ -317,51 +349,24 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.rlGeneral.setLayoutParams(layoutParamsPeer); } - -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParamsPeer.width = maxScreenWidth; -// layoutParamsPeer.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParamsPeer); -// } - }else if(numPeersOnCall == 6){ //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - -// if((position < 2)){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// -// }else if(position > 3){ -// layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - } + holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); - //Clear surfaceViewLayout + //Clear surfaceViewLayout and remove listener if(holder.surfaceViewLayout.getChildCount() != 0){ holder.surfaceViewLayout.removeAllViewsInLayout(); } + if(peer.getListener() != null){ peer.setListener(null); } @@ -374,13 +379,20 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); + if(numPeersOnCall > 6){ + holder.localRenderer.addListener(this); + } //Update micro icon holder.microSurface.setImageResource(R.drawable.ic_mic_off); RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, 50, 50, 0); + if(numPeersOnCall < 7){ + paramsMicroSurface.setMargins(0, 50, 50, 0); + }else{ + paramsMicroSurface.setMargins(0, 4, 4, 0); + } holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); if(peer.isAudioOn()){ @@ -392,7 +404,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.microSurface.setVisibility(View.GONE); } } - holder.surfaceViewLayout.setVisibility(View.VISIBLE); //Create listener @@ -455,11 +466,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); @@ -468,13 +474,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.rlGeneral.setLayoutParams(layoutParamsPeer); } -// if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ -// ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); -// layoutParamsPeer.width = maxScreenWidth; -// layoutParamsPeer.height = (maxScreenHeight/3); -// holder.rlGeneral.setLayoutParams(layoutParamsPeer); -// } - }else if(numPeersOnCall == 6){ //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); @@ -482,12 +481,6 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - -// if((position < 2)){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); -// }else if(position > 3){ -// layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); -// } holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); } @@ -743,9 +736,6 @@ public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGro public void setAdapterType(int adapterType){ this.adapterType = adapterType; } - private static void log(String log) { - Util.log("GroupCallAdapter", log); - } public RecyclerView getListFragment() { return recyclerViewFragment; @@ -786,4 +776,16 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } + public ArrayList getPeers() { + return peers; + } + + public void setPeers(ArrayList peers) { + this.peers = peers; + } + + private static void log(String log) { + Util.log("GroupCallAdapter", log); + } + } diff --git a/app/src/main/res/layout/item_big_camera_group_call.xml b/app/src/main/res/layout/item_big_camera_group_call.xml deleted file mode 100644 index 95b859667d3..00000000000 --- a/app/src/main/res/layout/item_big_camera_group_call.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index c767d78573f..bcd1e7de486 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -49,7 +49,6 @@ android:id="@+id/avatar_initial_letter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="50sp" android:background="@android:color/transparent" android:textColor="@color/white" android:layout_centerInParent="true" @@ -62,7 +61,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/avatar_rl" - android:layout_marginLeft="10dp" android:layout_alignTop="@+id/avatar_rl" android:background="@android:color/transparent" android:visibility="gone" From d1c3ebe9874945b1ada224e3272933ef5b575597 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 13 Sep 2018 13:08:31 +0200 Subject: [PATCH 059/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 61 +++++++-------- .../chatAdapters/GroupCallAdapter.java | 76 +++++++++---------- .../main/res/layout/activity_calls_chat.xml | 3 +- 3 files changed, 66 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 7b760b75b21..5a445189d19 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -34,7 +34,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; @@ -72,7 +71,6 @@ import mega.privacy.android.app.DatabaseHandler; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; -import mega.privacy.android.app.components.CustomizedGridLayoutManager; import mega.privacy.android.app.components.OnSwipeTouchListener; import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.CustomizedGridCallRecyclerView; @@ -157,9 +155,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque LinearLayoutManager layoutManager; RecyclerView bigRecyclerView; - GroupCallAdapter adapter; -// BigGroupCallAdapter BigAdapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -613,8 +609,7 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setVisibility(GONE); - //Recycler View for 6-8 peers - log("onCreate()"); + //Recycler View for 7-8 peers (because 9-10 without video) layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); bigRecyclerView.setLayoutManager(layoutManager); @@ -725,22 +720,20 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - //**** Descomentar - -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("Incoming group call"); @@ -790,22 +783,19 @@ protected void onCreate(Bundle savedInstanceState) { }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("onCreate()-InProgress"); - updateScreenStatusInProgress(); }else{ - //**** Descomentar - -// -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } + + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("Outgoing group call"); @@ -826,6 +816,7 @@ protected void onCreate(Bundle savedInstanceState) { InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); createNewAdapter(true); + }else{ log("Outgoing individual call"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 61be44a0a8a..aadda2cf29b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -14,6 +14,7 @@ import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.Display; import android.view.Gravity; import android.view.LayoutInflater; @@ -84,7 +85,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress) { - log("GroupCallAdapter( peers: "+peers.size()+")"); + log("GroupCallAdapter(peers: "+peers.size()+")"); this.context = context; this.recyclerViewFragment = recyclerView; @@ -200,7 +201,11 @@ public ViewHolderGroupCallGrid(View v) { }else if((numPeersOnCall > 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; + }else if(numPeersOnCall >= 7){ + lp.height = Util.scaleWidthPx(90, outMetrics); + lp.width = Util.scaleWidthPx(90, outMetrics); } + v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); @@ -227,12 +232,6 @@ public ViewHolderGroupCallGrid(View v) { if(numPeersOnCall < 7){ log("onCreateViewHolder() - peers < 7"); - - ViewGroup.LayoutParams paramsGeneral = (ViewGroup.LayoutParams) holderGrid.rlGeneral.getLayoutParams(); - paramsGeneral.width = ViewGroup.LayoutParams.MATCH_PARENT; - paramsGeneral.height = ViewGroup.LayoutParams.MATCH_PARENT; - holderGrid.rlGeneral.setLayoutParams(paramsGeneral); - holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); @@ -245,14 +244,10 @@ public ViewHolderGroupCallGrid(View v) { paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(Util.scaleWidthPx(25, outMetrics)); + holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 60f); }else{ - - ViewGroup.LayoutParams paramsGeneral = (ViewGroup.LayoutParams) holderGrid.rlGeneral.getLayoutParams(); - paramsGeneral.width = Util.scaleWidthPx(90, outMetrics); - paramsGeneral.height = Util.scaleWidthPx(90, outMetrics); - holderGrid.rlGeneral.setLayoutParams(paramsGeneral); + log("onCreateViewHolder() - peers >= 7"); holderGrid.avatarMicroLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent_black)); @@ -265,7 +260,7 @@ public ViewHolderGroupCallGrid(View v) { paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(Util.scaleWidthPx(30, outMetrics)); + holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); } v.setTag(holderGrid); return holderGrid; @@ -279,7 +274,6 @@ public int getItemViewType(int position) { @Override public void onBindViewHolder(ViewHolderGroupCall holder, int position) { - log("onBindViewHolder"); ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder; onBindViewHolderGrid(holderGrid2, position); @@ -295,8 +289,9 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ int numPeersOnCall = getItemCount(); if(peer.isVideoOn()) { - log("Video ON"); + log("Video ON - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ + log("1"); //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = maxScreenWidth; @@ -305,6 +300,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 2){ + log("2"); + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); @@ -313,6 +310,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 3){ + log("3"); + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); @@ -321,6 +320,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 4){ + log("4"); + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); @@ -335,6 +336,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 5){ + log("5"); + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); @@ -350,6 +353,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } }else if(numPeersOnCall == 6){ + log("6"); + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); @@ -380,6 +385,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); if(numPeersOnCall > 6){ + log("add listener in local Renderer"); + holder.localRenderer.addListener(this); } @@ -419,8 +426,9 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } }else{ - log("Video OFF"); + log("Video OFF - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ + log("1"); //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = maxScreenWidth; @@ -429,6 +437,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 2){ + log("2"); + //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); @@ -437,6 +447,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 3){ + log("3"); + //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); @@ -445,6 +457,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 4){ + log("4"); + //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); @@ -459,6 +473,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 5){ + log("5"); + //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); @@ -475,6 +491,8 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ } }else if(numPeersOnCall == 6){ + log("6"); + //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); @@ -533,8 +551,6 @@ public int getItemCount() { } public Object getItem(int position) { - log("getItem() position "+position); - if (peers != null){ return peers.get(position); } @@ -543,8 +559,6 @@ public Object getItem(int position) { public InfoPeerGroupCall getNodeAt(int position) { - log("getNodeAt() position "+position); - try { if (peers != null) { return peers.get(position); @@ -556,12 +570,9 @@ public InfoPeerGroupCall getNodeAt(int position) { //My AVATAR public void setProfileMyAvatar(ViewHolderGroupCall holder) { - log("setProfileMyAvatar()"); - Bitmap myBitmap = null; File avatar = null; if (context != null) { - log("context is not null"); if (context.getExternalCacheDir() != null) { avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); } else { @@ -592,8 +603,6 @@ public void setProfileMyAvatar(ViewHolderGroupCall holder) { } public void createMyDefaultAvatar(ViewHolderGroupCall holder) { - log("createMyDefaultAvatar()"); - String myFullName = megaChatApi.getMyFullname(); String myFirstLetter=myFullName.charAt(0) + ""; myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); @@ -608,11 +617,8 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); if(color!=null){ - log("The color to set the avatar is "+color); p.setColor(Color.parseColor(color)); - } - else{ - log("Default color to the avatar"); + }else{ p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); } @@ -631,7 +637,6 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ - log("setProfileContactAvatar"); Bitmap bitmap = null; File avatar = null; String contactMail = megaChatApi.getContactEmail(userHandle); @@ -667,8 +672,7 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde createDefaultAvatar(userHandle, fullName, holder); } - } - else{ + }else{ UserAvatarListener listener = new UserAvatarListener(context); if(!avatarRequested){ @@ -683,8 +687,7 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde createDefaultAvatar(userHandle, fullName, holder); } - } - else{ + }else{ UserAvatarListener listener = new UserAvatarListener(context); if(!avatarRequested){ @@ -702,8 +705,6 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde } public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGroupCall holder) { - log("createDefaultAvatar"); - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); @@ -771,7 +772,6 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } }else{ - log("holder is NULL"); notifyItemChanged(position); } } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 0232b4b00fb..7485ebd1c52 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -42,7 +42,8 @@ android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="94dp" - android:orientation="horizontal"/> + android:orientation="horizontal" + android:visibility="gone"/> From 3d204ac4d27981b3746df663e68f52964e96221b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 14 Sep 2018 10:10:16 +0200 Subject: [PATCH 060/247] Feature#9775-Group calls UI --- .../app/lollipop/megachat/chatAdapters/GroupCallAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index aadda2cf29b..1d1e51f7de9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -244,7 +244,7 @@ public ViewHolderGroupCallGrid(View v) { paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 60f); + holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); }else{ log("onCreateViewHolder() - peers >= 7"); From 53fdd3684d29ec75949e8c21a3c3bc042ba90df6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 17 Sep 2018 09:18:06 +0200 Subject: [PATCH 061/247] Feature#9775-Group calls UI --- .../listeners/CustomItemClickListener.java | 7 + .../calls/BigCameraGroupCallFragment.java | 165 ++++++++++++++++++ .../megachat/calls/ChatCallActivity.java | 155 ++++++++++++---- .../chatAdapters/GroupCallAdapter.java | 101 +++++++---- .../main/res/layout/activity_calls_chat.xml | 17 ++ 5 files changed, 372 insertions(+), 73 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java new file mode 100644 index 00000000000..9453ebda243 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java @@ -0,0 +1,7 @@ +package mega.privacy.android.app.lollipop.listeners; + +import android.view.View; + +public interface CustomItemClickListener { + public void onItemClick(int position); +} \ No newline at end of file diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java new file mode 100644 index 00000000000..62e873d6e5a --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -0,0 +1,165 @@ +package mega.privacy.android.app.lollipop.megachat.calls; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.PixelFormat; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.ViewGroup; + +import java.nio.ByteBuffer; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatVideoListenerInterface; + +/** + * Created by mega on 14/09/18. + */ + +public class BigCameraGroupCallFragment extends Fragment implements MegaChatVideoListenerInterface { + + int width = 0; + int height = 0; + Bitmap bitmap; + MegaChatApiAndroid megaChatApi; + Context context; + long chatId; + + public SurfaceView localFullScreenSurfaceView; + MegaSurfaceRenderer localRenderer; + + public static BigCameraGroupCallFragment newInstance(long chatId) { + log("newInstance"); + BigCameraGroupCallFragment f = new BigCameraGroupCallFragment(); + + Bundle args = new Bundle(); + args.putLong("chatId", chatId); + f.setArguments(args); + return f; + } + + @Override + public void onCreate (Bundle savedInstanceState){ + log("onCreate"); + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); + } + + Bundle args = getArguments(); + this.chatId = args.getLong("chatId", -1); + + super.onCreate(savedInstanceState); + log("after onCreate called super"); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + log("onCreateView"); + + if (!isAdded()) { + return null; + } + + View v = inflater.inflate(R.layout.fragment_local_camera_call_full_screen, container, false); + + localFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); + localFullScreenSurfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = localFullScreenSurfaceView.getHolder(); + localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + localRenderer = new MegaSurfaceRenderer(localFullScreenSurfaceView); + + megaChatApi.addChatLocalVideoListener(chatId, this); + + return v; + } + + @Override + public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { + if((width == 0) || (height == 0)){ + return; + } + + if (this.width != width || this.height != height) { + this.width = width; + this.height = height; + + SurfaceHolder holder = localFullScreenSurfaceView.getHolder(); + if (holder != null) { + int viewWidth = localFullScreenSurfaceView.getWidth(); + int viewHeight = localFullScreenSurfaceView.getHeight(); + if ((viewWidth != 0) && (viewHeight != 0)) { + int holderWidth = viewWidth < width ? viewWidth : width; + int holderHeight = holderWidth * viewHeight / viewWidth; + if (holderHeight > viewHeight) { + holderHeight = viewHeight; + holderWidth = holderHeight * viewWidth / viewHeight; + } + this.bitmap = localRenderer.CreateBitmap(width, height); + holder.setFixedSize(holderWidth, holderHeight); + } + else{ + this.width = -1; + this.height = -1; + } + } + } + + if (bitmap != null) { + bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); + + // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. + // The renderer has been modified a bit and an update of WebRTC could break our app + localRenderer.DrawBitmap(false); + } + } + + + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + context = activity; + } + + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; + } + + @Override + public void onDestroy(){ + megaChatApi.removeChatVideoListener(chatId, -1, this); + super.onDestroy(); + } + @Override + public void onResume() { + log("onResume"); + this.width=0; + this.height=0; + super.onResume(); + } + + public void setVideoFrame(boolean visible){ + if(visible){ + localFullScreenSurfaceView.setVisibility(View.VISIBLE); + } + else{ + localFullScreenSurfaceView.setVisibility(View.GONE); + } + } + + private static void log(String log) { + Util.log("LocalCameraCallFullScreenFragment", log); + } +} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 5a445189d19..e35ddfa11b8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -75,6 +75,7 @@ import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.CustomizedGridCallRecyclerView; import mega.privacy.android.app.lollipop.LoginActivityLollipop; +import mega.privacy.android.app.lollipop.listeners.CustomItemClickListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; @@ -188,14 +189,17 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FrameLayout fragmentContainerLocalCamera; FrameLayout fragmentContainerLocalCameraFS; FrameLayout fragmentContainerRemoteCameraFS; + FrameLayout fragmentContainerBigCameraGroupCall; ViewGroup parentLocal; ViewGroup parentLocalFS; ViewGroup parentRemoteFS; + ViewGroup parentBigCameraGroupCall; private LocalCameraCallFragment localCameraFragment; private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; + private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; private SensorManager mSensorManager; private Sensor mSensor; @@ -613,8 +617,32 @@ protected void onCreate(Bundle savedInstanceState) { layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); bigRecyclerView.setLayoutManager(layoutManager); + bigRecyclerView.setVisibility(GONE); + + //Big camera group calls + parentBigCameraGroupCall = (ViewGroup) findViewById(R.id.parent_layout_big_camera_group_call); + ViewGroup.LayoutParams paramsBigCameraGroupCall = (ViewGroup.LayoutParams) parentBigCameraGroupCall.getLayoutParams(); + if(widthScreenPX=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } + //************+ des + +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ log("Incoming group call"); @@ -787,15 +817,18 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } + //************+ des + +// +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("Outgoing group call"); @@ -1126,7 +1159,7 @@ protected void onResume() { log("onResume"); if(peersOnCall!=null){ if(peersOnCall.size()!=0){ - if(peersOnCall.size()<7){ + if(peersOnCall.size()<6){ for(InfoPeerGroupCall peer :peersOnCall){ if(peer.getListener()!=null){ if(peer.getListener().getHeight() != 0){ @@ -1634,7 +1667,8 @@ public void onClick(View v) { log("onClick"); switch (v.getId()) { - case R.id.call_chat_contact_image_rl:{ + case R.id.call_chat_contact_image_rl: + case R.id.parent_layout_big_camera_group_call:{ remoteCameraClick(); break; } @@ -1950,6 +1984,17 @@ public void updateLocalVideoStatus(){ log("activate Local Video for "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(true); adapter.notifyItemChanged(peersOnCall.size()-1); + + if(bigCameraGroupCallFragment == null){ + log("CREATE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); + ftFS.commitNowAllowingStateLoss(); + } + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); + } } }else { @@ -1962,6 +2007,16 @@ public void updateLocalVideoStatus(){ log("remove Local Video fot "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(false); adapter.notifyItemChanged(peersOnCall.size()-1); + + if (bigCameraGroupCallFragment != null) { + log("REMOVE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + parentBigCameraGroupCall.setVisibility(View.GONE); + fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); } } } @@ -2418,11 +2473,12 @@ public void createNewAdapter(boolean flag){ if(flag){ //arrayList-> peersOnCall - if(peersOnCall.size() < 7){ - log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" < 7"); + if(peersOnCall.size() < 6){ + log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" < 6"); bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setVisibility(View.GONE); if(peersOnCall.size() <= 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); @@ -2443,7 +2499,13 @@ public void createNewAdapter(boolean flag){ recyclerView.setColumnWidth((int) widthScreenPX/2); } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ + @Override + public void onItemClick( int position) { + // do what ever you want to do with it + } + }); + recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2452,13 +2514,24 @@ public void createNewAdapter(boolean flag){ } }else{ - log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" >= 7"); + log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" >= 6"); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ + @Override + public void onItemClick(int position) { + // do what ever you want to do with it + InfoPeerGroupCall p= adapter.getNodeAt(position); + log("****** onItemClick: p "+p.getName()); + + + } + }); bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ bigRecyclerView.setVisibility(View.GONE); @@ -2468,10 +2541,11 @@ public void createNewAdapter(boolean flag){ } }else{ + parentBigCameraGroupCall.setVisibility(View.GONE); //arrayList-> peersBeforeCall - if(peersBeforeCall.size() < 7) { - log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" < 7"); + if(peersBeforeCall.size() < 6) { + log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" < 6"); bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); @@ -2483,7 +2557,12 @@ public void createNewAdapter(boolean flag){ } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, new CustomItemClickListener(){ + @Override + public void onItemClick(int position) { + // do what ever you want to do with it + } + }); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2492,14 +2571,18 @@ public void createNewAdapter(boolean flag){ } }else{ - log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 7"); + log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 6"); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, new CustomItemClickListener(){ + @Override + public void onItemClick(int position) { + // do what ever you want to do with it + } + }); if (adapter.getItemCount() == 0){ bigRecyclerView.setVisibility(View.GONE); }else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 1d1e51f7de9..e58388fd201 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -38,6 +38,7 @@ import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; import mega.privacy.android.app.lollipop.adapters.FileStorageLollipopAdapter; +import mega.privacy.android.app.lollipop.listeners.CustomItemClickListener; import mega.privacy.android.app.lollipop.listeners.GroupCallListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; @@ -72,6 +73,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress) { + public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { log("GroupCallAdapter(peers: "+peers.size()+")"); this.context = context; @@ -93,6 +95,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList 4) && (numPeersOnCall < 7)){ + }else if((numPeersOnCall > 4) && (numPeersOnCall < 6)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; - }else if(numPeersOnCall >= 7){ + + }else if(numPeersOnCall >= 6){ lp.height = Util.scaleWidthPx(90, outMetrics); lp.width = Util.scaleWidthPx(90, outMetrics); } @@ -209,8 +215,15 @@ public ViewHolderGroupCallGrid(View v) { v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); + + holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - holderGrid.rlGeneral.setOnClickListener(this); + +// if(numPeersOnCall<6){ +// holderGrid.rlGeneral.setOnClickListener(this); +// }else{ +// holderGrid.rlGeneral.setOnClickListener(null); +// } holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.surfaceViewLayout.removeAllViewsInLayout(); @@ -230,8 +243,8 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - if(numPeersOnCall < 7){ - log("onCreateViewHolder() - peers < 7"); + if(numPeersOnCall < 6){ + log("onCreateViewHolder() - peers < 6"); holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); @@ -247,12 +260,14 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); }else{ - log("onCreateViewHolder() - peers >= 7"); + log("onCreateViewHolder() - peers >= 6"); holderGrid.avatarMicroLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent_black)); RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); paramsMicroAvatar.setMargins(0, 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); @@ -279,7 +294,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } - public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ + public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int position){ log("onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); @@ -287,7 +302,16 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ return; } + holder.rlGeneral.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + log("***** onClick() send my positon: "+holder.getPosition()); + listener.onItemClick(holder.getPosition()); + } + }); + int numPeersOnCall = getItemCount(); + if(peer.isVideoOn()) { log("Video ON - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ @@ -352,16 +376,18 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.rlGeneral.setLayoutParams(layoutParamsPeer); } - }else if(numPeersOnCall == 6){ - log("6"); - - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); } +// else if(numPeersOnCall == 6){ +// log("6"); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// } + holder.avatarMicroLayout.setVisibility(GONE); @@ -384,7 +410,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); - if(numPeersOnCall > 6){ + if(numPeersOnCall >= 6){ log("add listener in local Renderer"); holder.localRenderer.addListener(this); @@ -395,7 +421,7 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - if(numPeersOnCall < 7){ + if(numPeersOnCall < 6){ paramsMicroSurface.setMargins(0, 50, 50, 0); }else{ paramsMicroSurface.setMargins(0, 4, 4, 0); @@ -490,17 +516,18 @@ public void onBindViewHolderGrid (ViewHolderGroupCallGrid holder, int position){ holder.rlGeneral.setLayoutParams(layoutParamsPeer); } - }else if(numPeersOnCall == 6){ - log("6"); - - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); } +// else if(numPeersOnCall == 6){ +// log("6"); +// +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); +// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// } holder.microSurface.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 7485ebd1c52..75fee21d207 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -34,6 +34,23 @@ android:scrollbars="horizontal" android:layout_centerHorizontal="true" android:nestedScrollingEnabled="false"/> + + + + Date: Mon, 17 Sep 2018 09:22:39 +0200 Subject: [PATCH 062/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 54 +++++++++---------- .../chatAdapters/GroupCallAdapter.java | 8 ++- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index e35ddfa11b8..a53005a27e6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -748,22 +748,20 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - //************+ des - -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("Incoming group call"); @@ -817,18 +815,16 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - //************+ des - -// -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } + + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("Outgoing group call"); @@ -2527,8 +2523,6 @@ public void onItemClick( int position) { public void onItemClick(int position) { // do what ever you want to do with it InfoPeerGroupCall p= adapter.getNodeAt(position); - log("****** onItemClick: p "+p.getName()); - } }); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e58388fd201..e6a1902c68b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -116,7 +116,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList Date: Tue, 18 Sep 2018 08:09:16 +0200 Subject: [PATCH 063/247] Feature#9775-Group calls UI --- .../calls/BigCameraGroupCallFragment.java | 45 +- .../megachat/calls/ChatCallActivity.java | 429 +++++++++++++----- .../RemoteCameraCallFullScreenFragment.java | 1 - .../chatAdapters/GroupCallAdapter.java | 123 ++--- .../main/res/layout/activity_calls_chat.xml | 38 +- .../res/layout/item_camera_group_call.xml | 6 +- 6 files changed, 438 insertions(+), 204 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 62e873d6e5a..6edca1b1df9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -33,16 +33,18 @@ public class BigCameraGroupCallFragment extends Fragment implements MegaChatVide MegaChatApiAndroid megaChatApi; Context context; long chatId; + Long userHandle; - public SurfaceView localFullScreenSurfaceView; - MegaSurfaceRenderer localRenderer; + public SurfaceView fullScreenSurfaceView; + MegaSurfaceRenderer renderer; - public static BigCameraGroupCallFragment newInstance(long chatId) { + public static BigCameraGroupCallFragment newInstance(long chatId, long userHandle) { log("newInstance"); BigCameraGroupCallFragment f = new BigCameraGroupCallFragment(); Bundle args = new Bundle(); args.putLong("chatId", chatId); + args.putLong("userHandle",userHandle); f.setArguments(args); return f; } @@ -56,7 +58,7 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); - + this.userHandle = args.getLong("userHandle", -1); super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -71,13 +73,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_local_camera_call_full_screen, container, false); - localFullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); - localFullScreenSurfaceView.setZOrderMediaOverlay(true); - SurfaceHolder localSurfaceHolder = localFullScreenSurfaceView.getHolder(); + fullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); + fullScreenSurfaceView.setZOrderMediaOverlay(true); + SurfaceHolder localSurfaceHolder = fullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - localRenderer = new MegaSurfaceRenderer(localFullScreenSurfaceView); + renderer = new MegaSurfaceRenderer(fullScreenSurfaceView); + + if(userHandle.equals(megaChatApi.getMyUserHandle())){ + megaChatApi.addChatLocalVideoListener(chatId, this); + }else{ + megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); + } - megaChatApi.addChatLocalVideoListener(chatId, this); return v; } @@ -92,10 +99,10 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.width = width; this.height = height; - SurfaceHolder holder = localFullScreenSurfaceView.getHolder(); + SurfaceHolder holder = fullScreenSurfaceView.getHolder(); if (holder != null) { - int viewWidth = localFullScreenSurfaceView.getWidth(); - int viewHeight = localFullScreenSurfaceView.getHeight(); + int viewWidth = fullScreenSurfaceView.getWidth(); + int viewHeight = fullScreenSurfaceView.getHeight(); if ((viewWidth != 0) && (viewHeight != 0)) { int holderWidth = viewWidth < width ? viewWidth : width; int holderHeight = holderWidth * viewHeight / viewWidth; @@ -103,7 +110,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderHeight = viewHeight; holderWidth = holderHeight * viewWidth / viewHeight; } - this.bitmap = localRenderer.CreateBitmap(width, height); + this.bitmap = renderer.CreateBitmap(width, height); holder.setFixedSize(holderWidth, holderHeight); } else{ @@ -118,7 +125,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app - localRenderer.DrawBitmap(false); + renderer.DrawBitmap(false); } } @@ -139,7 +146,11 @@ public void onAttach(Context context) { @Override public void onDestroy(){ - megaChatApi.removeChatVideoListener(chatId, -1, this); + if(userHandle.equals(megaChatApi.getMyUserHandle())){ + megaChatApi.removeChatVideoListener(chatId, -1, this); + }else{ + megaChatApi.removeChatVideoListener(chatId, userHandle, this); + } super.onDestroy(); } @Override @@ -152,10 +163,10 @@ public void onResume() { public void setVideoFrame(boolean visible){ if(visible){ - localFullScreenSurfaceView.setVisibility(View.VISIBLE); + fullScreenSurfaceView.setVisibility(View.VISIBLE); } else{ - localFullScreenSurfaceView.setVisibility(View.GONE); + fullScreenSurfaceView.setVisibility(View.GONE); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 97021889900..45e68c52b7f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -59,7 +59,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; - import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -140,6 +139,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Toolbar tB; ActionBar aB; boolean avatarRequested = false; + InfoPeerGroupCall peerSelected = null; ArrayList peersOnCall = new ArrayList<>(); ArrayList peersBeforeCall = new ArrayList<>(); @@ -189,17 +189,22 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FrameLayout fragmentContainerLocalCamera; FrameLayout fragmentContainerLocalCameraFS; FrameLayout fragmentContainerRemoteCameraFS; - FrameLayout fragmentContainerBigCameraGroupCall; ViewGroup parentLocal; ViewGroup parentLocalFS; ViewGroup parentRemoteFS; - ViewGroup parentBigCameraGroupCall; private LocalCameraCallFragment localCameraFragment; private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; + + //Big elements for group call (more than 6 users) + FrameLayout fragmentContainerBigCameraGroupCall; + ViewGroup parentBigCameraGroupCall; private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; + RelativeLayout bigAvatarGroupCallLayout; + RoundedImageView bigAvatarGroupCallImage; + TextView bigAvatarGroupCallInitialLetter; private SensorManager mSensorManager; private Sensor mSensor; @@ -292,7 +297,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } public void updateScreenStatusInProgress(){ - log("updateScreenStatusInProgress"); + log("updateScreenStatusInProgress()"); relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; flagMyAvatar = true; @@ -306,7 +311,6 @@ public void updateScreenStatusInProgress(){ relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - log("updateScreenStatusInProgress()- callChat.getNumParticipants() = "+ callChat.getNumParticipants()); if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } @@ -325,7 +329,6 @@ public void updateScreenStatusInProgress(){ } if (!peerContain) { if(userHandle == megaChatApi.getMyUserHandle()){ - log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; @@ -333,7 +336,6 @@ public void updateScreenStatusInProgress(){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); changes = true; @@ -353,7 +355,6 @@ public void updateScreenStatusInProgress(){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ - log("updateScreenStatusInProgress(): peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; @@ -361,12 +362,10 @@ public void updateScreenStatusInProgress(){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("updateScreenStatusInProgress(): peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null); peersOnCall.add(0, userPeer); changes = true; }else{ - log("updateScreenStatusInProgress()-userSession.getStatus(): "+userSession.getStatus()); } } @@ -632,8 +631,7 @@ protected void onCreate(Bundle savedInstanceState) { bigRecyclerView.setVisibility(GONE); - - //Big camera group calls + //Big elements group calls parentBigCameraGroupCall = (ViewGroup) findViewById(R.id.parent_layout_big_camera_group_call); ViewGroup.LayoutParams paramsBigCameraGroupCall = (ViewGroup.LayoutParams) parentBigCameraGroupCall.getLayoutParams(); if(widthScreenPX=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } +//*DES +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ - log("Incoming group call"); + log("onCreate()-> Incoming group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -822,12 +821,11 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("onCreate()-InProgress"); + log("onCreate()-> InProgress"); updateScreenStatusInProgress(); }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -839,7 +837,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Outgoing group call"); + log("onCreate()-> Outgoing group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -1167,26 +1165,16 @@ protected void onResume() { log("onResume"); if(peersOnCall!=null){ if(peersOnCall.size()!=0){ - if(peersOnCall.size()<6){ - for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListener()!=null){ - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } - } - } - }else{ - for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListener()!=null){ + for(InfoPeerGroupCall peer :peersOnCall){ + if(peer.getListener()!=null){ + if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } } } - } } @@ -1976,7 +1964,7 @@ public void onSwipeBottom() {} } public void updateLocalVideoStatus(){ - log("updateLocalVideoStatus() "); + log("updateLocalVideoStatus"); int callStatus = callChat.getStatus(); if(chat.isGroup()){ @@ -1992,18 +1980,15 @@ public void updateLocalVideoStatus(){ log("activate Local Video for "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(true); adapter.notifyItemChanged(peersOnCall.size()-1); - - if(bigCameraGroupCallFragment == null){ - log("CREATE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); - ftFS.commitNowAllowingStateLoss(); - } - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); - } +// if(peerSelected!=null){ +// log("updateLocalVideoStatus()-> peerSelected.getHandle(): "+peerSelected.getHandle()+", peersOnCall.get(peersOnCall.size()-1).getHandle(): "+peersOnCall.get(peersOnCall.size()-1).getHandle()); +// if(peerSelected.getHandle().equals(peersOnCall.get(peersOnCall.size()-1).getHandle())){ +// log("updateLocalVideoStatus()-> createBigFragment"); +// createBigFragment(peerSelected.getHandle()); +// } +// } + } }else { log("Video local NOT connected"); @@ -2015,17 +2000,15 @@ public void updateLocalVideoStatus(){ log("remove Local Video fot "+peersOnCall.get(peersOnCall.size()-1).getName()); item.setVideoOn(false); adapter.notifyItemChanged(peersOnCall.size()-1); - - if (bigCameraGroupCallFragment != null) { - log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(bigCameraGroupCallFragment); - bigCameraGroupCallFragment = null; - } - parentBigCameraGroupCall.setVisibility(View.GONE); - fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); } +// if(peerSelected != null){ +// log("updateLocalVideoStatus()-> peerSelected.getHandle(): "+peerSelected.getHandle()+", peersOnCall.get(peersOnCall.size()-1).getHandle(): "+peersOnCall.get(peersOnCall.size()-1).getHandle()); +// if(peerSelected.getHandle().equals(peersOnCall.get(peersOnCall.size()-1).getHandle())){ +// log("updateLocalVideoStatus()-> removeBigFragment"); +// removeBigFragment(peerSelected.getHandle(), peerSelected.getName()); +// } +// } + } } } @@ -2165,12 +2148,19 @@ public void updateRemoteVideoStatus(long userHandle){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera TRUE"); peersOnCall.get(i).setVideoOn(true); adapter.notifyItemChanged(i); - break; } +// if(peerSelected!=null){ +// log("updateRemoteVideoStatus()-> peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); +// if(peerSelected.getHandle().equals(userHandle)){ +// log("updateRemoteVideoStatus()-> createBigFragment"); +// createBigFragment(peerSelected.getHandle()); +// } +// } + break; } } } - }else { + }else{ log(userHandle+": Video remote NOT connected"); if (peersOnCall != null && !peersOnCall.isEmpty()) { for(int i=0;i peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); +// if(peerSelected.getHandle().equals(userHandle)){ +// log("updateRemoteVideoStatus()-> removeBigFragment"); +// removeBigFragment(peerSelected.getHandle(), peerSelected.getName()); +// } +// } + break; } } } @@ -2479,13 +2476,11 @@ public void createNewAdapter(boolean flag){ log("createNewAdapter"); if(flag){ - //arrayList-> peersOnCall - if(peersOnCall.size() < 6){ - log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" < 6"); - + if(peersOnCall.size() < 7){ bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); if(peersOnCall.size() <= 4){ @@ -2493,7 +2488,6 @@ public void createNewAdapter(boolean flag){ params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; recyclerView.setLayoutParams(params); - }else{ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; @@ -2506,14 +2500,9 @@ public void createNewAdapter(boolean flag){ }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); } - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ - @Override - public void onItemClick( int position) { - // do what ever you want to do with it - } - }); + recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2522,23 +2511,28 @@ public void onItemClick( int position) { } }else{ - log("createNewAdapter() - numPeersOnCall: "+peersOnCall.size()+" >= 6"); - recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); - bigRecyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ @Override public void onItemClick(int position) { // do what ever you want to do with it - InfoPeerGroupCall p= adapter.getNodeAt(position); + peerSelected = adapter.getNodeAt(position); +// if(peerSelected.getHandle().equals(megaChatApi.getMyUserHandle())){ +// updateLocalVideoStatus(); +// }else{ +// updateRemoteVideoStatus(peerSelected.getHandle()); +// +// } } }); bigRecyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ bigRecyclerView.setVisibility(View.GONE); }else{ @@ -2550,11 +2544,24 @@ public void onItemClick(int position) { parentBigCameraGroupCall.setVisibility(View.GONE); //arrayList-> peersBeforeCall - if(peersBeforeCall.size() < 6) { - log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" < 6"); + if(peersBeforeCall.size() < 7) { bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); + + if(peersBeforeCall.size() <= 4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + recyclerView.setLayoutParams(params); + }else{ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(540, outMetrics); + recyclerView.setLayoutParams(params); + } if(peersBeforeCall.size() <= 3){ recyclerView.setColumnWidth((int) widthScreenPX); @@ -2563,12 +2570,7 @@ public void onItemClick(int position) { } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, new CustomItemClickListener(){ - @Override - public void onItemClick(int position) { - // do what ever you want to do with it - } - }); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, null); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2577,18 +2579,17 @@ public void onItemClick(int position) { } }else{ - log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 6"); + log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 7"); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, new CustomItemClickListener(){ - @Override - public void onItemClick(int position) { - // do what ever you want to do with it - } - }); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, null); + bigRecyclerView.setAdapter(adapter); + if (adapter.getItemCount() == 0){ bigRecyclerView.setVisibility(View.GONE); }else{ @@ -2600,5 +2601,217 @@ public void onItemClick(int position) { } + public void createBigFragment(Long handle){ + log("createBigFragment()"); + if(bigCameraGroupCallFragment != null){ + log("REMOVE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + + //Camera + if(bigCameraGroupCallFragment == null){ + log("CREATE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId, handle); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); + ftFS.commitNowAllowingStateLoss(); + } + fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); + + //Avatar + bigAvatarGroupCallLayout.setVisibility(View.GONE); + + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + } + + public void removeBigFragment(Long handle, String fullName){ + + //Camera + if (bigCameraGroupCallFragment != null) { + log("REMOVE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); + + //Avatar + if(handle.equals(megaChatApi.getMyUserHandle())){ + setProfileMyAvatarGroupCall(); + }else{ + setProfileContactAvatarGroupCall(handle,fullName); + } + bigAvatarGroupCallLayout.setVisibility(View.VISIBLE); + + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + } + + public void setProfileMyAvatarGroupCall() { + log("setProfileMyAvatarGroupCall"); + Bitmap myBitmap = null; + File avatar = null; + if (context != null) { + log("context is not null"); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); + } + } + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); + if (myBitmap != null) { + bigAvatarGroupCallImage.setImageBitmap(myBitmap); + bigAvatarGroupCallInitialLetter.setVisibility(GONE); + }else{ + createMyDefaultAvatarGroupCall(); + } + }else { + createMyDefaultAvatarGroupCall(); + } + }else { + createMyDefaultAvatarGroupCall(); + } + } + + public void createMyDefaultAvatarGroupCall() { + log("createMyDefaultAvatarGroupCall"); + String myFullName = megaChatApi.getMyFullname(); + String myFirstLetter = myFullName.charAt(0) + ""; + myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); + long userHandle = megaChatApi.getMyUserHandle(); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + p.setColor(Color.parseColor(color)); + }else { + p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); + bigAvatarGroupCallInitialLetter.setText(myFirstLetter); + bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + } + + public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ + log("setProfileContactAvatarGroupCall"); + Bitmap bitmap = null; + File avatar = null; + String contactMail = megaChatApi.getContactEmail(userHandle); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); + if (bitmap != null) { + bigAvatarGroupCallImage.setVisibility(View.VISIBLE); + bigAvatarGroupCallImage.setImageBitmap(bitmap); + bigAvatarGroupCallInitialLetter.setVisibility(GONE); + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + avatar.delete(); + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatarGroupCall(userHandle, fullName); + } + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatarGroupCall(userHandle, fullName); + } + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + createDefaultAvatarGroupCall(userHandle, fullName); + } + } + + public void createDefaultAvatarGroupCall(long userHandle, String fullName) { + log("createDefaultAvatarGroupCall"); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + p.setColor(Color.parseColor(color)); + }else{ + p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); + String contactFirstLetter = fullName.charAt(0) + ""; + contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); + bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); + bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index ee5d7c77e91..6883b7fca83 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -137,7 +137,6 @@ public void onAttach(Context context) { @Override public void onDestroy(){ log("onDestroy"); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e6a1902c68b..2a0363e4089 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -60,8 +60,9 @@ import static mega.privacy.android.app.utils.Util.deleteFolderAndSubfolders; import static mega.privacy.android.app.utils.Util.percScreenLogin; +//public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { -public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { +public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { Context context; MegaApiAndroid megaApi; @@ -113,18 +114,18 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList 4) && (numPeersOnCall < 6)){ + }else if((numPeersOnCall > 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; - - }else if(numPeersOnCall >= 6){ + }else if(numPeersOnCall >= 7){ lp.height = Util.scaleWidthPx(90, outMetrics); lp.width = Util.scaleWidthPx(90, outMetrics); } @@ -241,9 +239,9 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - if(numPeersOnCall < 6){ - log("onCreateViewHolder() - peers < 6"); - holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); + if(numPeersOnCall < 7){ + log("onCreateViewHolder() - peers < 7"); +// holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); @@ -258,7 +256,7 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); }else{ - log("onCreateViewHolder() - peers >= 6"); + log("onCreateViewHolder() - peers >= 7"); holderGrid.avatarMicroLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent_black)); @@ -289,7 +287,6 @@ public int getItemViewType(int position) { public void onBindViewHolder(ViewHolderGroupCall holder, int position) { ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder; onBindViewHolderGrid(holderGrid2, position); - } public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int position){ @@ -300,20 +297,24 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi return; } + int numPeersOnCall = getItemCount(); + holder.rlGeneral.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - log("onClick() send my positon: "+holder.getPosition()); - listener.onItemClick(holder.getPosition()); + if(getItemCount() < 7){ + ((ChatCallActivity) context).remoteCameraClick(); + }else{ + listener.onItemClick(holder.getPosition()); + } + } }); - int numPeersOnCall = getItemCount(); if(peer.isVideoOn()) { log("Video ON - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ - log("1"); //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = maxScreenWidth; @@ -322,8 +323,6 @@ public void onClick(View v) { holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 2){ - log("2"); - //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); @@ -332,8 +331,6 @@ public void onClick(View v) { holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 3){ - log("3"); - //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); @@ -342,8 +339,6 @@ public void onClick(View v) { holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 4){ - log("4"); - //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); @@ -358,8 +353,6 @@ public void onClick(View v) { holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 5){ - log("5"); - //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); @@ -374,19 +367,14 @@ public void onClick(View v) { holder.rlGeneral.setLayoutParams(layoutParamsPeer); } + }else if(numPeersOnCall == 6){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); } -// else if(numPeersOnCall == 6){ -// log("6"); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// } - - holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -408,10 +396,12 @@ public void onClick(View v) { holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); - if(numPeersOnCall >= 6){ + if(numPeersOnCall > 6){ log("add listener in local Renderer"); - holder.localRenderer.addListener(this); + }else{ + log("remove listener in local Renderer"); + holder.localRenderer.addListener(null); } //Update micro icon @@ -419,7 +409,7 @@ public void onClick(View v) { RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - if(numPeersOnCall < 6){ + if(numPeersOnCall < 7){ paramsMicroSurface.setMargins(0, 50, 50, 0); }else{ paramsMicroSurface.setMargins(0, 4, 4, 0); @@ -452,7 +442,6 @@ public void onClick(View v) { }else{ log("Video OFF - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ - log("1"); //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = maxScreenWidth; @@ -461,8 +450,6 @@ public void onClick(View v) { holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 2){ - log("2"); - //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); @@ -471,8 +458,6 @@ public void onClick(View v) { holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 3){ - log("3"); - //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); @@ -481,8 +466,6 @@ public void onClick(View v) { holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 4){ - log("4"); - //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); @@ -497,8 +480,6 @@ public void onClick(View v) { holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); }else if(numPeersOnCall == 5){ - log("5"); - //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); @@ -513,19 +494,15 @@ public void onClick(View v) { layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); } - + }else if(numPeersOnCall == 6){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); } -// else if(numPeersOnCall == 6){ -// log("6"); -// -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// } holder.microSurface.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 75fee21d207..4076c1d3753 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -34,7 +34,7 @@ android:scrollbars="horizontal" android:layout_centerHorizontal="true" android:nestedScrollingEnabled="false"/> - + + android:background="@android:color/transparent" + android:visibility="gone"> + + + + + + + + + + + android:background="@color/green_free_account"> @@ -35,7 +35,7 @@ android:layout_centerVertical="true" android:layout_gravity="center" android:textAlignment="center" - android:background="@android:color/transparent"> + android:background="@android:color/holo_orange_dark"> Date: Fri, 21 Sep 2018 13:58:25 +0200 Subject: [PATCH 064/247] Feature#9775-Group calls UI(1-6) --- .../megachat/calls/ChatCallActivity.java | 667 ++++++++++-------- .../calls/MegaSurfaceRendererGroup.java | 24 +- .../chatAdapters/GroupCallAdapter.java | 169 +++-- .../main/res/layout/activity_calls_chat.xml | 100 +-- .../res/layout/item_camera_group_call.xml | 10 +- 5 files changed, 556 insertions(+), 414 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 45e68c52b7f..d1e4ee0b4de 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -139,7 +139,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Toolbar tB; ActionBar aB; boolean avatarRequested = false; - InfoPeerGroupCall peerSelected = null; +// InfoPeerGroupCall peerSelected = null; ArrayList peersOnCall = new ArrayList<>(); ArrayList peersBeforeCall = new ArrayList<>(); @@ -198,13 +198,13 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; - //Big elements for group call (more than 6 users) - FrameLayout fragmentContainerBigCameraGroupCall; - ViewGroup parentBigCameraGroupCall; - private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; - RelativeLayout bigAvatarGroupCallLayout; - RoundedImageView bigAvatarGroupCallImage; - TextView bigAvatarGroupCallInitialLetter; +// //Big elements for group call (more than 6 users) +// FrameLayout fragmentContainerBigCameraGroupCall; +// ViewGroup parentBigCameraGroupCall; +// private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; +// RelativeLayout bigAvatarGroupCallLayout; +// RoundedImageView bigAvatarGroupCallImage; +// TextView bigAvatarGroupCallInitialLetter; private SensorManager mSensorManager; private Sensor mSensor; @@ -329,6 +329,8 @@ public void updateScreenStatusInProgress(){ } if (!peerContain) { if(userHandle == megaChatApi.getMyUserHandle()){ + log("updateScreenStatusInProgress()-peersOnCall.add("+megaChatApi.getMyFullname()+")-> ME"); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); changes = true; @@ -336,6 +338,7 @@ public void updateScreenStatusInProgress(){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log("updateScreenStatusInProgress()-peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); changes = true; @@ -432,7 +435,7 @@ public void updateSubTitle(){ protected void onNewIntent(Intent intent) { super.onNewIntent(intent); - log("onNewIntent"); + log("onNewIntent()"); Bundle extras = intent.getExtras(); log(getIntent().getAction()); @@ -441,8 +444,7 @@ protected void onNewIntent(Intent intent) { log("New chat id: "+newChatId); if(chatId==newChatId){ log("Its the same call"); - } - else{ + }else{ log("New intent to the activity with a new chatId"); //Check the new call if in progress chatId = newChatId; @@ -464,7 +466,7 @@ protected void onNewIntent(Intent intent) { @Override protected void onCreate(Bundle savedInstanceState) { - log("onCreate"); + log("onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_calls_chat); @@ -628,31 +630,32 @@ protected void onCreate(Bundle savedInstanceState) { layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); bigRecyclerView.setLayoutManager(layoutManager); - + bigRecyclerView.setClipToPadding(false); + bigRecyclerView.setHasFixedSize(true); bigRecyclerView.setVisibility(GONE); - //Big elements group calls - parentBigCameraGroupCall = (ViewGroup) findViewById(R.id.parent_layout_big_camera_group_call); - ViewGroup.LayoutParams paramsBigCameraGroupCall = (ViewGroup.LayoutParams) parentBigCameraGroupCall.getLayoutParams(); - if(widthScreenPX change my status to IN PROGRESS"); createNewAdapter(true); } }else{ - log("CALL_STATUS_IN_PROGRESS- peersOnCall.add("+megaChatApi.getMyFullname()+")"); InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); peersOnCall.add(myPeer); - createNewAdapter(true); +// createNewAdapter(true); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1468,11 +1478,16 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log("SESSION_STATUS_IN_PROGRESS"); updateSubTitle(); //contact joined the group call + log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); + boolean changes = false; + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + boolean peerContain = false; for(InfoPeerGroupCall peer : peersOnCall) { if (peer.getHandle().equals(userHandle)) { @@ -1481,26 +1496,32 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } } if(!peerContain){ - log("CHANGE_TYPE_SESSION_STATUS: peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); + changes = true; + } + if(changes){ createNewAdapter(true); } } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ + log("SESSION_STATUS_DESTROYED"); updateSubTitle(); //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); boolean changes = false; - for(int i=0;i peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); @@ -2156,7 +2179,7 @@ public void updateRemoteVideoStatus(long userHandle){ // createBigFragment(peerSelected.getHandle()); // } // } - break; +// break; } } } @@ -2169,6 +2192,7 @@ public void updateRemoteVideoStatus(long userHandle){ log("remove Remote Video for "+peersOnCall.get(i).getName()+" camera FALSE"); peersOnCall.get(i).setVideoOn(false); adapter.notifyItemChanged(i); + break; } // if(peerSelected != null){ // log("updateRemoteVideoStatus()-> peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); @@ -2177,7 +2201,7 @@ public void updateRemoteVideoStatus(long userHandle){ // removeBigFragment(peerSelected.getHandle(), peerSelected.getName()); // } // } - break; +// break; } } } @@ -2473,21 +2497,30 @@ public void animationAlphaArrows(final ImageView arrow){ } public void createNewAdapter(boolean flag){ - log("createNewAdapter"); + log("createNewAdapter()"); if(flag){ + //arrayList-> peersOnCall if(peersOnCall.size() < 7){ + bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); +// parentBigCameraGroupCall.setOnClickListener(null); +// parentBigCameraGroupCall.setVisibility(View.GONE); - if(peersOnCall.size() <= 4){ + if(peersOnCall.size() < 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; recyclerView.setLayoutParams(params); + + }else if(peersOnCall.size()==4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(360, outMetrics); + recyclerView.setLayoutParams(params); + }else{ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; @@ -2502,7 +2535,8 @@ public void createNewAdapter(boolean flag){ } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2513,24 +2547,28 @@ public void createNewAdapter(boolean flag){ }else{ recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - +// parentBigCameraGroupCall.setOnClickListener(this); +// parentBigCameraGroupCall.setVisibility(View.VISIBLE); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ - @Override - public void onItemClick(int position) { + + adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + +// bigRecyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ +// @Override-̣ +// public void onItemClick(int position) { // do what ever you want to do with it - peerSelected = adapter.getNodeAt(position); +// peerSelected = adapter.getNodeAt(position); // if(peerSelected.getHandle().equals(megaChatApi.getMyUserHandle())){ // updateLocalVideoStatus(); // }else{ // updateRemoteVideoStatus(peerSelected.getHandle()); // // } - - } - }); +// +// } +// }); bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2541,21 +2579,41 @@ public void onItemClick(int position) { } }else{ - parentBigCameraGroupCall.setVisibility(View.GONE); + +// parentBigCameraGroupCall.setVisibility(View.GONE); //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); +// parentBigCameraGroupCall.setOnClickListener(null); +// parentBigCameraGroupCall.setVisibility(View.GONE); + +// if(peersBeforeCall.size() <= 4){ +// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); +// params.width = ViewGroup.LayoutParams.MATCH_PARENT; +// params.height = ViewGroup.LayoutParams.MATCH_PARENT; +// recyclerView.setLayoutParams(params); +// }else{ +// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); +// params.width = ViewGroup.LayoutParams.MATCH_PARENT; +// params.height = Util.scaleWidthPx(540, outMetrics); +// recyclerView.setLayoutParams(params); +// } - if(peersBeforeCall.size() <= 4){ + if(peersBeforeCall.size() < 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; recyclerView.setLayoutParams(params); + + }else if(peersBeforeCall.size()==4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(360, outMetrics); + recyclerView.setLayoutParams(params); + }else{ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; @@ -2567,10 +2625,13 @@ public void onItemClick(int position) { recyclerView.setColumnWidth((int) widthScreenPX); }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ recyclerView.setColumnWidth((int) widthScreenPX/2); + } recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, null); +// adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); + recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); @@ -2579,15 +2640,15 @@ public void onItemClick(int position) { } }else{ - log("createNewAdapter() - peersBeforeCall: "+peersBeforeCall.size()+" >= 7"); - recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); +// parentBigCameraGroupCall.setOnClickListener(null); +// parentBigCameraGroupCall.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, null); +// adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, null); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); + bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2601,217 +2662,217 @@ public void onItemClick(int position) { } - public void createBigFragment(Long handle){ - log("createBigFragment()"); - if(bigCameraGroupCallFragment != null){ - log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(bigCameraGroupCallFragment); - bigCameraGroupCallFragment = null; - } - - //Camera - if(bigCameraGroupCallFragment == null){ - log("CREATE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId, handle); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); - ftFS.commitNowAllowingStateLoss(); - } - fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); - - //Avatar - bigAvatarGroupCallLayout.setVisibility(View.GONE); - - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - - } - - public void removeBigFragment(Long handle, String fullName){ - - //Camera - if (bigCameraGroupCallFragment != null) { - log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(bigCameraGroupCallFragment); - bigCameraGroupCallFragment = null; - } - fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); - - //Avatar - if(handle.equals(megaChatApi.getMyUserHandle())){ - setProfileMyAvatarGroupCall(); - }else{ - setProfileContactAvatarGroupCall(handle,fullName); - } - bigAvatarGroupCallLayout.setVisibility(View.VISIBLE); - - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - } - - public void setProfileMyAvatarGroupCall() { - log("setProfileMyAvatarGroupCall"); - Bitmap myBitmap = null; - File avatar = null; - if (context != null) { - log("context is not null"); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } - } - if (avatar.exists()) { - if (avatar.length() > 0) { - BitmapFactory.Options bOpts = new BitmapFactory.Options(); - bOpts.inPurgeable = true; - bOpts.inInputShareable = true; - myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); - if (myBitmap != null) { - bigAvatarGroupCallImage.setImageBitmap(myBitmap); - bigAvatarGroupCallInitialLetter.setVisibility(GONE); - }else{ - createMyDefaultAvatarGroupCall(); - } - }else { - createMyDefaultAvatarGroupCall(); - } - }else { - createMyDefaultAvatarGroupCall(); - } - } - - public void createMyDefaultAvatarGroupCall() { - log("createMyDefaultAvatarGroupCall"); - String myFullName = megaChatApi.getMyFullname(); - String myFirstLetter = myFullName.charAt(0) + ""; - myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); - long userHandle = megaChatApi.getMyUserHandle(); - - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint p = new Paint(); - p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); - - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if (color != null) { - p.setColor(Color.parseColor(color)); - }else { - p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); - } - - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { - radius = defaultAvatar.getWidth() / 2; - }else { - radius = defaultAvatar.getHeight() / 2; - } - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); - bigAvatarGroupCallInitialLetter.setText(myFirstLetter); - bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); - } - - public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ - log("setProfileContactAvatarGroupCall"); - Bitmap bitmap = null; - File avatar = null; - String contactMail = megaChatApi.getContactEmail(userHandle); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } - - if (avatar.exists()) { - if (avatar.length() > 0) { - BitmapFactory.Options bOpts = new BitmapFactory.Options(); - bOpts.inPurgeable = true; - bOpts.inInputShareable = true; - bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); - if (bitmap != null) { - bigAvatarGroupCallImage.setVisibility(View.VISIBLE); - bigAvatarGroupCallImage.setImageBitmap(bitmap); - bigAvatarGroupCallInitialLetter.setVisibility(GONE); - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - avatar.delete(); - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - - createDefaultAvatarGroupCall(userHandle, fullName); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - - createDefaultAvatarGroupCall(userHandle, fullName); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - createDefaultAvatarGroupCall(userHandle, fullName); - } - } - - public void createDefaultAvatarGroupCall(long userHandle, String fullName) { - log("createDefaultAvatarGroupCall"); - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint p = new Paint(); - p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); - - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if (color != null) { - p.setColor(Color.parseColor(color)); - }else{ - p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); - } +// public void createBigFragment(Long handle){ +// log("createBigFragment()"); +// if(bigCameraGroupCallFragment != null){ +// log("REMOVE bigCameraGroupCallFragment"); +// bigCameraGroupCallFragment.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(bigCameraGroupCallFragment); +// bigCameraGroupCallFragment = null; +// } +// +// //Camera +// if(bigCameraGroupCallFragment == null){ +// log("CREATE bigCameraGroupCallFragment"); +// bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId, handle); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); +// ftFS.commitNowAllowingStateLoss(); +// } +// fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); +// +// //Avatar +// bigAvatarGroupCallLayout.setVisibility(View.GONE); +// +// parentBigCameraGroupCall.setVisibility(View.VISIBLE); +// +// } - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { - radius = defaultAvatar.getWidth() / 2; - }else { - radius = defaultAvatar.getHeight() / 2; - } - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); - String contactFirstLetter = fullName.charAt(0) + ""; - contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); - bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); - bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); - } +// public void removeBigFragment(Long handle, String fullName){ +// +// //Camera +// if (bigCameraGroupCallFragment != null) { +// log("REMOVE bigCameraGroupCallFragment"); +// bigCameraGroupCallFragment.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(bigCameraGroupCallFragment); +// bigCameraGroupCallFragment = null; +// } +// fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); +// +// //Avatar +// if(handle.equals(megaChatApi.getMyUserHandle())){ +// setProfileMyAvatarGroupCall(); +// }else{ +// setProfileContactAvatarGroupCall(handle,fullName); +// } +// bigAvatarGroupCallLayout.setVisibility(View.VISIBLE); +// +// parentBigCameraGroupCall.setVisibility(View.VISIBLE); +// } +// +// public void setProfileMyAvatarGroupCall() { +// log("setProfileMyAvatarGroupCall"); +// Bitmap myBitmap = null; +// File avatar = null; +// if (context != null) { +// log("context is not null"); +// if (context.getExternalCacheDir() != null) { +// avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); +// } else { +// avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); +// } +// } +// if (avatar.exists()) { +// if (avatar.length() > 0) { +// BitmapFactory.Options bOpts = new BitmapFactory.Options(); +// bOpts.inPurgeable = true; +// bOpts.inInputShareable = true; +// myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); +// myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); +// if (myBitmap != null) { +// bigAvatarGroupCallImage.setImageBitmap(myBitmap); +// bigAvatarGroupCallInitialLetter.setVisibility(GONE); +// }else{ +// createMyDefaultAvatarGroupCall(); +// } +// }else { +// createMyDefaultAvatarGroupCall(); +// } +// }else { +// createMyDefaultAvatarGroupCall(); +// } +// } + +// public void createMyDefaultAvatarGroupCall() { +// log("createMyDefaultAvatarGroupCall"); +// String myFullName = megaChatApi.getMyFullname(); +// String myFirstLetter = myFullName.charAt(0) + ""; +// myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); +// long userHandle = megaChatApi.getMyUserHandle(); +// +// Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); +// Canvas c = new Canvas(defaultAvatar); +// Paint p = new Paint(); +// p.setAntiAlias(true); +// p.setColor(Color.TRANSPARENT); +// +// String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); +// if (color != null) { +// p.setColor(Color.parseColor(color)); +// }else { +// p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); +// } +// +// int radius; +// if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { +// radius = defaultAvatar.getWidth() / 2; +// }else { +// radius = defaultAvatar.getHeight() / 2; +// } +// c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); +// bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); +// bigAvatarGroupCallInitialLetter.setText(myFirstLetter); +// bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); +// } + +// public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ +// log("setProfileContactAvatarGroupCall"); +// Bitmap bitmap = null; +// File avatar = null; +// String contactMail = megaChatApi.getContactEmail(userHandle); +// if (context.getExternalCacheDir() != null) { +// avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); +// } else { +// avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); +// } +// +// if (avatar.exists()) { +// if (avatar.length() > 0) { +// BitmapFactory.Options bOpts = new BitmapFactory.Options(); +// bOpts.inPurgeable = true; +// bOpts.inInputShareable = true; +// bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); +// bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); +// if (bitmap != null) { +// bigAvatarGroupCallImage.setVisibility(View.VISIBLE); +// bigAvatarGroupCallImage.setImageBitmap(bitmap); +// bigAvatarGroupCallInitialLetter.setVisibility(GONE); +// }else{ +// UserAvatarListener listener = new UserAvatarListener(context); +// avatar.delete(); +// if(!avatarRequested){ +// avatarRequested = true; +// if (context.getExternalCacheDir() != null){ +// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// else{ +// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// } +// +// createDefaultAvatarGroupCall(userHandle, fullName); +// } +// }else{ +// UserAvatarListener listener = new UserAvatarListener(context); +// +// if(!avatarRequested){ +// avatarRequested = true; +// if (context.getExternalCacheDir() != null){ +// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// else{ +// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// } +// +// createDefaultAvatarGroupCall(userHandle, fullName); +// } +// }else{ +// UserAvatarListener listener = new UserAvatarListener(context); +// +// if(!avatarRequested){ +// avatarRequested = true; +// if (context.getExternalCacheDir() != null){ +// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// else{ +// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); +// } +// } +// createDefaultAvatarGroupCall(userHandle, fullName); +// } +// } + +// public void createDefaultAvatarGroupCall(long userHandle, String fullName) { +// log("createDefaultAvatarGroupCall"); +// Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); +// Canvas c = new Canvas(defaultAvatar); +// Paint p = new Paint(); +// p.setAntiAlias(true); +// p.setColor(Color.TRANSPARENT); +// +// String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); +// if (color != null) { +// p.setColor(Color.parseColor(color)); +// }else{ +// p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); +// } +// +// int radius; +// if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { +// radius = defaultAvatar.getWidth() / 2; +// }else { +// radius = defaultAvatar.getHeight() / 2; +// } +// c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); +// bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); +// String contactFirstLetter = fullName.charAt(0) + ""; +// contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); +// bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); +// bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); +// } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index 8d4b187585e..d41a0c030a0 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -68,11 +68,14 @@ public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { private Bitmap bitmap = null; private ByteBuffer byteBuffer = null; private SurfaceHolder surfaceHolder; + // Rect of the source bitmap to draw private Rect srcRect = new Rect(); + // Rect of the destination canvas to draw to private Rect dstRect = new Rect(); private RectF dstRectf = new RectF(); + Paint paint; PorterDuffXfermode modesrcover; PorterDuffXfermode modesrcin; @@ -110,13 +113,13 @@ private void changeDestRect(int dstWidth, int dstHeight) { } public void surfaceCreated(SurfaceHolder holder) { - log("surfaceCreated()"); + log("**** surfaceCreated()"); Canvas canvas = holder.lockCanvas(); if(canvas != null) { Rect dst = holder.getSurfaceFrame(); if(dst != null) { - notifyStateToAll(); +// notifyStateToAll(); changeDestRect(dst.right - dst.left, dst.bottom - dst.top); Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + " dst.left:" + dst.left + @@ -155,7 +158,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - log("surfaceDestroyed(): "); + log("****** surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; @@ -176,26 +179,36 @@ public Bitmap CreateBitmap(int width, int height) { } if(height == width){ + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); srcRect.top = 0; srcRect.bottom = height; srcRect.left = 0; srcRect.right = width; + log("CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + }else if(height > width){ + int newHeight = width; bitmap = Bitmap.createBitmap(width, newHeight, Bitmap.Config.ARGB_8888); srcRect.top = 0; srcRect.bottom = newHeight; srcRect.left = 0; srcRect.right = width; + log("CreateBitmap(): height > width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + }else{ + log("CreateBitmap(): height < width"); + int newWidth = height; bitmap = Bitmap.createBitmap(newWidth, height, Bitmap.Config.ARGB_8888); srcRect.left = 0; srcRect.right = newWidth; srcRect.top = 0; srcRect.bottom = height; + log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + } return bitmap; } @@ -229,16 +242,21 @@ private static void log(String log) { } private void notifyStateToAll() { + log("notifyStateToAll()"); for(MegaSurfaceRendererGroupListener listener : listeners) notifyState(listener); } public void addListener(MegaSurfaceRendererGroupListener l) { + log("addListener()"); + listeners.add(l); notifyState(l); } private void notifyState(MegaSurfaceRendererGroupListener listener) { + log("notifyState()"); + if(listener == null) return; listener.resetSize(handleUser); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 2a0363e4089..4f56ce4f5fd 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -60,9 +60,9 @@ import static mega.privacy.android.app.utils.Util.deleteFolderAndSubfolders; import static mega.privacy.android.app.utils.Util.percScreenLogin; -//public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { +public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { -public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { +//public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { Context context; MegaApiAndroid megaApi; @@ -74,7 +74,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { - log("GroupCallAdapter(peers: "+peers.size()+")"); +// public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { +public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress) { + + log("GroupCallAdapter(peers: "+peers.size()+")"); this.context = context; this.recyclerViewFragment = recyclerView; @@ -96,7 +98,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList 4) && (numPeersOnCall < 7)){ + + }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; }else if(numPeersOnCall >= 7){ @@ -215,11 +215,11 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); -// if(numPeersOnCall<6){ -// holderGrid.rlGeneral.setOnClickListener(this); -// }else{ -// holderGrid.rlGeneral.setOnClickListener(null); -// } + if(numPeersOnCall < 7){ + holderGrid.rlGeneral.setOnClickListener(this); + }else{ + holderGrid.rlGeneral.setOnClickListener(null); + } holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.surfaceViewLayout.removeAllViewsInLayout(); @@ -240,9 +240,6 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); if(numPeersOnCall < 7){ - log("onCreateViewHolder() - peers < 7"); -// holderGrid.avatarMicroLayout.setBackgroundColor(Color.TRANSPARENT); - RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); @@ -256,23 +253,81 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); }else{ - log("onCreateViewHolder() - peers >= 7"); - - holderGrid.avatarMicroLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent_black)); - RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); paramsMicroAvatar.setMargins(0, 0, 0, 0); - paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); - paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); paramsAvatarImage.width = Util.scaleWidthPx(60, outMetrics); paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); } + + + +// if(numPeersOnCall == 1){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = maxScreenWidth; +// layoutParamsAvatar.height = maxScreenWidth; +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); +// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = maxScreenWidth; +// layoutParamsSurface.height = maxScreenWidth; +// layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); +// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// }else if(numPeersOnCall == 2){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// }else if(numPeersOnCall == 3){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// }else if(numPeersOnCall == 4){ +// //Avatar Layout: +// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); +// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); +// +// //Surface Layout: +// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); +// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); +// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); +// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); +// +// } + v.setTag(holderGrid); return holderGrid; @@ -299,22 +354,23 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi int numPeersOnCall = getItemCount(); - holder.rlGeneral.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(getItemCount() < 7){ - ((ChatCallActivity) context).remoteCameraClick(); - }else{ - listener.onItemClick(holder.getPosition()); - } - - } - }); +// holder.rlGeneral.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// if(getItemCount() < 7){ +// ((ChatCallActivity) context).remoteCameraClick(); +// }else{ +// listener.onItemClick(holder.getPosition()); +// } +// +// } +// }); if(peer.isVideoOn()) { log("Video ON - numPeersOnCall: "+numPeersOnCall); if(numPeersOnCall == 1){ + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); layoutParamsSurface.width = maxScreenWidth; @@ -347,8 +403,10 @@ public void onClick(View v) { if((position < 2)){ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); @@ -396,12 +454,12 @@ public void onClick(View v) { holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); - if(numPeersOnCall > 6){ + if(numPeersOnCall < 7){ log("add listener in local Renderer"); - holder.localRenderer.addListener(this); + holder.localRenderer.addListener(null); }else{ log("remove listener in local Renderer"); - holder.localRenderer.addListener(null); + holder.localRenderer.addListener(this); } //Update micro icon @@ -441,6 +499,7 @@ public void onClick(View v) { }else{ log("Video OFF - numPeersOnCall: "+numPeersOnCall); + if(numPeersOnCall == 1){ //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); @@ -474,8 +533,10 @@ public void onClick(View v) { if((position < 2)){ layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); @@ -485,23 +546,23 @@ public void onClick(View v) { layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); layoutParamsPeer.width = maxScreenWidth; layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); } + }else if(numPeersOnCall == 6){ //Avatar Layout: RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + } holder.microSurface.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 4076c1d3753..b4f6ae277d2 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -25,6 +25,7 @@ android:id="@+id/big_elements_group_call" android:layout_width="match_parent" android:layout_height="match_parent" + android:gravity="center_vertical" android:background="@color/black"> - - - - - + android:nestedScrollingEnabled="false"/> - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="@color/black"> @@ -35,7 +35,7 @@ android:layout_centerVertical="true" android:layout_gravity="center" android:textAlignment="center" - android:background="@android:color/holo_orange_dark"> + android:background="@android:color/transparent"> Date: Fri, 21 Sep 2018 14:08:22 +0200 Subject: [PATCH 065/247] Feature#9775-Group calls UI(1-6) --- .../megachat/calls/ChatCallActivity.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index d1e4ee0b4de..7edb19569d3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -761,21 +761,21 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ -//*DES -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("onCreate()-> Incoming group call"); From 2fee14da5e12ecfef4543bca9911719cc4591df4 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 21 Sep 2018 14:37:29 +0200 Subject: [PATCH 066/247] Feature#9775-Group calls UI (1-6 users) --- .../megachat/calls/ChatCallActivity.java | 49 ++++++++++--------- .../chatAdapters/GroupCallAdapter.java | 10 ++++ .../main/res/layout/activity_calls_chat.xml | 4 +- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 7edb19569d3..fd714611d8b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -761,21 +761,22 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ + //*********Descomentar - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); - MyRingerTask myRingerTask = new MyRingerTask(); - ringerTimer.schedule(myRingerTask, 0, 500); - - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] pattern = {0, 1000, 500, 500, 1000}; - if (vibrator != null){ - if (vibrator.hasVibrator()){ - //FOR API>=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ log("onCreate()-> Incoming group call"); @@ -827,15 +828,17 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } + //*********Descomentar + +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("onCreate()-> Outgoing group call"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 4f56ce4f5fd..157bba0d2e3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -423,6 +423,11 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi layoutParamsPeer.width = maxScreenWidth; layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); + }else{ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = (maxScreenWidth/2); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); } }else if(numPeersOnCall == 6){ @@ -553,6 +558,11 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi layoutParamsPeer.width = maxScreenWidth; layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); holder.rlGeneral.setLayoutParams(layoutParamsPeer); + }else{ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = (maxScreenWidth/2); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); } }else if(numPeersOnCall == 6){ diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index b4f6ae277d2..51416a14b6c 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -30,8 +30,8 @@ Date: Fri, 21 Sep 2018 14:40:21 +0200 Subject: [PATCH 067/247] Feature#9775-Group calls UI (1-6 users) --- .../megachat/calls/ChatCallActivity.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index fd714611d8b..dfd313a00b9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -761,22 +761,21 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - //*********Descomentar -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("onCreate()-> Incoming group call"); @@ -828,17 +827,16 @@ protected void onCreate(Bundle savedInstanceState) { }else{ - //*********Descomentar -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("onCreate()-> Outgoing group call"); From a7159b62804ae3f0cb6c009c5ba303b559d7eb6c Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 24 Sep 2018 11:15:11 +0200 Subject: [PATCH 068/247] Feature#9775-Group calls UI (more than 6 users) --- .../megachat/calls/ChatCallActivity.java | 9 +- .../calls/MegaSurfaceRendererGroup.java | 8 +- .../chatAdapters/GroupCallAdapter.java | 345 +++++++----------- .../main/res/layout/activity_calls_chat.xml | 3 +- 4 files changed, 148 insertions(+), 217 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index dfd313a00b9..b56acfdefa6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -156,6 +156,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque LinearLayoutManager layoutManager; RecyclerView bigRecyclerView; + GroupCallAdapter adapter; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -630,8 +631,6 @@ protected void onCreate(Bundle savedInstanceState) { layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); bigRecyclerView.setLayoutManager(layoutManager); - bigRecyclerView.setClipToPadding(false); - bigRecyclerView.setHasFixedSize(true); bigRecyclerView.setVisibility(GONE); // //Big elements group calls @@ -762,6 +761,7 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -2504,7 +2504,6 @@ public void createNewAdapter(boolean flag){ //arrayList-> peersOnCall if(peersOnCall.size() < 7){ - bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); // parentBigCameraGroupCall.setOnClickListener(null); @@ -2580,12 +2579,9 @@ public void createNewAdapter(boolean flag){ } }else{ - // parentBigCameraGroupCall.setVisibility(View.GONE); - //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { - bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); // parentBigCameraGroupCall.setOnClickListener(null); @@ -2641,6 +2637,7 @@ public void createNewAdapter(boolean flag){ } }else{ + recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); // parentBigCameraGroupCall.setOnClickListener(null); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index d41a0c030a0..c448888d36e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -119,7 +119,7 @@ public void surfaceCreated(SurfaceHolder holder) { if(canvas != null) { Rect dst = holder.getSurfaceFrame(); if(dst != null) { -// notifyStateToAll(); + notifyStateToAll(); changeDestRect(dst.right - dst.left, dst.bottom - dst.top); Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + " dst.left:" + dst.left + @@ -242,20 +242,20 @@ private static void log(String log) { } private void notifyStateToAll() { - log("notifyStateToAll()"); + log("**** notifyStateToAll()"); for(MegaSurfaceRendererGroupListener listener : listeners) notifyState(listener); } public void addListener(MegaSurfaceRendererGroupListener l) { - log("addListener()"); + log("**** addListener()"); listeners.add(l); notifyState(l); } private void notifyState(MegaSurfaceRendererGroupListener listener) { - log("notifyState()"); + log("**** notifyState()"); if(listener == null) return; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 157bba0d2e3..3215e644ad1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -90,7 +90,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress) { - log("GroupCallAdapter(peers: "+peers.size()+")"); + log("**** GroupCallAdapter(peers: "+peers.size()+")"); this.context = context; this.recyclerViewFragment = recyclerView; @@ -131,7 +131,7 @@ public void onClick(View v) { @Override public void resetSize(Long userHandle) { - log("resetSize"); + log("**** resetSize"); if(getItemCount()!=0){ for(InfoPeerGroupCall peer:peers){ if(peer.getHandle() == userHandle){ @@ -203,7 +203,7 @@ public ViewHolderGroupCallGrid(View v) { }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; - }else if(numPeersOnCall >= 7){ + }else{ lp.height = Util.scaleWidthPx(90, outMetrics); lp.width = Util.scaleWidthPx(90, outMetrics); } @@ -212,7 +212,6 @@ public ViewHolderGroupCallGrid(View v) { holderGrid = new ViewHolderGroupCallGrid(v); - holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); if(numPeersOnCall < 7){ @@ -255,6 +254,8 @@ public ViewHolderGroupCallGrid(View v) { }else{ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); paramsMicroAvatar.setMargins(0, 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); @@ -264,70 +265,6 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); } - - -// if(numPeersOnCall == 1){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = maxScreenWidth; -// layoutParamsAvatar.height = maxScreenWidth; -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = maxScreenWidth; -// layoutParamsSurface.height = maxScreenWidth; -// layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); -// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 2){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 3){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// }else if(numPeersOnCall == 4){ -// //Avatar Layout: -// RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holderGrid.avatarMicroLayout.getLayoutParams(); -// layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); -// -// //Surface Layout: -// RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holderGrid.surfaceViewLayout.getLayoutParams(); -// layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); -// layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); -// holderGrid.surfaceViewLayout.setLayoutParams(layoutParamsSurface); -// -// } - v.setTag(holderGrid); return holderGrid; @@ -345,7 +282,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int position){ - log("onBindViewHolderGrid()"); + log("**** onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -369,76 +306,77 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi if(peer.isVideoOn()) { log("Video ON - numPeersOnCall: "+numPeersOnCall); - if(numPeersOnCall == 1){ - - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = maxScreenWidth; - layoutParamsSurface.height = maxScreenWidth; - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 2){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 3){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 4){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + if(numPeersOnCall < 7){ + if(numPeersOnCall == 1){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = maxScreenWidth; + layoutParamsSurface.height = maxScreenWidth; + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 2){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 3){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 4){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - }else{ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 5){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + }else{ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = (maxScreenWidth/2); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + }else if(numPeersOnCall == 6){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); } - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 5){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - }else{ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = (maxScreenWidth/2); - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - }else if(numPeersOnCall == 6){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); } + holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -460,10 +398,10 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); holder.surfaceViewLayout.addView(holder.surfaceView); if(numPeersOnCall < 7){ - log("add listener in local Renderer"); + log("remove listener in local Renderer"); holder.localRenderer.addListener(null); }else{ - log("remove listener in local Renderer"); + log("add listener in local Renderer"); holder.localRenderer.addListener(this); } @@ -496,7 +434,6 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("Video ON-> addChatLocalVideoListener() "); megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); - } else { log("Video ON-> addChatRemoteVideoListener()"); megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); @@ -505,74 +442,74 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int posi }else{ log("Video OFF - numPeersOnCall: "+numPeersOnCall); - if(numPeersOnCall == 1){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = maxScreenWidth; - layoutParamsAvatar.height = maxScreenWidth; - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 2){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 3){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 4){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + if(numPeersOnCall < 7){ + if(numPeersOnCall == 1){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = maxScreenWidth; + layoutParamsAvatar.height = maxScreenWidth; + layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 2){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 3){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 4){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - }else{ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + } + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + }else if(numPeersOnCall == 5){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + }else{ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = (maxScreenWidth/2); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + }else if(numPeersOnCall == 6){ + //Avatar Layout: + RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); + layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); } - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 5){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - }else{ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = (maxScreenWidth/2); - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - }else if(numPeersOnCall == 6){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - } holder.microSurface.setVisibility(View.GONE); @@ -705,10 +642,8 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { holder.avatarImage.setImageBitmap(defaultAvatar); holder.avatarInitialLetter.setText(myFirstLetter); holder.avatarInitialLetter.setVisibility(View.VISIBLE); - } - public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ Bitmap bitmap = null; File avatar = null; @@ -742,7 +677,6 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } } - createDefaultAvatar(userHandle, fullName, holder); } }else{ @@ -757,7 +691,6 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } } - createDefaultAvatar(userHandle, fullName, holder); } }else{ diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 51416a14b6c..02efbd2ae95 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -25,7 +25,6 @@ android:id="@+id/big_elements_group_call" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="center_vertical" android:background="@color/black"> From 3d539761d4b73fb3fe017814122910091049bc00 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 25 Sep 2018 13:13:22 +0200 Subject: [PATCH 069/247] Feature#9775-Group calls UI(7 +) --- .../megachat/calls/ChatCallActivity.java | 670 ++++++++++-------- .../calls/MegaSurfaceRendererGroup.java | 10 +- .../chatAdapters/GroupCallAdapter.java | 43 +- .../main/res/layout/activity_calls_chat.xml | 152 ++-- .../res/layout/item_camera_group_call.xml | 8 + app/src/main/res/values/colors.xml | 2 + 6 files changed, 517 insertions(+), 368 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b56acfdefa6..3afa40d66b1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -137,6 +137,12 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque float scaleH; AppBarLayout appBarLayout; Toolbar tB; + LinearLayout toolbarElements; + TextView titleToolbar; + TextView subtitleToobar; + LinearLayout linearParticipants; + TextView participantText; + ActionBar aB; boolean avatarRequested = false; // InfoPeerGroupCall peerSelected = null; @@ -147,6 +153,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; + Long userSpeaking = null; RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -199,13 +206,13 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; -// //Big elements for group call (more than 6 users) -// FrameLayout fragmentContainerBigCameraGroupCall; -// ViewGroup parentBigCameraGroupCall; -// private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; -// RelativeLayout bigAvatarGroupCallLayout; -// RoundedImageView bigAvatarGroupCallImage; -// TextView bigAvatarGroupCallInitialLetter; + //Big elements for group call (more than 6 users) + FrameLayout fragmentContainerBigCameraGroupCall; + ViewGroup parentBigCameraGroupCall; + private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; + RelativeLayout bigAvatarGroupCallLayout; + RoundedImageView bigAvatarGroupCallImage; + TextView bigAvatarGroupCallInitialLetter; private SensorManager mSensorManager; private Sensor mSensor; @@ -404,7 +411,9 @@ public void updateSubTitle(){ int sessionStatus = -1; if(callChat.getStatus()<=MegaChatCall.CALL_STATUS_RING_IN){ - aB.setSubtitle(getString(R.string.call_starting)); +// aB.setSubtitle(getString(R.string.call_starting)); + subtitleToobar.setText(getString(R.string.call_starting)); + }else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ if(chat.isGroup()){ startClock(); @@ -420,17 +429,22 @@ public void updateSubTitle(){ startClock(); } else{ - aB.setSubtitle(getString(R.string.chat_connecting)); +// aB.setSubtitle(getString(R.string.chat_connecting)); + subtitleToobar.setText(getString(R.string.chat_connecting)); + } } else{ log("Error getting the session of the user"); - aB.setSubtitle(null); +// aB.setSubtitle(null); + subtitleToobar.setText(null); } } } else{ - aB.setSubtitle(null); +// aB.setSubtitle(null); + subtitleToobar.setText(null); + } } @@ -452,7 +466,9 @@ protected void onNewIntent(Intent intent) { chat = megaChatApi.getChatRoom(chatId); callChat = megaChatApi.getChatCall(chatId); - aB.setTitle(chat.getTitle()); +// aB.setTitle(chat.getTitle()); + titleToolbar.setText(chat.getTitle()); + updateSubTitle(); updateScreenStatusInProgress(); @@ -561,7 +577,17 @@ protected void onCreate(Bundle savedInstanceState) { aB.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white); aB.setHomeButtonEnabled(true); aB.setDisplayHomeAsUpEnabled(true); - aB.setTitle(" "); + aB.setTitle(null); + aB.setSubtitle(null); +// aB.setTitle(" "); + + toolbarElements = (LinearLayout) tB.findViewById(R.id.toolbar_elements); + titleToolbar = (TextView) tB.findViewById(R.id.title_toolbar); + titleToolbar.setText(" "); + subtitleToobar = (TextView) tB.findViewById(R.id.subtitle_toolbar); + linearParticipants = (LinearLayout) tB.findViewById(R.id.ll_participants); + participantText = (TextView) tB.findViewById(R.id.participants_text); + linearParticipants.setVisibility(View.GONE); myChrono = new Chronometer(context); @@ -633,28 +659,25 @@ protected void onCreate(Bundle savedInstanceState) { bigRecyclerView.setLayoutManager(layoutManager); bigRecyclerView.setVisibility(GONE); -// //Big elements group calls -// parentBigCameraGroupCall = (ViewGroup) findViewById(R.id.parent_layout_big_camera_group_call); -// ViewGroup.LayoutParams paramsBigCameraGroupCall = (ViewGroup.LayoutParams) parentBigCameraGroupCall.getLayoutParams(); -// if(widthScreenPX= 7){ + + long userHandle = call.getPeerSessionStatusChange(); + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession != null){ + boolean userHasAudio = userSession.getAudioDetected(); + if(userHasAudio){ + userSpeaking = userHandle; + if(userSession.hasVideo()){ + createBigFragment(userHandle); + }else{ + removeBigFragment(userHandle, chat.getPeerFullnameByHandle(userHandle)); + } + }else{ + int position = -1; + for(int i=0; i peerSelected.getHandle(): "+peerSelected.getHandle()+", peersOnCall.get(peersOnCall.size()-1).getHandle(): "+peersOnCall.get(peersOnCall.size()-1).getHandle()); -// if(peerSelected.getHandle().equals(peersOnCall.get(peersOnCall.size()-1).getHandle())){ -// log("updateLocalVideoStatus()-> createBigFragment"); -// createBigFragment(peerSelected.getHandle()); -// } -// } } }else { @@ -2024,14 +2076,6 @@ public void updateLocalVideoStatus(){ item.setVideoOn(false); adapter.notifyItemChanged(peersOnCall.size()-1); } -// if(peerSelected != null){ -// log("updateLocalVideoStatus()-> peerSelected.getHandle(): "+peerSelected.getHandle()+", peersOnCall.get(peersOnCall.size()-1).getHandle(): "+peersOnCall.get(peersOnCall.size()-1).getHandle()); -// if(peerSelected.getHandle().equals(peersOnCall.get(peersOnCall.size()-1).getHandle())){ -// log("updateLocalVideoStatus()-> removeBigFragment"); -// removeBigFragment(peerSelected.getHandle(), peerSelected.getName()); -// } -// } - } } } @@ -2159,7 +2203,7 @@ public void updateLocalAudioStatus(){ } public void updateRemoteVideoStatus(long userHandle){ - log("updateRemoteVideoStatus"); + log("updateRemoteVideoStatus()"); if(chat.isGroup()){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null && userSession.hasVideo()) { @@ -2168,19 +2212,16 @@ public void updateRemoteVideoStatus(long userHandle){ for(int i=0;i peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); -// if(peerSelected.getHandle().equals(userHandle)){ -// log("updateRemoteVideoStatus()-> createBigFragment"); -// createBigFragment(peerSelected.getHandle()); -// } -// } -// break; } } } @@ -2190,19 +2231,16 @@ public void updateRemoteVideoStatus(long userHandle){ for(int i=0;i peerSelected.getHandle(): "+peerSelected.getHandle()+", userHandle: "+userHandle); -// if(peerSelected.getHandle().equals(userHandle)){ -// log("updateRemoteVideoStatus()-> removeBigFragment"); -// removeBigFragment(peerSelected.getHandle(), peerSelected.getName()); -// } -// } -// break; } } } @@ -2412,7 +2450,8 @@ private void startClock(){ private Runnable updateTimerThread = new Runnable() { public void run() { long elapsedTime = SystemClock.uptimeMillis() - myChrono.getBase(); - aB.setSubtitle(getDateFromMillis(elapsedTime)); +// aB.setSubtitle(getDateFromMillis(elapsedTime)); + subtitleToobar.setText(getDateFromMillis(elapsedTime)); customHandler.postDelayed(this, 0); } }; @@ -2501,13 +2540,15 @@ public void createNewAdapter(boolean flag){ log("createNewAdapter()"); if(flag){ - + participantText.setText(peersOnCall.size()+"/"+(chat.getPeerCount()+1)); + linearParticipants.setVisibility(View.VISIBLE); //arrayList-> peersOnCall if(peersOnCall.size() < 7){ + bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); -// parentBigCameraGroupCall.setOnClickListener(null); -// parentBigCameraGroupCall.setVisibility(View.GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); if(peersOnCall.size() < 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); @@ -2547,8 +2588,9 @@ public void createNewAdapter(boolean flag){ }else{ recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); -// parentBigCameraGroupCall.setOnClickListener(this); -// parentBigCameraGroupCall.setVisibility(View.VISIBLE); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + // adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); bigRecyclerView.setAdapter(null); @@ -2579,25 +2621,15 @@ public void createNewAdapter(boolean flag){ } }else{ -// parentBigCameraGroupCall.setVisibility(View.GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); + linearParticipants.setVisibility(View.VISIBLE); + + //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); -// parentBigCameraGroupCall.setOnClickListener(null); -// parentBigCameraGroupCall.setVisibility(View.GONE); - -// if(peersBeforeCall.size() <= 4){ -// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); -// params.width = ViewGroup.LayoutParams.MATCH_PARENT; -// params.height = ViewGroup.LayoutParams.MATCH_PARENT; -// recyclerView.setLayoutParams(params); -// }else{ -// ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); -// params.width = ViewGroup.LayoutParams.MATCH_PARENT; -// params.height = Util.scaleWidthPx(540, outMetrics); -// recyclerView.setLayoutParams(params); -// } if(peersBeforeCall.size() < 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); @@ -2640,8 +2672,6 @@ public void createNewAdapter(boolean flag){ recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); -// parentBigCameraGroupCall.setOnClickListener(null); -// parentBigCameraGroupCall.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); // adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, null); @@ -2660,217 +2690,237 @@ public void createNewAdapter(boolean flag){ } -// public void createBigFragment(Long handle){ -// log("createBigFragment()"); -// if(bigCameraGroupCallFragment != null){ -// log("REMOVE bigCameraGroupCallFragment"); -// bigCameraGroupCallFragment.setVideoFrame(false); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(bigCameraGroupCallFragment); -// bigCameraGroupCallFragment = null; -// } -// -// //Camera -// if(bigCameraGroupCallFragment == null){ -// log("CREATE bigCameraGroupCallFragment"); -// bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId, handle); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); -// ftFS.commitNowAllowingStateLoss(); -// } -// fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); -// -// //Avatar -// bigAvatarGroupCallLayout.setVisibility(View.GONE); -// -// parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// -// } + public void createBigFragment(Long handle){ + log("createBigFragment()"); + if(bigCameraGroupCallFragment != null){ + log("REMOVE bigCameraGroupCallFragment"); + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } -// public void removeBigFragment(Long handle, String fullName){ -// -// //Camera -// if (bigCameraGroupCallFragment != null) { -// log("REMOVE bigCameraGroupCallFragment"); -// bigCameraGroupCallFragment.setVideoFrame(false); -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(bigCameraGroupCallFragment); -// bigCameraGroupCallFragment = null; -// } -// fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); -// -// //Avatar -// if(handle.equals(megaChatApi.getMyUserHandle())){ -// setProfileMyAvatarGroupCall(); -// }else{ -// setProfileContactAvatarGroupCall(handle,fullName); -// } -// bigAvatarGroupCallLayout.setVisibility(View.VISIBLE); -// -// parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// } -// -// public void setProfileMyAvatarGroupCall() { -// log("setProfileMyAvatarGroupCall"); -// Bitmap myBitmap = null; -// File avatar = null; -// if (context != null) { -// log("context is not null"); -// if (context.getExternalCacheDir() != null) { -// avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); -// } else { -// avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); -// } -// } -// if (avatar.exists()) { -// if (avatar.length() > 0) { -// BitmapFactory.Options bOpts = new BitmapFactory.Options(); -// bOpts.inPurgeable = true; -// bOpts.inInputShareable = true; -// myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); -// myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); -// if (myBitmap != null) { -// bigAvatarGroupCallImage.setImageBitmap(myBitmap); -// bigAvatarGroupCallInitialLetter.setVisibility(GONE); -// }else{ -// createMyDefaultAvatarGroupCall(); -// } -// }else { -// createMyDefaultAvatarGroupCall(); -// } -// }else { -// createMyDefaultAvatarGroupCall(); -// } -// } - -// public void createMyDefaultAvatarGroupCall() { -// log("createMyDefaultAvatarGroupCall"); -// String myFullName = megaChatApi.getMyFullname(); -// String myFirstLetter = myFullName.charAt(0) + ""; -// myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); -// long userHandle = megaChatApi.getMyUserHandle(); -// -// Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); -// Canvas c = new Canvas(defaultAvatar); -// Paint p = new Paint(); -// p.setAntiAlias(true); -// p.setColor(Color.TRANSPARENT); -// -// String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); -// if (color != null) { -// p.setColor(Color.parseColor(color)); -// }else { -// p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); -// } -// -// int radius; -// if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { -// radius = defaultAvatar.getWidth() / 2; -// }else { -// radius = defaultAvatar.getHeight() / 2; -// } -// c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); -// bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); -// bigAvatarGroupCallInitialLetter.setText(myFirstLetter); -// bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); -// } - -// public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ -// log("setProfileContactAvatarGroupCall"); -// Bitmap bitmap = null; -// File avatar = null; -// String contactMail = megaChatApi.getContactEmail(userHandle); -// if (context.getExternalCacheDir() != null) { -// avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); -// } else { -// avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); -// } -// -// if (avatar.exists()) { -// if (avatar.length() > 0) { -// BitmapFactory.Options bOpts = new BitmapFactory.Options(); -// bOpts.inPurgeable = true; -// bOpts.inInputShareable = true; -// bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); -// bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); -// if (bitmap != null) { -// bigAvatarGroupCallImage.setVisibility(View.VISIBLE); -// bigAvatarGroupCallImage.setImageBitmap(bitmap); -// bigAvatarGroupCallInitialLetter.setVisibility(GONE); -// }else{ -// UserAvatarListener listener = new UserAvatarListener(context); -// avatar.delete(); -// if(!avatarRequested){ -// avatarRequested = true; -// if (context.getExternalCacheDir() != null){ -// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// else{ -// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// } -// -// createDefaultAvatarGroupCall(userHandle, fullName); -// } -// }else{ -// UserAvatarListener listener = new UserAvatarListener(context); -// -// if(!avatarRequested){ -// avatarRequested = true; -// if (context.getExternalCacheDir() != null){ -// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// else{ -// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// } -// -// createDefaultAvatarGroupCall(userHandle, fullName); -// } -// }else{ -// UserAvatarListener listener = new UserAvatarListener(context); -// -// if(!avatarRequested){ -// avatarRequested = true; -// if (context.getExternalCacheDir() != null){ -// megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// else{ -// megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); -// } -// } -// createDefaultAvatarGroupCall(userHandle, fullName); -// } -// } - -// public void createDefaultAvatarGroupCall(long userHandle, String fullName) { -// log("createDefaultAvatarGroupCall"); -// Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); -// Canvas c = new Canvas(defaultAvatar); -// Paint p = new Paint(); -// p.setAntiAlias(true); -// p.setColor(Color.TRANSPARENT); -// -// String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); -// if (color != null) { -// p.setColor(Color.parseColor(color)); -// }else{ -// p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); -// } -// -// int radius; -// if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { -// radius = defaultAvatar.getWidth() / 2; -// }else { -// radius = defaultAvatar.getHeight() / 2; -// } -// c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); -// bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); -// String contactFirstLetter = fullName.charAt(0) + ""; -// contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); -// bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); -// bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); -// } + int position = -1; + for(int i=0; i 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); + if (myBitmap != null) { + bigAvatarGroupCallImage.setImageBitmap(myBitmap); + bigAvatarGroupCallInitialLetter.setVisibility(GONE); + }else{ + createMyDefaultAvatarGroupCall(); + } + }else { + createMyDefaultAvatarGroupCall(); + } + }else { + createMyDefaultAvatarGroupCall(); + } + } + + public void createMyDefaultAvatarGroupCall() { + log("createMyDefaultAvatarGroupCall"); + String myFullName = megaChatApi.getMyFullname(); + String myFirstLetter = myFullName.charAt(0) + ""; + myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); + long userHandle = megaChatApi.getMyUserHandle(); + + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + p.setColor(Color.parseColor(color)); + }else { + p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); + bigAvatarGroupCallInitialLetter.setText(myFirstLetter); + bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + } + + public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ + log("setProfileContactAvatarGroupCall"); + Bitmap bitmap = null; + File avatar = null; + String contactMail = megaChatApi.getContactEmail(userHandle); + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } else { + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + + if (avatar.exists()) { + if (avatar.length() > 0) { + BitmapFactory.Options bOpts = new BitmapFactory.Options(); + bOpts.inPurgeable = true; + bOpts.inInputShareable = true; + bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); + bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); + if (bitmap != null) { + bigAvatarGroupCallImage.setVisibility(View.VISIBLE); + bigAvatarGroupCallImage.setImageBitmap(bitmap); + bigAvatarGroupCallInitialLetter.setVisibility(GONE); + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + avatar.delete(); + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatarGroupCall(userHandle, fullName); + } + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + + createDefaultAvatarGroupCall(userHandle, fullName); + } + }else{ + UserAvatarListener listener = new UserAvatarListener(context); + + if(!avatarRequested){ + avatarRequested = true; + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + } + createDefaultAvatarGroupCall(userHandle, fullName); + } + } + + public void createDefaultAvatarGroupCall(long userHandle, String fullName) { + log("createDefaultAvatarGroupCall"); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(defaultAvatar); + Paint p = new Paint(); + p.setAntiAlias(true); + p.setColor(Color.TRANSPARENT); + + String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); + if (color != null) { + p.setColor(Color.parseColor(color)); + }else{ + p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } + + int radius; + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); + String contactFirstLetter = fullName.charAt(0) + ""; + contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); + bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); + bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index c448888d36e..06efcf68986 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -113,7 +113,7 @@ private void changeDestRect(int dstWidth, int dstHeight) { } public void surfaceCreated(SurfaceHolder holder) { - log("**** surfaceCreated()"); + log("surfaceCreated()"); Canvas canvas = holder.lockCanvas(); if(canvas != null) { @@ -158,7 +158,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - log("****** surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); + log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; @@ -242,20 +242,20 @@ private static void log(String log) { } private void notifyStateToAll() { - log("**** notifyStateToAll()"); + log("notifyStateToAll()"); for(MegaSurfaceRendererGroupListener listener : listeners) notifyState(listener); } public void addListener(MegaSurfaceRendererGroupListener l) { - log("**** addListener()"); + log("addListener()"); listeners.add(l); notifyState(l); } private void notifyState(MegaSurfaceRendererGroupListener listener) { - log("**** notifyState()"); + log("notifyState()"); if(listener == null) return; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 3215e644ad1..8b0bfb5b800 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -90,7 +90,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress) { - log("**** GroupCallAdapter(peers: "+peers.size()+")"); + log("GroupCallAdapter(peers: "+peers.size()+")"); this.context = context; this.recyclerViewFragment = recyclerView; @@ -131,7 +131,7 @@ public void onClick(View v) { @Override public void resetSize(Long userHandle) { - log("**** resetSize"); + log("resetSize"); if(getItemCount()!=0){ for(InfoPeerGroupCall peer:peers){ if(peer.getHandle() == userHandle){ @@ -151,6 +151,7 @@ public void resetSize(Long userHandle) { public class ViewHolderGroupCall extends RecyclerView.ViewHolder{ RelativeLayout rlGeneral; + RelativeLayout greenLayer; RelativeLayout avatarMicroLayout; RelativeLayout avatarLayout; RoundedImageView avatarImage; @@ -220,6 +221,9 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.rlGeneral.setOnClickListener(null); } + holderGrid.greenLayer = (RelativeLayout) v.findViewById(R.id.green_layer); + holderGrid.greenLayer.setVisibility(GONE); + holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); holderGrid.surfaceViewLayout.removeAllViewsInLayout(); @@ -282,7 +286,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, int position){ - log("**** onBindViewHolderGrid()"); + log("onBindViewHolderGrid()"); InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -782,6 +786,39 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } + public void addLayer(int position, ViewHolderGroupCall holder){ + if(getItemCount()>=7){ + if(holder == null){ + holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + holder.greenLayer.setVisibility(View.VISIBLE); + } + } + + } + + public void removeLayer(int position, ViewHolderGroupCall holder){ + if(getItemCount()>=7){ + if(holder == null){ + holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + holder.greenLayer.setVisibility(View.GONE); + } + } + + } + + public ArrayList getPeers() { return peers; } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 02efbd2ae95..010cc6a962c 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -38,55 +38,55 @@ android:layout_centerInParent="true" android:nestedScrollingEnabled="false"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + android:fitsSystemWindows="true"> + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6cee5f937ba..791047bdba7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -162,4 +162,6 @@ #FFFAFAFA #FFE1E1E1 #FF707070 + #8000BFA5 + \ No newline at end of file From caca5506050e0573cd55210c10017c20834df221 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 25 Sep 2018 14:16:36 +0200 Subject: [PATCH 070/247] Feature#9775-Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 3afa40d66b1..c4c16c5a8e0 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2623,8 +2623,7 @@ public void createNewAdapter(boolean flag){ }else{ parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); - linearParticipants.setVisibility(View.VISIBLE); - + linearParticipants.setVisibility(View.GONE); //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { From 6cf4ee186158aee2f1d261d6c6b14ca5a6c08bd9 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 26 Sep 2018 11:51:32 +0200 Subject: [PATCH 071/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 165 +++++++++--------- .../chatAdapters/GroupCallAdapter.java | 2 +- .../res/drawable-hdpi/ic_mic_off_contact.png | Bin 0 -> 1174 bytes .../res/drawable-mdpi/ic_mic_off_contact.png | Bin 0 -> 802 bytes .../res/drawable-xhdpi/ic_mic_off_contact.png | Bin 0 -> 1464 bytes .../drawable-xxhdpi/ic_mic_off_contact.png | Bin 0 -> 2131 bytes .../drawable-xxxhdpi/ic_mic_off_contact.png | Bin 0 -> 2773 bytes .../main/res/layout/activity_calls_chat.xml | 6 + .../res/layout/item_camera_group_call.xml | 2 +- 9 files changed, 94 insertions(+), 81 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_mic_off_contact.png create mode 100644 app/src/main/res/drawable-mdpi/ic_mic_off_contact.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_mic_off_contact.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_mic_off_contact.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_mic_off_contact.png diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index c4c16c5a8e0..315f7483665 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -153,7 +153,9 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; - Long userSpeaking = null; + Long currentUserSpeaking = null; + Long lastUserHandleSpeaking = null; + RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -1409,7 +1411,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); peersOnCall.add(myPeer); - log("createNewAdapter() -> change my status to IN PROGRESS"); createNewAdapter(true); } }else{ @@ -1637,29 +1638,40 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if((peersOnCall != null)&&(peersOnCall.size() != 0)){ if(peersOnCall.size()>= 7){ - + lastUserHandleSpeaking = currentUserSpeaking; long userHandle = call.getPeerSessionStatusChange(); MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ boolean userHasAudio = userSession.getAudioDetected(); if(userHasAudio){ - userSpeaking = userHandle; + currentUserSpeaking = userHandle; + if(!currentUserSpeaking.equals(lastUserHandleSpeaking)){ + int positionLastSpeaking = -1; + int positionCurrentSpeaking = -1; + for(int i=0; i peersOnCall: "+peersOnCall.size()); if(flag){ - participantText.setText(peersOnCall.size()+"/"+(chat.getPeerCount()+1)); - linearParticipants.setVisibility(View.VISIBLE); + updateSubtitleToolbar(); //arrayList-> peersOnCall if(peersOnCall.size() < 7){ @@ -2576,7 +2601,7 @@ public void createNewAdapter(boolean flag){ } recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); +// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2591,26 +2616,26 @@ public void createNewAdapter(boolean flag){ parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); bigRecyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); -// bigRecyclerView.setAdapter(null); // adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ -// @Override-̣ +// @Override // public void onItemClick(int position) { - // do what ever you want to do with it // peerSelected = adapter.getNodeAt(position); -// if(peerSelected.getHandle().equals(megaChatApi.getMyUserHandle())){ -// updateLocalVideoStatus(); -// }else{ -// updateRemoteVideoStatus(peerSelected.getHandle()); +//// if(peerSelected.getHandle().equals(megaChatApi.getMyUserHandle())){ +//// updateLocalVideoStatus(); +//// }else{ +//// updateRemoteVideoStatus(peerSelected.getHandle()); +//// +//// } // -// } // // } // }); + + bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2691,6 +2716,10 @@ public void createNewAdapter(boolean flag){ public void createBigFragment(Long handle){ log("createBigFragment()"); + + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + //Remove current Camera if(bigCameraGroupCallFragment != null){ log("REMOVE bigCameraGroupCallFragment"); bigCameraGroupCallFragment.setVideoFrame(false); @@ -2699,36 +2728,25 @@ public void createBigFragment(Long handle){ bigCameraGroupCallFragment = null; } - int position = -1; - for(int i=0; iPx(P)S5VR9FekSYJq6XB5AQO{z(1GvjI~G!<+D&Z0=V4a7f#XdH?t*7iXxWiN#e zN*UtIpihH7=$k&&M@0}pWHJoa8C|A=bLc3AHnHX*(N>~~O>1ln&2HTJIj^MG+~i)f zsRvHJf9IUxnbu^a0PD z6*2-G>wgohFC1djEszUoK7ba^w=aL&3lQoH3~(>uZ2Z- z2R1inp7_??d>NHWB_A6bYpklOs*%g(I2_F0-X3eW+n+W!H`{i0c38fSm@y2Q6A3!5 z7k~Ffmg?(ov|4kBW!;NAp||mJ)6>(p2#i%GlgU|@{Rl7wOi@r!U@9*!SN8Swy^NO^ z+ZW6sc;;`0iBL>4f4Z9g;J*IyHO{ETV$sp27L2E+rk-YJXFmj^kGaaqN=tox{paXQ zB|$(4(<85^ClRQ+y1J{_h{E!=wzl@?a5x+TqmMaSk~cIo9DV^QpacQIh!Cju_V&N# z=H~3dU@$=8I@}L^%wfV{Fz5~!By^Gjf*m1H6%`f3M865`MY$!klyp8NAZQDLf~S&N zKgOacK*>NIW6z{2q5+*0C{Z_cM@NSVfJR40*Pg7b;F9dYRlr>d7$dBZ;giv5%xY?C zx`O$xuC7=7b^chChdMhu+rgY+p`3zom&=8^2DdgE20EPn{zQroQGlY+=q~K&bh`b@ zz-%^O5CUbjT7SWnu(7f64mx>xd1|zgNMsvrDiRg4?d|O#fypW?EJP8-==J){nVFey z=|&!=;gRs+O32U8&xEYWWZKu++S=O0I2DQV(DL%K3x>+d%5EqW3YpDj^HZBKJ3D(z z$WtDVCvu?kC0ei7yNWgyi2~H$-~R^;<>uyI85$a@M!%+}W|(f~n8V??DFg~~RE{{Q z*`tJZV4R8sU;B8)rKP3!t*xyF3Y(rnVD$NXFXrdxgY=?17Zw)0C`G2;y!N9iKy`rA z$5jd6_jJ$E!@J(y-JS3h#_xl^U_HbaEG;d)Kp}dhR;w>kF~&|zOxRjlTE_9H#>=8A z;I0Hb%y^*T!FZWuebInmgpP3Dz`(!{8ja>Nj6gvWpUBtGvwf&wBC`o_- zqNu1yJvcacySTU*Kc9}|AdWmv*>ORM${_&Z$nW<@dwYAI{YjLQlk-8TR5DtvHW%x3 zvYc+WdySUX?XTB16Xg`Y^5pDttz-{zid>88k?QEj7*|(U|43Ei7Pp30s;7>)Jl@!U z(NA_IB(nd%1Hz_!P34g(pJzBt%wl o%6!CVvx!gZUo=Ds{{<}m1L#aMiRMr+SO5S307*qoM6N<$f-G1&mH+?% literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_mic_off_contact.png b/app/src/main/res/drawable-mdpi/ic_mic_off_contact.png new file mode 100644 index 0000000000000000000000000000000000000000..e67d977647d20cfe3c1c39f769c444fa059a1b8c GIT binary patch literal 802 zcmV+-1Ks?IP)Px%+(|@1R7efAR#9k@Q562?pBv*h4e}wIm=ejH%P1*vTRo(144MXeSLWBqI6o&o&=Y^sA!R*c8_#O|KESgSQn1xKj)tN zefOMm@5LdCq7+1~6JdxP=cp2}_e138E|KE~$BkA6{}CKWm=j3VPt!C_S*_MHjYgvx ziA3^5_gm7Q=MbzZl$VWS@xuRj?Ig&xRcG8NdlT<*KgX7lar?3BSi zY(R;+27q5-L^s|}UR)6h1kfWY7!2N#N~JQt-yZ}a-(!J5V5w^%kHN_Rc22-)-6%6n zG-XPD35vzyQ`_6yai`Py0dUl6^;v_#FvWw}<>q7nWdYF7zpC-SBr9_k%X&N>|As3o zmC8?{P&kVAVVaWx1S1J#03;j4XIfni9tOlW$H@Q#k)$&d>msu&{6mGFkd@@Uk-#kK6q&o6WX+GCx1BHJi9e6~$3iqHyL`G!z gh#-8++J9UA0E@FpY$pH(*#H0l07*qoM6N<$f@3*&MF0Q* literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_mic_off_contact.png b/app/src/main/res/drawable-xhdpi/ic_mic_off_contact.png new file mode 100644 index 0000000000000000000000000000000000000000..fd0943db8b7105905ce313b9ed73e4a0a4d10247 GIT binary patch literal 1464 zcmV;p1xNacP)Px)a!Eu%RA>e5T74{JR}?qQnDLQXOMSFhc1vv4Dh-RYh(GF&S`is7V`M1PbH?7;=dGFh-ppuc zlAh$gd+x_O_x$d;=iYN)p1|ppJR!RYDG-wTX_ehRwV>G(NcSLV1n@xRb0LW#ITGnW z*&!Erya(x3N7DScu0qJ&o#BDY#!)E{0oePRH#fNk3z+L*_ibnahbD9co0FH9my1*? z4M|Q;4t8^M6VK1jueZ0iKit{bIkxp+xQ!Okgv$K#0z|H1*_VAo2e+O+I5;^u zIq#jWuCAMvm6f+85{U=9T`U%RWMpI{1qB6dkBp4`!EU#-O!Wbrc~^k|4?CwTVsX?& z)QwMlM533LUT$t~Kv7ZAheVP6{r#QU+1V*f$UmvDS)+Zz+^kG6C>#$8E5=mNGT5ch43!(zRHJ`rl^Bo$9 zw}6O3O-)S$%gf6Lq>OxXbMpWxhlht>C%m;e6#x#v1w=OuY#Ch8#vrZroa2}Tij+Y>=AZUZyvYpd8z#b5H zA>577p-CJ12>J?wBz5duuh)M`>c9#g6W*Gfmj%c`G)s_v|3+>R094FgKv)dGUO-p{ zz#c&G27r!85&}Ttx}3;4ar)MaCy~c=@)xb+7SqfXKKg5!u_@+a~o~bKU?}R#tu^!ZR~7 zZxFt-vvazprsg9qAf~6Mjgyd_ogGVLJOUy-*PJ(iv9YmVh;Rs%lR`s7C0HIB8d5+8d>ZM=wjBV$XOnVET7Qc@BRw=PeN{~^{Fc6WCxu;1|T z@ET;w^73*SIJo-Ti3v5{;P57QNhma2F)?S}?BIT|o|2Lhr&g=i^7HeD+2hg5ya5~^ zA3FsH2Ww&N8cYusxaRHctr{I2UB|&DCnq;sTU);m3k#Dd6pG!w!^0DEAP^+PMM}8% z|2{rGuBIu>Znr3yLm^8`OSdB;BHl(G_V45V{{8`(O!fno&m&6%!1H7=>v;PBc{wX9 zOTN9mZJ2eKLHvv&RVtO`Wo2b=xVWHU&k}8SI@_Cj$zluO5a58G;MAr5{{B~(L&7Eg zFW694wzjsOIXgQGe0_br!9qX6L8h>^C9DE~O8fZu2nPoTZ>6QBy>ITOg<%Aq#CVw5 z5(IB2X3jM72L}fya=HBB+}zy#kdP3k03cXGB6dGqW^r+GSEr_?e)?6Z)S7c_Q{SD~ zGO=v61=vC{J}M|Ec)hy1`h&>GNW&h#xVZSBs;cT6*k(7F{cT|hi=CLM2$P3+Mh{;g z9Y=x!2jsW1B4;+vWg>(p+)+7; z*xZR}1Jc^jv2o^6`L8xMjQ0jp@7WyyQ;M3Zx0@woNPx-4M{{nRCodHoOw)CM;O3?T@bltISMJ(Xh6zY3ZfMY2@Ru(8M?QqzVQB_LM1q6>6vDB31f4 z`|Hl1KcAhMnfZ>pySt~*`&O%U`ts$=4aLR9^~1x%xL0zx$O43Leu<7b5TMtE4_Pg} z*+yfT6iCU*$-Xr;HJ^rthQ21I#{&Zc5AyQzPPVkPjEl+7GLK|HG#t_pDUjB!TjvQK zEeQ$=dX>B{<~cMp)R&l;_;r7O|BRUYtnx_y6~k$TBZqE4kluZ5O-#&Z8&`XyRbWYh zX;rugocYnw(WmI3fCWW`S1m;<1rzd(n6jN|7^NlDq3pPwJfk5@A+84&6k)H!k>9Xxn&8*~PzwM`lu8!rL0 z$~$-N*c3hbG49HhE48+a;Bj?zb=$jl?-n{vZNFqd*dV!(qNAgu=nhRzPL32675z%b z(f-21!i$)Pj!Q^Lh^517`(**bM#+KH*Vp%m?odxpPuJMk*eo4K`!Nmk&~dOlFwkMO z{jvdJ!=yq=OH2Fy=FOYUq*IR{KmMEe7kl#aczSyJES6V|ctwD)K~f-DESCArn>T+) zAmOUnUZ=$5u~&wYbj5(MawU+IG~N;KG65tPQdLz|yCXWOqz-0)6_Q$=Vp%S8K+Xn96+q4eNi{&u0!dXs&HzbuKrcHaW;W^C+S(k1L8Pgv>E6+! zNAHm^Sxlnc2u&j-9-qWiBGocU$|xx*i2~CtXCu60$Bsoe!Q?$LPiBC&Z{MEFtMDQX z2-D<10t1@O48kkl7DPA#^)mtFkSS*C2?a^4J!$vu-M^8&8(j|V2RjkR#zdzn^)mxB zGcz+qH^$G;Z_!;h8A)Ow@i(|o&kG|8tdMwB#U}91v@M{}!we7@wm2safq{Yk{IFMc7ejd4DW`HIpCisAY_>GE)h%j8ge!W-;q|(yT zpZMhl1O#yE8Xq4Ynn;wyeQk@bTq z7Hq2+JP$zVuo6ErKwy0D;5Ec`-@bhbbQ~PpJcX0eI)IcW7ZP0_`VSvIyajYLUL~|i zYilbrK#~s*ZLQ#Wf`fzI;RLiyr_;HUBslDQ6doS_6)IX1=jG+)*45Qj5*8M=9)F$C z!bsBbTuo@5gzut47g{HcjEsBfovk^2nIB4nY?7T%9icdTs zJaOU#=a|N9HqYhe=AMKO7?qAB_%d9;sNYT32}efltl(g|%m86wM~)o11P|M2!MI(! zcI5*I&d)GRfeHAQ%YO!mkB?80JKbQkxX?Cktnc*c(|Es`nJ}ATq($%zehlYdZ;~)R zL4kM2#>SQk9r55<{h>pLlHk2TP~x^D9x2lee-#ljOkZ!P`xITbQa^J*+1c5_)z#IX z^RKkP^lM8`Pp`nKD7Mj3A;rbT`G8)V5L>>Oe5n1C#bgwl$7C{@L17QW(C3UI&_`jg zZHR+!`gU(`uc(#ou+?IzA02BgFc@OI+;p5J1BNjk(=p%N+?>mkCr_B){9rzU2uJ|2 z6V^fLBut*T4QOa+sNb_^PovllNf}9`9#&7)0HI!JZf@QQ3%M6=b714)*KEAKy}cDK zQnepHe%u6G70wZ~!C=tCPTq=&7-hL2sRn4FSMYK5>eZr*jEpQ27J9_ zGlz|CARaNZSSJb9Cnb)#4&qmS_Uu_BbhZzE>LWcoJOu9|A{0#X@$m`p_V)JI>-8R3 z4lE|u!kwZu6%`eKqK=WGllbkB8&-V;k%r-I*2>Dt0=S>Jm0oR=^rfE5Ig(T#L8Rlb zC9s}3bLKWI0e*+=hZ$V(s#UA(UfIL{WAa@YtWpy(&8i`Enr z6s!l6=^Jn{DwR&_=;&wxCI1&}f_q@WJwT@szatd4!$uJ46#abo@ZofQef@y1ukTb= zR@PQJ?bxwnKfq4?meFWj)cECyk;HT_Mt9IrekqnoIc<9B0b!@rgya-})P&?TfW$!h zHZt-9%qK;h3J`XDvFQezmi|w=yML4d2lFyJS(REboxiQEZMd$k?jk>q4omS9NW^@L zaPm5h-`tv-kZcNB)^(7SPRq%Q>m;03ICA8`!8)B9kQ}J|cbrZK@jIwAtO2q^Py?g^ zvO~a5vNnQ50J7T2vyzjoID$BTu(pzE2=sjf0pb7b(nOfRT?Et#j&rw1IPZ#!MJAnS zQAEMNy1`pooJ$6nutEjl;3WtPZZ(LYU;8(K|Ee6ERSUON{sA5S;>H5`W={YB002ov JPDHLkV1l#``Og3V literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mic_off_contact.png b/app/src/main/res/drawable-xxxhdpi/ic_mic_off_contact.png new file mode 100644 index 0000000000000000000000000000000000000000..59a018247d70d727ba51e3b1c84a4e242582406a GIT binary patch literal 2773 zcmV;`3M%!9P)Pxt0y#fugo2rw7{gNq+lCTLbxR%mW+Zc18O zTEeJNqrUX__YVes*0#2`md3`$AB&5NpC3GUu%xJ{sM%m#oi3iHqyOY|Y6l5}y}Udw z#>OxCM@`MY3tE~Q9VB=9a%N^`$eulW7EGT$J>A{iU7A2--fy*9`yM@dRJeBS+RG0f zJZNDiGLeufGlPdd1b#unwA`t_eraEag{3@g|M;w`tFuFG-aB^eNIrDv&|e}WBV#NU zi^DMsX)I&Mj-9Z4`SJ`eFR!|Sf`T8_>Y(NQTnLcBkM{W@iInxWxcl)S;lzm(nQPXp z`GbdthqtRB;2y6zbLRYN^5n^F7cN|=cJ+R}(yJyw4!)$gS`v2c+LgL`_3Guw&vw;L z%HG+dB`GN>0o_*hty{ND*%DNb0XGwqmQME%$WlV2t*^In*{fH(T^SQ*%$N~)_wL=l z`}p|yE9L8oyt})*WA^OXTOK}q_`#L?^hoQlPj#dO4Y&ldQn~y{Z23LR(-8S}SVz5R z1%JDD@1ChFBh_O7Rg|n9vU+IXrM_QYc{+D?OxVAFe^x?5!Zb!6*3FwYA5sFJ(xcmI z?CI&LnLmI2Oq>oFJII3a_V#YLc=2L2BX7e*s=FXbbL!)%uUFe0B_<}uNO{^G(Z$>u z416gqrJ=Oax$QAMJ)K3YZ4%vob0dH>=Rrb9NJuCPg=5E#-DSyHvg5~(7qR5w;o;;G zVyeKE0IHc<5|%DqdZe|r^_?80D_5@kAeSkfU%q_#E$do9K!DxYz)Gj5j5`6Oyc!a2 z-n{vK;lhQxyAyATx>HDKA0CkY)L9j$f+LJ%Dt?aPvPc6PS2gBXh8zJ zC5r6|gkaXJS&=Nc(!;|_J5-tG1T-`>Fs+f9GiS!Ll!jx~eR3_-f`s+!*FR>JnVg&) z#gbQ4RA}x+r#S&|3#YF{*@gJ{_-THAes<-pFVx+(1V0^>()iXVT&;w6+q;7aKzQ-RkKDZ1Lj7Cz_j^>5GS&23=YJ`D)^c`VXrncmiY2 zoH;X>b&X`y5@>r72IgXNuH`*2v)-5s3kz>mRaJE=>BLj6OA8={v3a5ftsslF;}I`H zQ!!0YdFRd@JFjTE_wC!aU55`Jes=Zh)xy!EM|Uq+upj}}Rb^9CQ~wjHrX^5|qLxK1 z0kgDj$p6T@ckk>B2hxRi(2anWmX=;@zO$m=pDM2eDs9Qg$Ve(HD=R^ykDM|?U0q$* z*|TRW;s5{A7JMl&4-#N~)#vBuYi|8WI%~cjAQePM8uVVje*M=86DGvk%BA0^{738o z`{(xU+sh=`P>wv-6NXamQ0~#K1(0$y=;1pKrOTEr`w9cH-E1gruFlTRPQy!D$GLOo zhWr$&X$eCCQO!NN5(*QVIbb2i7C={i(=sH?$=!07cC(UT zNEc)aDB1paQ+|k#F^$0%Rn^-_>5Z1`d7f{~w)*n^Z8!l`AC&a|uU)%VG;!j@o-t#_e91CZrL>NY!-WJ>5kR2Qv;)?K%kk~E zg5cob|6;Bv2(zKIe$2F%1|gykQ{i=8U0v@n4^?lQ&P>*k;e)U(FiOA4Qv&8_6s9Yp zv6vqn6B9Fyl@`{~OU&!kym;}VhDdZYpKpeNc~}r22b-rGq0uDhG94`k&`jrQTwZw8 zW5g3cAR0-6AmHc6*eDVN0XF@J5hMr#YzUyAdXpdskP+Yt37aD$f5W)lC6ORN0WL=^ zp|Y#<+ePJNXB2LCS}X_{1S%yG2>k4q&kwhBcmMSNAP339;iX~uBIdAGoDjDiJ^% zA1V;ZMO?LqGV%~X83B6o3H+ZHb7(qR9_TYNafss(0}z>ClY(3X=MW$>pDax>c4)jE buzBQv8@FkfFHS2200000NkvXXu0mjfG#@32 literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 010cc6a962c..c2d270949e9 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -48,6 +48,12 @@ android:layout_above="@+id/big_recycler_view_cameras" android:background="@android:color/transparent" android:visibility="gone"> + + android:src="@drawable/ic_mic_off_contact"/> From 57e51b20969588278d457fe0b4298963a5a09870 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 27 Sep 2018 12:43:09 +0200 Subject: [PATCH 072/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 315f7483665..19d95251ac4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -358,7 +358,6 @@ public void updateScreenStatusInProgress(){ } } } - if(changes){ createNewAdapter(true); } @@ -872,7 +871,6 @@ protected void onCreate(Bundle savedInstanceState) { if((peersOnCall != null)&&(peersOnCall.size() != 0)){ peersOnCall.clear(); } - if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } @@ -1416,7 +1414,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); peersOnCall.add(myPeer); -// createNewAdapter(true); +// createNewAdapter(true); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1512,8 +1510,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ //contact joined the group call log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); - boolean changes = false; - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ boolean peerContain = false; @@ -1524,14 +1520,11 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } } if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); peersOnCall.add(0, userPeer); - changes = true; - } - if(changes){ createNewAdapter(true); } + } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ @@ -1541,32 +1534,23 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); - boolean changes = false; if((peersOnCall != null)&&(peersOnCall.size() != 0)){ for(int i=0;i Date: Fri, 28 Sep 2018 14:31:22 +0200 Subject: [PATCH 073/247] Feature#9775-Group calls UI --- .../listeners/CustomItemClickListener.java | 7 - .../calls/BigCameraGroupCallFragment.java | 12 +- .../megachat/calls/ChatCallActivity.java | 442 +++++++++--------- .../chatAdapters/GroupCallAdapter.java | 186 +++----- .../main/res/layout/activity_calls_chat.xml | 21 +- 5 files changed, 297 insertions(+), 371 deletions(-) delete mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java deleted file mode 100644 index 9453ebda243..00000000000 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/CustomItemClickListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package mega.privacy.android.app.lollipop.listeners; - -import android.view.View; - -public interface CustomItemClickListener { - public void onItemClick(int position); -} \ No newline at end of file diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 6edca1b1df9..4825201697a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -21,10 +21,6 @@ import nz.mega.sdk.MegaChatApiJava; import nz.mega.sdk.MegaChatVideoListenerInterface; -/** - * Created by mega on 14/09/18. - */ - public class BigCameraGroupCallFragment extends Fragment implements MegaChatVideoListenerInterface { int width = 0; @@ -36,7 +32,7 @@ public class BigCameraGroupCallFragment extends Fragment implements MegaChatVide Long userHandle; public SurfaceView fullScreenSurfaceView; - MegaSurfaceRenderer renderer; + MegaSurfaceRendererGroup renderer; public static BigCameraGroupCallFragment newInstance(long chatId, long userHandle) { log("newInstance"); @@ -59,6 +55,8 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); + this.width = 0; + this.height = 0; super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -77,7 +75,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa fullScreenSurfaceView.setZOrderMediaOverlay(true); SurfaceHolder localSurfaceHolder = fullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - renderer = new MegaSurfaceRenderer(fullScreenSurfaceView); + renderer = new MegaSurfaceRendererGroup(fullScreenSurfaceView, userHandle); if(userHandle.equals(megaChatApi.getMyUserHandle())){ megaChatApi.addChatLocalVideoListener(chatId, this); @@ -120,6 +118,8 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } } + + if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 19d95251ac4..139581bdcc7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -74,7 +74,6 @@ import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.CustomizedGridCallRecyclerView; import mega.privacy.android.app.lollipop.LoginActivityLollipop; -import mega.privacy.android.app.lollipop.listeners.CustomItemClickListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; @@ -145,7 +144,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ActionBar aB; boolean avatarRequested = false; -// InfoPeerGroupCall peerSelected = null; ArrayList peersOnCall = new ArrayList<>(); ArrayList peersBeforeCall = new ArrayList<>(); @@ -153,9 +151,6 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque Timer timer = null; Timer ringerTimer = null; long milliseconds = 0; - Long currentUserSpeaking = null; - Long lastUserHandleSpeaking = null; - RelativeLayout smallElementsIndividualCallLayout; RelativeLayout bigElementsIndividualCallLayout; @@ -209,12 +204,12 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; //Big elements for group call (more than 6 users) - FrameLayout fragmentContainerBigCameraGroupCall; + FrameLayout fragmentBigCameraGroupCall; ViewGroup parentBigCameraGroupCall; private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; - RelativeLayout bigAvatarGroupCallLayout; - RoundedImageView bigAvatarGroupCallImage; - TextView bigAvatarGroupCallInitialLetter; + RelativeLayout avatarBigCameraGroupCallLayout; + RoundedImageView avatarBigCameraGroupCallImage; + TextView avatarBigCameraGroupCallInitialLetter; private SensorManager mSensorManager; private Sensor mSensor; @@ -249,13 +244,14 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque long startTime, timeInMilliseconds = 0; Handler customHandler = new Handler(); + InfoPeerGroupCall peerSelected = null; + boolean isManualMode = false; + @Override public boolean onCreateOptionsMenu(Menu menu) { log("onCreateOptionsMenu"); - MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_calls_chat, menu); - return super.onCreateOptionsMenu(menu); } @@ -266,27 +262,22 @@ public boolean onPrepareOptionsMenu(Menu menu) { remoteAudioIcon = menu.findItem(R.id.info_remote_audio); if(chat.isGroup()){ remoteAudioIcon.setVisible(false); - } - else{ + }else{ MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); - if(callChat!=null && userSession!=null){ if(userSession.hasAudio()){ log("Audio remote connected"); remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_up_white)); - } - else{ + }else{ log("Audio remote NOT connected"); remoteAudioIcon.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_volume_off_white)); } - } - else{ + }else{ log("callChat is Null"); } remoteAudioIcon.setVisible(true); remoteAudioIcon.setEnabled(false); } - return super.onPrepareOptionsMenu(menu); } @@ -377,8 +368,7 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null); peersOnCall.add(0, userPeer); changes = true; - }else{ - } + }else{} } } @@ -428,21 +418,17 @@ public void updateSubTitle(){ log("sessionStatus: "+sessionStatus); if(sessionStatus==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ startClock(); - } - else{ + }else{ // aB.setSubtitle(getString(R.string.chat_connecting)); subtitleToobar.setText(getString(R.string.chat_connecting)); - } - } - else{ + }else{ log("Error getting the session of the user"); // aB.setSubtitle(null); subtitleToobar.setText(null); } } - } - else{ + }else{ // aB.setSubtitle(null); subtitleToobar.setText(null); @@ -672,12 +658,16 @@ protected void onCreate(Bundle savedInstanceState) { } parentBigCameraGroupCall.setLayoutParams(paramsBigCameraGroupCall); - fragmentContainerBigCameraGroupCall = (FrameLayout) findViewById(R.id.fragment_container_big_camera_group_call); - fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); - bigAvatarGroupCallLayout = (RelativeLayout) findViewById(R.id.big_camera_group_call_avatar_rl); - bigAvatarGroupCallImage = (RoundedImageView) findViewById(R.id.big_camera_group_call_image); - bigAvatarGroupCallInitialLetter = (TextView) findViewById(R.id.big_camera_group_call_initial_letter); - bigAvatarGroupCallLayout.setVisibility(View.GONE); + + + fragmentBigCameraGroupCall = (FrameLayout) findViewById(R.id.fragment_big_camera_group_call); + fragmentBigCameraGroupCall.setVisibility(View.GONE); + + avatarBigCameraGroupCallLayout = (RelativeLayout) findViewById(R.id.rl_avatar_big_camera_group_call); + + avatarBigCameraGroupCallImage = (RoundedImageView) findViewById(R.id.image_big_camera_group_call); + avatarBigCameraGroupCallInitialLetter = (TextView) findViewById(R.id.initial_letter_big_camera_group_call); + avatarBigCameraGroupCallLayout.setVisibility(View.GONE); parentBigCameraGroupCall.setVisibility(View.GONE); //Local camera small @@ -803,7 +793,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("onCreate()-> Incoming group call"); + log("Incoming group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -847,10 +837,11 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("onCreate()-> InProgress"); + log("InProgress"); updateScreenStatusInProgress(); }else{ + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -862,18 +853,19 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("onCreate()-> Outgoing group call"); + log("Outgoing group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - peersOnCall.clear(); - } if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } + if((peersOnCall != null)&&(peersOnCall.size() != 0)){ + peersOnCall.clear(); + } + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); peersOnCall.add(myPeer); @@ -936,11 +928,10 @@ public void createDefaultAvatar(long userHandle, String fullName) { if (color != null) { log("The color to set the avatar is " + color); p.setColor(Color.parseColor(color)); - } else { + }else { log("Default color to the avatar"); p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); } - int radius; if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { radius = defaultAvatar.getWidth() / 2; @@ -976,7 +967,6 @@ public void setProfileContactAvatar(){ } else { avatar = new File(context.getCacheDir().getAbsolutePath(), chat.getPeerEmail(0) + ".jpg"); } - if (avatar.exists()) { if (avatar.length() > 0) { BitmapFactory.Options bOpts = new BitmapFactory.Options(); @@ -992,24 +982,20 @@ public void setProfileContactAvatar(){ contactImage.setImageBitmap(bitmap); contactInitialLetter.setVisibility(GONE); } - } - else{ + }else{ UserAvatarListener listener = new UserAvatarListener(this); avatar.delete(); if(!avatarRequested){ avatarRequested = true; if (context.getExternalCacheDir() != null){ megaApi.getUserAvatar(chat.getPeerEmail(0), context.getExternalCacheDir().getAbsolutePath() + "/" + chat.getPeerEmail(0) + ".jpg", listener); - } - else{ + }else{ megaApi.getUserAvatar(chat.getPeerEmail(0), context.getCacheDir().getAbsolutePath() + "/" + chat.getPeerEmail(0) + ".jpg", listener); } } - createDefaultAvatar(chat.getPeerHandle(0), chat.getPeerFullname(0)); } - } - else{ + }else{ UserAvatarListener listener = new UserAvatarListener(this); if(!avatarRequested){ @@ -1021,23 +1007,18 @@ public void setProfileContactAvatar(){ megaApi.getUserAvatar(chat.getPeerEmail(0), context.getCacheDir().getAbsolutePath() + "/" + chat.getPeerEmail(0) + ".jpg", listener); } } - createDefaultAvatar(chat.getPeerHandle(0), chat.getPeerFullname(0)); } - } - else{ + }else{ UserAvatarListener listener = new UserAvatarListener(this); - if(!avatarRequested){ avatarRequested = true; if (context.getExternalCacheDir() != null){ megaApi.getUserAvatar(chat.getPeerEmail(0), context.getExternalCacheDir().getAbsolutePath() + "/" + chat.getPeerEmail(0) + ".jpg", listener); - } - else{ + }else{ megaApi.getUserAvatar(chat.getPeerEmail(0), context.getCacheDir().getAbsolutePath() + "/" + chat.getPeerEmail(0) + ".jpg", listener); } } - createDefaultAvatar(chat.getPeerHandle(0), chat.getPeerFullname(0)); } } @@ -1049,7 +1030,6 @@ public void createMyDefaultAvatar() { String myFirstLetter=myFullName.charAt(0) + ""; myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); long userHandle = megaChatApi.getMyUserHandle(); - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels,outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); @@ -1061,19 +1041,16 @@ public void createMyDefaultAvatar() { if(color!=null){ log("The color to set the avatar is "+color); p.setColor(Color.parseColor(color)); - } - else{ + }else{ log("Default color to the avatar"); - p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); } - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) - radius = defaultAvatar.getWidth()/2; - else - radius = defaultAvatar.getHeight()/2; - + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); if(flagMyAvatar){ myImage.setImageBitmap(defaultAvatar); @@ -1088,7 +1065,6 @@ public void createMyDefaultAvatar() { contactInitialLetter.setTextColor(Color.WHITE); contactInitialLetter.setVisibility(View.VISIBLE); } - } public void setProfileMyAvatar() { @@ -1118,15 +1094,13 @@ public void setProfileMyAvatar() { contactImage.setImageBitmap(myBitmap); contactInitialLetter.setVisibility(GONE); } - } - else{ + }else{ createMyDefaultAvatar(); } - } - else { + }else { createMyDefaultAvatar(); } - } else { + }else { createMyDefaultAvatar(); } } @@ -1141,7 +1115,6 @@ public void run() { aB.hide(); } }).start(); - } else { aB.hide(); } @@ -1153,7 +1126,6 @@ protected void showActionBar(){ aB.show(); if(tB != null) { tB.animate().translationY(0).setDuration(800L).start(); - } } } @@ -1241,6 +1213,9 @@ public void onDestroy(){ customHandler.removeCallbacksAndMessages(null); } + peerSelected = null; + isManualMode = false; + peersOnCall.clear(); peersBeforeCall.clear(); stopAudioSignals(); @@ -1618,45 +1593,29 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if((peersOnCall != null)&&(peersOnCall.size() != 0)){ if(peersOnCall.size()>= 7){ - lastUserHandleSpeaking = currentUserSpeaking; - long userHandle = call.getPeerSessionStatusChange(); - MegaChatSession userSession = callChat.getMegaChatSession(userHandle); - if(userSession != null){ - boolean userHasAudio = userSession.getAudioDetected(); - if(userHasAudio){ - currentUserSpeaking = userHandle; - if(!currentUserSpeaking.equals(lastUserHandleSpeaking)){ - int positionLastSpeaking = -1; - int positionCurrentSpeaking = -1; - for(int i=0; i= 7) && (peerSelected != null)){ + if(peerSelected.getHandle().equals(userHandle)){ + createBigFragment(peerSelected.getHandle()); } } break; @@ -2228,9 +2187,9 @@ public void updateRemoteVideoStatus(long userHandle){ peersOnCall.get(i).setVideoOn(false); adapter.notifyItemChanged(i); updateSubtitleToolbar(); - if(currentUserSpeaking!=null){ - if(currentUserSpeaking.equals(userHandle)){ - createBigAvatar(currentUserSpeaking, peersOnCall.get(i).getName()); + if((peersOnCall.size() >= 7) && (peerSelected != null)){ + if(peerSelected.getHandle().equals(userHandle)){ + createBigAvatar(peerSelected.getHandle(),peerSelected.getName()); } } break; @@ -2324,9 +2283,14 @@ public void updateRemoteAudioStatus(long userHandle){ for(int i=0;i= 7) && (peerSelected != null)){ + if(peerSelected.getHandle().equals(userHandle)){ + //Disable audio icon GONE + + } + } break; } } @@ -2338,9 +2302,13 @@ public void updateRemoteAudioStatus(long userHandle){ for(int i=0;i= 7) && (peerSelected != null)){ + if(peerSelected.getHandle().equals(userHandle)){ + //Disable audio icon VISIBLE + } + } break; } } @@ -2420,6 +2388,30 @@ public void remoteCameraClick(){ } } + public void itemClicked(int position, InfoPeerGroupCall peer){ + log("itemClicked-> "+peer.getName()+", userSelected: "+peerSelected.getName()); + if(peerSelected.getHandle().equals(peer.getHandle())){ + //I touched the same user that is now in big fragment: + if(isManualMode){ + isManualMode = false; + }else{ + isManualMode = true; + } + peerSelected = peer; + updateUserSelected(true); + + }else{ + if(!peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + if(!isManualMode) { + isManualMode = true; + } + peerSelected = peer; + updateUserSelected(true); + } + } + + } + @Override public void onAccuracyChanged(Sensor sensor, int accuracy) {} @@ -2546,10 +2538,11 @@ public void createNewAdapter(boolean flag){ log("createNewAdapter() ----> peersOnCall: "+peersOnCall.size()); if(flag){ + //Call IN PROGRESS updateSubtitleToolbar(); //arrayList-> peersOnCall if(peersOnCall.size() < 7){ - + //1-6 peers bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(null); @@ -2581,7 +2574,6 @@ public void createNewAdapter(boolean flag){ } recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag,null); adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); recyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2591,32 +2583,15 @@ public void createNewAdapter(boolean flag){ } }else{ + + //7 + peers recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); - -// adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, new CustomItemClickListener(){ -// @Override -// public void onItemClick(int position) { -// log("peerSelected: "+adapter.getNodeAt(position)); -//// peerSelected = adapter.getNodeAt(position); -//// if(peerSelected.getHandle().equals(megaChatApi.getMyUserHandle())){ -//// updateLocalVideoStatus(); -//// }else{ -//// updateRemoteVideoStatus(peerSelected.getHandle()); -//// -//// } -// -// -// } -// }); - - bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2624,17 +2599,22 @@ public void createNewAdapter(boolean flag){ }else{ bigRecyclerView.setVisibility(View.VISIBLE); } + updateUserSelected(flag); + } }else{ - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); + //Call INCOMING + linearParticipants.setVisibility(View.GONE); //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { + //1-6 peers bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); if(peersBeforeCall.size() < 4){ ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); @@ -2663,7 +2643,6 @@ public void createNewAdapter(boolean flag){ } recyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, null); adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapter); @@ -2674,14 +2653,14 @@ public void createNewAdapter(boolean flag){ } }else{ - + //7 + peers + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); bigRecyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, null); adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); if (adapter.getItemCount() == 0){ @@ -2689,10 +2668,74 @@ public void createNewAdapter(boolean flag){ }else{ bigRecyclerView.setVisibility(View.VISIBLE); } + updateUserSelected(flag); } - } + } + + public void updateUserSelected(boolean flag){ + log("updateUserSelected()"); + //Se llama a est función si: createNewAdapter, se detecta que toca o se detecta que habla alguien. + if(flag){ + //Call IN PROGRESS + if(peerSelected == null){ + //First case: + if(!isManualMode){ + if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ + + peerSelected = peersOnCall.get((peersOnCall.size())-2); + if(peerSelected.isVideoOn()){ + createBigFragment(peerSelected.getHandle()); + }else{ + createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); + } + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + }else{ + //Disable audio icon VISIBLE + } + } + } + }else{ + //Rest of cases: + if(peerSelected.isVideoOn()){ + createBigFragment(peerSelected.getHandle()); + }else{ + createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); + } + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + }else{ + //Disable audio icon VISIBLE + } + } + + }else{ + //Call INCOMING + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + if((peerSelected == null)){ + //First time: + //Remove Camera element, because with incoming, avatar is the only showed + if (bigCameraGroupCallFragment != null) { + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + fragmentBigCameraGroupCall.setVisibility(View.GONE); + + //Create Avatar, get the last peer of peersBeforeCall + if((peersBeforeCall!=null)&& (peersBeforeCall.size()!= 0)){ + avatarBigCameraGroupCallLayout.setVisibility(View.VISIBLE); + InfoPeerGroupCall peerTemp = peersBeforeCall.get((peersBeforeCall.size())-1); + setProfileContactAvatarGroupCall(peerTemp.getHandle(), peerTemp.getName()); + }else{ + avatarBigCameraGroupCallLayout.setVisibility(View.GONE); + } + } + } } public void createBigFragment(Long handle){ @@ -2700,7 +2743,7 @@ public void createBigFragment(Long handle){ parentBigCameraGroupCall.setVisibility(View.VISIBLE); - //Remove current Camera + //Remove big Camera if(bigCameraGroupCallFragment != null){ log("REMOVE bigCameraGroupCallFragment"); bigCameraGroupCallFragment.setVideoFrame(false); @@ -2709,107 +2752,40 @@ public void createBigFragment(Long handle){ bigCameraGroupCallFragment = null; } - //Create Camera + //Create big Camera if(bigCameraGroupCallFragment == null){ - log("createBigFragment()- CREATE bigCameraGroupCallFragment"); + log("CREATE bigCameraGroupCallFragment"); bigCameraGroupCallFragment = BigCameraGroupCallFragment.newInstance(chatId, handle); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.replace(R.id.fragment_container_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); + ftFS.replace(R.id.fragment_big_camera_group_call, bigCameraGroupCallFragment, "bigCameraGroupCallFragment"); ftFS.commitNowAllowingStateLoss(); } - fragmentContainerBigCameraGroupCall.setVisibility(View.VISIBLE); - - //Avatar - bigAvatarGroupCallLayout.setVisibility(View.GONE); + fragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + //Remove Avatar + avatarBigCameraGroupCallLayout.setVisibility(View.GONE); } public void createBigAvatar(Long handle, String fullName){ log("createBigAvatar()"); - //Remove current Camera + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + //Create Avatar + avatarBigCameraGroupCallLayout.setVisibility(View.VISIBLE); + if(!handle.equals(megaChatApi.getMyUserHandle())){ + setProfileContactAvatarGroupCall(handle,fullName); + } + + //Remove big Camera if (bigCameraGroupCallFragment != null) { - log("removeBigFragment()- REMOVE bigCameraGroupCallFragment"); + log("REMOVE bigCameraGroupCallFragment"); bigCameraGroupCallFragment.setVideoFrame(false); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; } - fragmentContainerBigCameraGroupCall.setVisibility(View.GONE); - - //Avatar - if(handle.equals(megaChatApi.getMyUserHandle())){ - setProfileMyAvatarGroupCall(); - }else{ - setProfileContactAvatarGroupCall(handle,fullName); - } - bigAvatarGroupCallLayout.setVisibility(View.VISIBLE); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - } - - public void setProfileMyAvatarGroupCall() { - log("setProfileMyAvatarGroupCall"); - Bitmap myBitmap = null; - File avatar = null; - if (context != null) { - log("context is not null"); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), megaChatApi.getMyEmail() + ".jpg"); - } - } - if (avatar.exists()) { - if (avatar.length() > 0) { - BitmapFactory.Options bOpts = new BitmapFactory.Options(); - bOpts.inPurgeable = true; - bOpts.inInputShareable = true; - myBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - myBitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, myBitmap, 3); - if (myBitmap != null) { - bigAvatarGroupCallImage.setImageBitmap(myBitmap); - bigAvatarGroupCallInitialLetter.setVisibility(GONE); - }else{ - createMyDefaultAvatarGroupCall(); - } - }else { - createMyDefaultAvatarGroupCall(); - } - }else { - createMyDefaultAvatarGroupCall(); - } - } - - public void createMyDefaultAvatarGroupCall() { - log("createMyDefaultAvatarGroupCall"); - String myFullName = megaChatApi.getMyFullname(); - String myFirstLetter = myFullName.charAt(0) + ""; - myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); - long userHandle = megaChatApi.getMyUserHandle(); - - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(defaultAvatar); - Paint p = new Paint(); - p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); - - String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if (color != null) { - p.setColor(Color.parseColor(color)); - }else { - p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); - } - - int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { - radius = defaultAvatar.getWidth() / 2; - }else { - radius = defaultAvatar.getHeight() / 2; - } - c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); - bigAvatarGroupCallInitialLetter.setText(myFirstLetter); - bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + fragmentBigCameraGroupCall.setVisibility(View.GONE); } public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ @@ -2831,9 +2807,9 @@ public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); if (bitmap != null) { - bigAvatarGroupCallImage.setVisibility(View.VISIBLE); - bigAvatarGroupCallImage.setImageBitmap(bitmap); - bigAvatarGroupCallInitialLetter.setVisibility(GONE); + avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE); + avatarBigCameraGroupCallImage.setImageBitmap(bitmap); + avatarBigCameraGroupCallInitialLetter.setVisibility(GONE); }else{ UserAvatarListener listener = new UserAvatarListener(context); avatar.delete(); @@ -2902,11 +2878,11 @@ public void createDefaultAvatarGroupCall(long userHandle, String fullName) { radius = defaultAvatar.getHeight() / 2; } c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); - bigAvatarGroupCallImage.setImageBitmap(defaultAvatar); + avatarBigCameraGroupCallImage.setImageBitmap(defaultAvatar); String contactFirstLetter = fullName.charAt(0) + ""; contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); - bigAvatarGroupCallInitialLetter.setText(contactFirstLetter); - bigAvatarGroupCallInitialLetter.setVisibility(View.VISIBLE); + avatarBigCameraGroupCallInitialLetter.setText(contactFirstLetter); + avatarBigCameraGroupCallInitialLetter.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 83a15e97ac0..3b53cf43436 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -8,27 +8,21 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; -import android.graphics.Point; -import android.graphics.Rect; -import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Display; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import java.io.File; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Locale; @@ -36,17 +30,11 @@ import mega.privacy.android.app.R; import mega.privacy.android.app.components.CustomizedGridRecyclerView; import mega.privacy.android.app.components.RoundedImageView; -import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; -import mega.privacy.android.app.lollipop.adapters.FileStorageLollipopAdapter; -import mega.privacy.android.app.lollipop.listeners.CustomItemClickListener; import mega.privacy.android.app.lollipop.listeners.GroupCallListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; import mega.privacy.android.app.lollipop.megachat.calls.InfoPeerGroupCall; -import mega.privacy.android.app.lollipop.megachat.calls.LocalCameraCallFullScreenFragment; import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRendererGroup; -import mega.privacy.android.app.lollipop.megachat.calls.RemoteCameraCallFullScreenFragment; -import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiAndroid; @@ -60,9 +48,7 @@ import static mega.privacy.android.app.utils.Util.deleteFolderAndSubfolders; import static mega.privacy.android.app.utils.Util.percScreenLogin; -public class GroupCallAdapter extends RecyclerView.Adapter implements View.OnClickListener, MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { - -//public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { +public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { Context context; MegaApiAndroid megaApi; @@ -74,7 +60,6 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, CustomItemClickListener listener) { public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress) { log("GroupCallAdapter(peers: "+peers.size()+")"); @@ -96,9 +77,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList=7){ - if(holder == null){ - holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); - } - if(holder!=null){ - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; - } - holder.greenLayer.setVisibility(View.VISIBLE); - } - } - - } +// public void addLayer(int position, ViewHolderGroupCall holder){ +// if(getItemCount()>=7){ +// if(holder == null){ +// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); +// } +// if(holder!=null){ +// InfoPeerGroupCall peer = getNodeAt(position); +// if (peer == null){ +// return; +// } +// holder.greenLayer.setVisibility(View.VISIBLE); +// } +// } +// +// } +// +// public void removeLayer(int position, ViewHolderGroupCall holder){ +// if(getItemCount()>=7){ +// if(holder == null){ +// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); +// } +// if(holder!=null){ +// InfoPeerGroupCall peer = getNodeAt(position); +// if (peer == null){ +// return; +// } +// holder.greenLayer.setVisibility(View.GONE); +// } +// } +// } - public void removeLayer(int position, ViewHolderGroupCall holder){ - if(getItemCount()>=7){ - if(holder == null){ - holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); - } - if(holder!=null){ - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; + @Override + public void resetSize(Long userHandle) { + log("resetSize"); + if(getItemCount()!=0){ + for(InfoPeerGroupCall peer:peers){ + if(peer.getHandle() == userHandle){ + if(peer.getListener()!=null){ + if(peer.getListener().getWidth()!=0){ + peer.getListener().setWidth(0); + } + if(peer.getListener().getHeight()!=0){ + peer.getListener().setHeight(0); + } + } } - holder.greenLayer.setVisibility(View.GONE); } } - } - public ArrayList getPeers() { return peers; } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index c2d270949e9..b9f46c50943 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -27,6 +27,7 @@ android:layout_height="match_parent" android:background="@color/black"> + + + + + android:layout_alignParentTop="true" + android:visibility="gone"/> + android:background="@android:color/holo_blue_light"> + - + Date: Mon, 1 Oct 2018 11:28:53 +0200 Subject: [PATCH 074/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 59 ++++++++++++++----- .../chatAdapters/GroupCallAdapter.java | 54 ++++++++--------- .../main/res/layout/activity_calls_chat.xml | 2 +- 3 files changed, 68 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 139581bdcc7..f4a3fb865fe 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1608,6 +1608,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if(position != -1){ peerSelected = adapter.getNodeAt(position); + log("audio detected: "+peerSelected.getName()); updateUserSelected(true); } } @@ -2388,14 +2389,16 @@ public void remoteCameraClick(){ } } - public void itemClicked(int position, InfoPeerGroupCall peer){ + public void itemClicked(InfoPeerGroupCall peer){ log("itemClicked-> "+peer.getName()+", userSelected: "+peerSelected.getName()); if(peerSelected.getHandle().equals(peer.getHandle())){ //I touched the same user that is now in big fragment: if(isManualMode){ isManualMode = false; + log("manual mode - False"); }else{ isManualMode = true; + log("manual mode - True"); } peerSelected = peer; updateUserSelected(true); @@ -2404,12 +2407,12 @@ public void itemClicked(int position, InfoPeerGroupCall peer){ if(!peer.getHandle().equals(megaChatApi.getMyUserHandle())){ if(!isManualMode) { isManualMode = true; + log("manual mode - True"); } peerSelected = peer; updateUserSelected(true); } } - } @Override @@ -2675,15 +2678,22 @@ public void createNewAdapter(boolean flag){ public void updateUserSelected(boolean flag){ log("updateUserSelected()"); - //Se llama a est función si: createNewAdapter, se detecta que toca o se detecta que habla alguien. if(flag){ + + int position=-1; //Call IN PROGRESS if(peerSelected == null){ + //First case: if(!isManualMode){ if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ + log("updateUserSelected() - call IN PROGRESS - first case"); + position = peersOnCall.size()-2; + peerSelected = peersOnCall.get(position); + if((adapter != null)&&(position !=-1)){ + adapter.addLayer(position, null); + } - peerSelected = peersOnCall.get((peersOnCall.size())-2); if(peerSelected.isVideoOn()){ createBigFragment(peerSelected.getHandle()); }else{ @@ -2697,26 +2707,45 @@ public void updateUserSelected(boolean flag){ } } }else{ - //Rest of cases: - if(peerSelected.isVideoOn()){ - createBigFragment(peerSelected.getHandle()); - }else{ - createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); - } - if(peerSelected.isAudioOn()){ - //Disable audio icon GONE - }else{ - //Disable audio icon VISIBLE + + if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ + log("updateUserSelected() - call IN PROGRESS - rest of cases"); + + for(int i=0; i=7){ -// if(holder == null){ -// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); -// } -// if(holder!=null){ -// InfoPeerGroupCall peer = getNodeAt(position); -// if (peer == null){ -// return; -// } -// holder.greenLayer.setVisibility(View.VISIBLE); -// } -// } -// -// } -// -// public void removeLayer(int position, ViewHolderGroupCall holder){ -// if(getItemCount()>=7){ -// if(holder == null){ -// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); -// } -// if(holder!=null){ -// InfoPeerGroupCall peer = getNodeAt(position); -// if (peer == null){ -// return; -// } -// holder.greenLayer.setVisibility(View.GONE); -// } -// } -// } + public void addLayer(int position, ViewHolderGroupCall holder){ + log(" addLayer()"); + //Remove green layer for the rest of users: + for(int i=0; i + android:background="@android:color/transparent"> Date: Mon, 1 Oct 2018 12:40:07 +0200 Subject: [PATCH 075/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 96 ++++++++++++++----- app/src/main/jni/megachat/sdk | 2 +- .../main/res/layout/activity_calls_chat.xml | 33 +++++-- .../res/layout/item_camera_group_call.xml | 3 +- 4 files changed, 98 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f4a3fb865fe..edc0d36b393 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -205,9 +205,11 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque //Big elements for group call (more than 6 users) FrameLayout fragmentBigCameraGroupCall; + ImageView microFragmentBigCameraGroupCall; ViewGroup parentBigCameraGroupCall; private BigCameraGroupCallFragment bigCameraGroupCallFragment = null; RelativeLayout avatarBigCameraGroupCallLayout; + ImageView avatarBigCameraGroupCallMicro; RoundedImageView avatarBigCameraGroupCallImage; TextView avatarBigCameraGroupCallInitialLetter; @@ -656,17 +658,17 @@ protected void onCreate(Bundle savedInstanceState) { paramsBigCameraGroupCall.width = (int)heightScreenPX; paramsBigCameraGroupCall.height = (int)heightScreenPX; } - parentBigCameraGroupCall.setLayoutParams(paramsBigCameraGroupCall); - - fragmentBigCameraGroupCall = (FrameLayout) findViewById(R.id.fragment_big_camera_group_call); fragmentBigCameraGroupCall.setVisibility(View.GONE); + microFragmentBigCameraGroupCall = (ImageView) findViewById(R.id.micro_fragment_big_camera_group_call); + microFragmentBigCameraGroupCall.setVisibility(View.GONE); avatarBigCameraGroupCallLayout = (RelativeLayout) findViewById(R.id.rl_avatar_big_camera_group_call); - + avatarBigCameraGroupCallMicro = (ImageView) findViewById(R.id.micro_avatar_big_camera_group_call); avatarBigCameraGroupCallImage = (RoundedImageView) findViewById(R.id.image_big_camera_group_call); avatarBigCameraGroupCallInitialLetter = (TextView) findViewById(R.id.initial_letter_big_camera_group_call); + avatarBigCameraGroupCallMicro.setVisibility(GONE); avatarBigCameraGroupCallLayout.setVisibility(View.GONE); parentBigCameraGroupCall.setVisibility(View.GONE); @@ -841,7 +843,6 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume == 0) { toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); @@ -2172,6 +2173,15 @@ public void updateRemoteVideoStatus(long userHandle){ if((peersOnCall.size() >= 7) && (peerSelected != null)){ if(peerSelected.getHandle().equals(userHandle)){ createBigFragment(peerSelected.getHandle()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + } } } break; @@ -2191,6 +2201,15 @@ public void updateRemoteVideoStatus(long userHandle){ if((peersOnCall.size() >= 7) && (peerSelected != null)){ if(peerSelected.getHandle().equals(userHandle)){ createBigAvatar(peerSelected.getHandle(),peerSelected.getName()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } break; @@ -2288,8 +2307,8 @@ public void updateRemoteAudioStatus(long userHandle){ adapter.changesInAudio(i,null); if((peersOnCall.size() >= 7) && (peerSelected != null)){ if(peerSelected.getHandle().equals(userHandle)){ - //Disable audio icon GONE - + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); } } break; @@ -2307,7 +2326,13 @@ public void updateRemoteAudioStatus(long userHandle){ adapter.changesInAudio(i,null); if((peersOnCall.size() >= 7) && (peerSelected != null)){ if(peerSelected.getHandle().equals(userHandle)){ - //Disable audio icon VISIBLE + if(peerSelected.isVideoOn()){ + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + }else{ + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } break; @@ -2695,14 +2720,29 @@ public void updateUserSelected(boolean flag){ } if(peerSelected.isVideoOn()){ + //Video ON createBigFragment(peerSelected.getHandle()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + } }else{ + //Video OFF createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); - } - if(peerSelected.isAudioOn()){ - //Disable audio icon GONE - }else{ - //Disable audio icon VISIBLE + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } } @@ -2721,24 +2761,34 @@ public void updateUserSelected(boolean flag){ } //Rest of cases: if(peerSelected.isVideoOn()){ + //Video ON createBigFragment(peerSelected.getHandle()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + } }else{ + //Video OFF createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); - } - if(peerSelected.isAudioOn()){ - //Disable audio icon GONE - }else{ - //Disable audio icon VISIBLE + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } - - - - } }else{ - //Call INCOMING parentBigCameraGroupCall.setVisibility(View.VISIBLE); diff --git a/app/src/main/jni/megachat/sdk b/app/src/main/jni/megachat/sdk index 0a3dfded442..cfd50661a24 160000 --- a/app/src/main/jni/megachat/sdk +++ b/app/src/main/jni/megachat/sdk @@ -1 +1 @@ -Subproject commit 0a3dfded442bf1abb38bef3ff88c410d9d60a5cf +Subproject commit cfd50661a24f79dd145295115ebd4fbd4186563d diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index b05e14b2988..0a4ffe065d5 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -51,16 +51,6 @@ android:background="@android:color/transparent" android:visibility="gone"> - - - + + + + + diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 0a411ba8a56..353829bb574 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -5,7 +5,6 @@ android:layout_height="wrap_content" android:background="@color/black"> - - + Date: Tue, 2 Oct 2018 16:56:12 +0200 Subject: [PATCH 076/247] Task #10613 - Add suppport for messages type TYPE_CALL_STARTED --- .../chatAdapters/MegaChatLollipopAdapter.java | 269 +++++++++--------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 142 insertions(+), 128 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index 0858966d589..e7b2fe6bdce 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -1367,9 +1367,10 @@ public void onBindViewHolderMessage(RecyclerView.ViewHolder holder, int position bindRevokeNodeMessage((ViewHolderMessageChat) holder, androidMessage, position); break; } - case MegaChatMessage.TYPE_CALL_ENDED: { - log("MegaChatMessage.TYPE_CALL_ENDED"); - bindCallEndedMessage((ViewHolderMessageChat) holder, androidMessage, position); + case MegaChatMessage.TYPE_CALL_ENDED: + case MegaChatMessage.TYPE_CALL_STARTED: { + log("MegaChatMessage.TYPE_CALL_ENDED or TYPE_CALL_STARTED"); + bindCallMessage((ViewHolderMessageChat) holder, androidMessage, position); break; } case MegaChatMessage.TYPE_INVALID: { @@ -1471,8 +1472,8 @@ public boolean isKnownMessage(int messageType){ } } - public void bindCallEndedMessage(ViewHolderMessageChat holder, AndroidMegaChatMessage androidMessage, int position) { - log("bindCallEndedMessage"); + public void bindCallMessage(ViewHolderMessageChat holder, AndroidMegaChatMessage androidMessage, int position) { + log("bindCallMessage"); ((ViewHolderMessageChat) holder).layoutAvatarMessages.setVisibility(View.GONE); MegaChatMessage message = androidMessage.getMessage(); @@ -1519,93 +1520,99 @@ public void bindCallEndedMessage(ViewHolderMessageChat holder, AndroidMegaChatMe String textToShow = ""; - switch(message.getTermCode()){ - case MegaChatMessage.END_CALL_REASON_ENDED:{ + if(message.getType()==MegaChatMessage.TYPE_CALL_STARTED){ + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_started)); + textToShow = context.getResources().getString(R.string.call_started_messages); + } + else{ + switch(message.getTermCode()){ + case MegaChatMessage.END_CALL_REASON_ENDED:{ - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_calling)); + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_calling)); - int minutes = (message.getDuration() % 3600) / 60; - int seconds = message.getDuration() % 60; + int minutes = (message.getDuration() % 3600) / 60; + int seconds = message.getDuration() % 60; - if(minutes == 0){ + if(minutes == 0){ textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_just_seconds, seconds, seconds); - } - else{ - if(seconds == 0){ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_minutes, minutes, minutes); - } - else if (seconds == 1){ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_one_second, minutes, minutes, seconds); } else{ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_more_seconds, minutes, minutes, seconds); + if(seconds == 0){ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_minutes, minutes, minutes); + } + else if (seconds == 1){ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_one_second, minutes, minutes, seconds); + } + else{ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_more_seconds, minutes, minutes, seconds); + } } - } - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - textToShow = textToShow.replace("[B]", ""); - textToShow = textToShow.replace("[/B]", ""); - textToShow = textToShow.replace("[C]", ""); - textToShow = textToShow.replace("[/C]", ""); - } catch (Exception e) { + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + textToShow = textToShow.replace("[B]", ""); + textToShow = textToShow.replace("[/B]", ""); + textToShow = textToShow.replace("[C]", ""); + textToShow = textToShow.replace("[/C]", ""); + } catch (Exception e) { + } + + break; } + case MegaChatMessage.END_CALL_REASON_REJECTED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_REJECTED:{ + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_rejected)); - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_rejected)); + textToShow = String.format(context.getString(R.string.call_rejected_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); - textToShow = String.format(context.getString(R.string.call_rejected_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_NO_ANSWER:{ - break; - } - case MegaChatMessage.END_CALL_REASON_NO_ANSWER:{ + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); + textToShow = String.format(context.getString(R.string.call_not_answered_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_not_answered_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_FAILED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_FAILED:{ + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); + textToShow = String.format(context.getString(R.string.call_failed_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_failed_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_CANCELLED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_CANCELLED:{ + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_cancelled)); - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_cancelled)); + textToShow = String.format(context.getString(R.string.call_cancelled_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_cancelled_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } - - break; } } @@ -1759,92 +1766,98 @@ else if (seconds == 1){ String textToShow = ""; - switch(message.getTermCode()){ - case MegaChatMessage.END_CALL_REASON_ENDED:{ + if(message.getType()==MegaChatMessage.TYPE_CALL_STARTED){ + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_started)); + textToShow = context.getResources().getString(R.string.call_started_messages); + } + else{ + switch(message.getTermCode()){ + case MegaChatMessage.END_CALL_REASON_ENDED:{ - ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_started)); + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_started)); - int minutes = (message.getDuration() % 3600) / 60; - int seconds = message.getDuration() % 60; + int minutes = (message.getDuration() % 3600) / 60; + int seconds = message.getDuration() % 60; - if(minutes == 0){ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_just_seconds, seconds, seconds); - } - else{ - if(seconds == 0){ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_minutes, minutes, minutes); - } - else if (seconds == 1){ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_one_second, minutes, minutes, seconds); + if(minutes == 0){ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_just_seconds, seconds, seconds); } else{ - textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_more_seconds, minutes, minutes, seconds); + if(seconds == 0){ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_minutes, minutes, minutes); + } + else if (seconds == 1){ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_one_second, minutes, minutes, seconds); + } + else{ + textToShow = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_with_more_seconds, minutes, minutes, seconds); + } } - } - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - textToShow = textToShow.replace("[B]", ""); - textToShow = textToShow.replace("[/B]", ""); - textToShow = textToShow.replace("[C]", ""); - textToShow = textToShow.replace("[/C]", ""); - } catch (Exception e) { + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + textToShow = textToShow.replace("[B]", ""); + textToShow = textToShow.replace("[/B]", ""); + textToShow = textToShow.replace("[C]", ""); + textToShow = textToShow.replace("[/C]", ""); + } catch (Exception e) { + } + + break; } + case MegaChatMessage.END_CALL_REASON_REJECTED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_REJECTED:{ + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_rejected)); - ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_rejected)); + textToShow = String.format(context.getString(R.string.call_rejected_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_rejected_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_NO_ANSWER:{ - break; - } - case MegaChatMessage.END_CALL_REASON_NO_ANSWER:{ + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_missed)); - ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_missed)); + textToShow = String.format(context.getString(R.string.call_missed_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_missed_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_FAILED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_FAILED:{ + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); - ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_failed)); + textToShow = String.format(context.getString(R.string.call_failed_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_failed_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } + case MegaChatMessage.END_CALL_REASON_CANCELLED:{ - break; - } - case MegaChatMessage.END_CALL_REASON_CANCELLED:{ + ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_missed)); - ((ViewHolderMessageChat) holder).contactManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_missed)); + textToShow = String.format(context.getString(R.string.call_missed_messages)); + try { + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + } catch (Exception e) { + } - textToShow = String.format(context.getString(R.string.call_missed_messages)); - try { - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - } catch (Exception e) { + break; } - - break; } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b7b88ddf10..89d898664d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2133,4 +2133,5 @@ Do you want to close all other sessions? This will log you out on all other active sessions except the current one. + Call started From 589fb02e1c552e376d7c1bf1a24355e7963cabb2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 5 Oct 2018 12:48:17 +0200 Subject: [PATCH 077/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 4 +-- .../chatAdapters/GroupCallAdapter.java | 29 +++++++++++++------ .../main/res/layout/activity_calls_chat.xml | 8 ++--- .../res/layout/item_camera_group_call.xml | 4 +-- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index a5b974361a8..4d4c8ab1e1e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2723,9 +2723,9 @@ public void updateUserSelected(boolean flag){ if(!isManualMode){ if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ position = 0; - peerSelected = peersOnCall.get(position); + peerSelected = peersOnCall.get(1); if((adapter != null)&&(position !=-1)){ - adapter.addLayer(position); + adapter.addLayer(1); } if(peerSelected.isVideoOn()){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index fa888b50aac..939b5e018e3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -184,6 +184,8 @@ public ViewHolderGroupCallGrid(View v) { if(numPeersOnCall < 7){ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(24, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(24, outMetrics); paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); @@ -197,6 +199,8 @@ public ViewHolderGroupCallGrid(View v) { }else{ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(15, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(15, outMetrics); paramsMicroAvatar.setMargins(0, 0, 0, 0); paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); @@ -348,15 +352,22 @@ public void onClick(View v) { //Update micro icon holder.microSurface.setImageResource(R.drawable.ic_mic_off_contact); - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); if(numPeersOnCall < 7){ - paramsMicroSurface.setMargins(0, 50, 50, 0); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams( Util.scaleWidthPx(24, outMetrics),Util.scaleWidthPx(24, outMetrics)); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(50, outMetrics), Util.scaleWidthPx(50, outMetrics), 0); + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + }else{ - paramsMicroSurface.setMargins(0, 4, 4, 0); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams( Util.scaleWidthPx(15, outMetrics),Util.scaleWidthPx(15, outMetrics)); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); + holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + } - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); @@ -719,8 +730,8 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } - public void addLayer(int position){ - log("addLayer() - position "+position); + public void addLayer(int p){ + log("addLayer() - position "+p); if(peers!=null){ //Remove green layer for the rest of users: for(int i=0; i Date: Fri, 5 Oct 2018 14:24:58 +0200 Subject: [PATCH 078/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 80 ++++++++++++----- .../megachat/calls/InfoPeerGroupCall.java | 14 ++- .../chatAdapters/GroupCallAdapter.java | 90 ++++++++++++++----- 3 files changed, 140 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 4d4c8ab1e1e..49beea1295d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -334,7 +334,7 @@ public void updateScreenStatusInProgress(){ if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress()-peersOnCall.add("+megaChatApi.getMyFullname()+")-> ME"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); peersOnCall.add(myPeer); changes = true; }else{ @@ -342,7 +342,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress()-peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null, null); peersOnCall.add(0, userPeer); changes = true; } @@ -360,14 +360,14 @@ public void updateScreenStatusInProgress(){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); peersOnCall.add(myPeer); changes = true; }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null,null); peersOnCall.add(0, userPeer); changes = true; }else{} @@ -824,7 +824,7 @@ protected void onCreate(Bundle savedInstanceState) { boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null, null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -878,7 +878,7 @@ protected void onCreate(Bundle savedInstanceState) { } - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); peersOnCall.add(myPeer); createNewAdapter(true); @@ -1393,12 +1393,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } if(!peerContain){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); peersOnCall.add(myPeer); createNewAdapter(true); } }else{ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), null,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); peersOnCall.add(myPeer); // createNewAdapter(true); } @@ -1506,7 +1506,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } } if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null, null); peersOnCall.add(0, userPeer); createNewAdapter(true); } @@ -1589,7 +1589,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ //Get all participant and add them for(int i = 0; i < call.getParticipants().size(); i++){ long userHandle = call.getParticipants().get(i); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, null,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null,null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -2712,20 +2712,49 @@ public void createNewAdapter(boolean flag){ } public void updateUserSelected(boolean flag){ - log("updateUserSelected()"); + log("**** updateUserSelected()"); if(flag){ - int position=-1; //Call IN PROGRESS if(peerSelected == null){ + log("**** updateUserSelected()- First case"); //First case: if(!isManualMode){ + log("**** A"); + if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - position = 0; - peerSelected = peersOnCall.get(1); - if((adapter != null)&&(position !=-1)){ - adapter.addLayer(1); + log("**** A.1"); + + int position = peersOnCall.size()-2; + peerSelected = peersOnCall.get(position); + log("**** A.2- position: "+position); + + for(int i=0;i 7){ + if(peer.hasGreenLayer()){ + holder.greenLayer.setVisibility(View.VISIBLE); + }else{ + holder.greenLayer.setVisibility(View.GONE); + } + }else{ + holder.greenLayer.setVisibility(View.GONE); + } + //Create listener GroupCallListener listenerPeer = new GroupCallListener(context, holder); peer.setListener(listenerPeer); @@ -489,6 +499,17 @@ public void onClick(View v) { } holder.avatarMicroLayout.setVisibility(View.VISIBLE); + //Green Layer + if(numPeersOnCall > 7){ + if(peer.hasGreenLayer()){ + holder.greenLayer.setVisibility(View.VISIBLE); + }else{ + holder.greenLayer.setVisibility(View.GONE); + } + }else{ + holder.greenLayer.setVisibility(View.GONE); + } + //Remove listener if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { log("Video OFF-> removeChatMyVideoListener()"); @@ -730,32 +751,55 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } - public void addLayer(int p){ - log("addLayer() - position "+p); - if(peers!=null){ - //Remove green layer for the rest of users: - for(int i=0; i Date: Mon, 8 Oct 2018 11:31:25 +0200 Subject: [PATCH 079/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 45 ++----- .../megachat/calls/InfoPeerGroupCall.java | 1 + .../chatAdapters/GroupCallAdapter.java | 119 +++++++----------- 3 files changed, 55 insertions(+), 110 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 49beea1295d..131913d46ff 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2128,9 +2128,8 @@ public void updateLocalAudioStatus(){ microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor))); microFAB.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_record_audio_w)); if (peersOnCall != null && !peersOnCall.isEmpty()) { - InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); - if(!item.isAudioOn()){ - item.setAudioOn(true); + if(!peersOnCall.get(peersOnCall.size()-1).isAudioOn()){ + peersOnCall.get(peersOnCall.size()-1).setAudioOn(true); int position = peersOnCall.size() -1; adapter.changesInAudio(position,null); @@ -2141,9 +2140,8 @@ public void updateLocalAudioStatus(){ microFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); microFAB.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.ic_mic_off)); if (peersOnCall != null && !peersOnCall.isEmpty()) { - InfoPeerGroupCall item = peersOnCall.get(peersOnCall.size()-1); - if(item.isAudioOn()){ - item.setAudioOn(false); + if(peersOnCall.get(peersOnCall.size()-1).isAudioOn()){ + peersOnCall.get(peersOnCall.size()-1).setAudioOn(false); int position = peersOnCall.size() -1; adapter.changesInAudio(position,null); } @@ -2712,45 +2710,28 @@ public void createNewAdapter(boolean flag){ } public void updateUserSelected(boolean flag){ - log("**** updateUserSelected()"); + log("updateUserSelected()"); if(flag){ //Call IN PROGRESS if(peerSelected == null){ - log("**** updateUserSelected()- First case"); - //First case: if(!isManualMode){ - log("**** A"); - if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - log("**** A.1"); - int position = peersOnCall.size()-2; peerSelected = peersOnCall.get(position); - log("**** A.2- position: "+position); - for(int i=0;i 7){ + if(numPeersOnCall >= 7){ if(peer.hasGreenLayer()){ holder.greenLayer.setVisibility(View.VISIBLE); }else{ @@ -500,7 +499,7 @@ public void onClick(View v) { holder.avatarMicroLayout.setVisibility(View.VISIBLE); //Green Layer - if(numPeersOnCall > 7){ + if(numPeersOnCall >= 7){ if(peer.hasGreenLayer()){ holder.greenLayer.setVisibility(View.VISIBLE); }else{ @@ -724,81 +723,53 @@ public void setListFragment(RecyclerView recyclerViewFragment) { public void changesInAudio(int position, ViewHolderGroupCall holder){ log("changesInAudio"); - if(holder == null){ - holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); - } - if(holder!=null){ - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; - } - if(peer.isAudioOn()){ - log("Audio ON"); - holder.microAvatar.setVisibility(View.GONE); - holder.microSurface.setVisibility(View.GONE); - }else{ - log("Audio OFF"); - if(!peer.isVideoOn()){ - holder.microAvatar.setVisibility(View.VISIBLE); - holder.microSurface.setVisibility(View.GONE); - }else{ - holder.microSurface.setVisibility(View.VISIBLE); - holder.microAvatar.setVisibility(View.GONE); - } - } - }else{ - notifyItemChanged(position); - } - } + notifyItemChanged(position); - public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ - log("changesInGreenLayer"); - if(holder == null){ - holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); - } - if(holder!=null){ - InfoPeerGroupCall peer = getNodeAt(position); - if (peer == null){ - return; - } - if(peer.hasGreenLayer()){ - log("Has Green layer"); - holder.greenLayer.setVisibility(View.VISIBLE); - }else{ - log("Has not Green layer"); - holder.greenLayer.setVisibility(View.GONE); - } - }else{ - notifyItemChanged(position); - } - } - - -// public void addLayer(int p){ -// log("addLayer() - position "+p); -// if(peers!=null){ -// //Remove green layer for the rest of users: -// for(int i=0; i Date: Mon, 8 Oct 2018 12:08:55 +0200 Subject: [PATCH 080/247] Feature#9775-Group calls UI --- .../chatAdapters/GroupCallAdapter.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index f4a718920d2..13c2f803a0a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -355,7 +355,7 @@ public void onClick(View v) { RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams( Util.scaleWidthPx(24, outMetrics),Util.scaleWidthPx(24, outMetrics)); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, Util.scaleWidthPx(50, outMetrics), Util.scaleWidthPx(50, outMetrics), 0); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); }else{ @@ -723,31 +723,30 @@ public void setListFragment(RecyclerView recyclerViewFragment) { public void changesInAudio(int position, ViewHolderGroupCall holder){ log("changesInAudio"); - notifyItemChanged(position); -// if(holder == null){ -// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); -// } -// if(holder!=null){ -// InfoPeerGroupCall peer = getNodeAt(position); -// if (peer == null){ -// return; -// } -// if(peer.isAudioOn()){ -// holder.microAvatar.setVisibility(View.GONE); -// holder.microSurface.setVisibility(View.GONE); -// }else{ -// if(!peer.isVideoOn()){ -// holder.microAvatar.setVisibility(View.VISIBLE); -// holder.microSurface.setVisibility(View.GONE); -// }else{ -// holder.microSurface.setVisibility(View.VISIBLE); -// holder.microAvatar.setVisibility(View.GONE); -// } -// } -// }else{ -// notifyItemChanged(position); -// } + if(holder == null){ + holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + if(peer.isAudioOn()){ + holder.microAvatar.setVisibility(View.GONE); + holder.microSurface.setVisibility(View.GONE); + }else{ + if(!peer.isVideoOn()){ + holder.microAvatar.setVisibility(View.VISIBLE); + holder.microSurface.setVisibility(View.GONE); + }else{ + holder.microSurface.setVisibility(View.VISIBLE); + holder.microAvatar.setVisibility(View.GONE); + } + } + }else{ + notifyItemChanged(position); + } } public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ From e2263d71ad4a3c6f4b9f1646cc907c65a6ba7d11 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 8 Oct 2018 12:24:22 +0200 Subject: [PATCH 081/247] Feature#9775-Group calls UI --- .../chatAdapters/GroupCallAdapter.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 13c2f803a0a..7e74095ae98 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -751,23 +751,23 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ log("changesInGreenLayer()"); - notifyItemChanged(position); -// if(holder == null){ -// holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); -// } -// if(holder!=null){ -// InfoPeerGroupCall peer = getNodeAt(position); -// if (peer == null){ -// return; -// } -// if(peer.hasGreenLayer()){ -// holder.greenLayer.setVisibility(View.VISIBLE); -// }else{ -// holder.greenLayer.setVisibility(View.GONE); -// } -// }else{ -// notifyItemChanged(position); -// } +// notifyItemChanged(position); + if(holder == null){ + holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); + } + if(holder!=null){ + InfoPeerGroupCall peer = getNodeAt(position); + if (peer == null){ + return; + } + if(peer.hasGreenLayer()){ + holder.greenLayer.setVisibility(View.VISIBLE); + }else{ + holder.greenLayer.setVisibility(View.GONE); + } + }else{ + notifyItemChanged(position); + } } @Override From 5ee106e6f10954c7eb510323915dd7a38841d102 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 8 Oct 2018 12:27:30 +0200 Subject: [PATCH 082/247] Feature#9775-Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 131913d46ff..75272b0c795 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -815,7 +815,6 @@ protected void onCreate(Bundle savedInstanceState) { if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ peersOnCall.clear(); } @@ -839,7 +838,6 @@ protected void onCreate(Bundle savedInstanceState) { relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); - myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; From 31d946f3db32e6524fb0bdc3557183fdc63507d8 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 15 Oct 2018 12:38:21 +0200 Subject: [PATCH 083/247] Task #10613-Add suppport for messages type TYPE_CALL_STARTED --- .../lollipop/controllers/ChatController.java | 11 ++++- .../megachat/ChatActivityLollipop.java | 10 ++-- .../megachat/calls/ChatCallActivity.java | 48 +++++++++---------- .../chatAdapters/MegaChatLollipopAdapter.java | 3 +- .../MegaListChatLollipopAdapter.java | 12 +++++ 5 files changed, 53 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java index 735b85eafc4..bbb1e0ef7e7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java @@ -683,7 +683,12 @@ public String createManagementString(MegaChatMessage message, MegaChatRoom chatR }else{ return ""; } - } else if(message.getType() == MegaChatMessage.TYPE_CALL_ENDED){ + }else if(message.getType() == MegaChatMessage.TYPE_CALL_STARTED){ + String textToShow = context.getResources().getString(R.string.call_started_messages); + builder.append(textToShow); + return builder.toString(); + } + else if(message.getType() == MegaChatMessage.TYPE_CALL_ENDED){ String textToShow = ""; switch(message.getTermCode()){ case MegaChatMessage.END_CALL_REASON_ENDED:{ @@ -858,6 +863,10 @@ else if (seconds == 1){ }else{ return ""; } + }else if(message.getType() == MegaChatMessage.TYPE_CALL_STARTED){ + String textToShow = context.getResources().getString(R.string.call_started_messages); + builder.append(textToShow); + return builder.toString(); } else if(message.getType() == MegaChatMessage.TYPE_CALL_ENDED){ String textToShow = ""; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 93b61ef8357..a210ff109d6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -3239,7 +3239,7 @@ else if(selected.get(0).getMessage().getType()==MegaChatMessage.TYPE_CONTACT_ATT } int type = selected.get(0).getMessage().getType(); - if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED) { + if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED||type == MegaChatMessage.TYPE_CALL_STARTED) { menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); } else{ if(Util.isOnline(chatActivity)){ @@ -3255,7 +3255,7 @@ else if(selected.get(0).getMessage().getType()==MegaChatMessage.TYPE_CONTACT_ATT importIcon.setVisible(false); int type = selected.get(0).getMessage().getType(); - if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED) { + if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED||type == MegaChatMessage.TYPE_CALL_STARTED) { menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); } else{ if(Util.isOnline(chatActivity)){ @@ -3302,7 +3302,7 @@ else if(selected.get(0).getMessage().getType()==MegaChatMessage.TYPE_CONTACT_ATT if (showForward) { int type = selected.get(i).getMessage().getType(); - if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED) { + if (type == MegaChatMessage.TYPE_TRUNCATE||type == MegaChatMessage.TYPE_ALTER_PARTICIPANTS||type == MegaChatMessage.TYPE_CHAT_TITLE||type == MegaChatMessage.TYPE_PRIV_CHANGE||type == MegaChatMessage.TYPE_CALL_ENDED||type == MegaChatMessage.TYPE_CALL_STARTED) { showForward = false; } } @@ -5495,7 +5495,7 @@ public int adjustInfoToShow(int index) { userHandleToCompare = myUserHandle; } else{ - if (msg.getMessage().getType() == MegaChatMessage.TYPE_CALL_ENDED){ + if ((msg.getMessage().getType() == MegaChatMessage.TYPE_CALL_ENDED) || (msg.getMessage().getType() == MegaChatMessage.TYPE_CALL_STARTED)){ msg.setInfoToShow(AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_TIME); return AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_TIME; } @@ -5784,7 +5784,7 @@ public void setShowAvatar(int index){ // msg.setShowAvatar(true); // } // else{ - if ((previousMessage.getMessage().getType() == MegaChatMessage.TYPE_CALL_ENDED) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_PRIV_CHANGE) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_ALTER_PARTICIPANTS) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_CHAT_TITLE)) { + if ((previousMessage.getMessage().getType() == MegaChatMessage.TYPE_CALL_ENDED) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_CALL_STARTED) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_PRIV_CHANGE) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_ALTER_PARTICIPANTS) || (previousMessage.getMessage().getType() == MegaChatMessage.TYPE_CHAT_TITLE)) { msg.setShowAvatar(true); log("Set: "+true); } else { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 64044497e82..05a2ddba8dc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -789,21 +789,21 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); - MyRingerTask myRingerTask = new MyRingerTask(); - ringerTimer.schedule(myRingerTask, 0, 500); - - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] pattern = {0, 1000, 500, 500, 1000}; - if (vibrator != null){ - if (vibrator.hasVibrator()){ - //FOR API>=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } +// +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ log("Incoming group call"); @@ -852,15 +852,15 @@ protected void onCreate(Bundle savedInstanceState) { updateScreenStatusInProgress(); }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("Outgoing group call"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index 2b0658b0538..45c7da6a6b3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -1461,6 +1461,7 @@ public boolean isKnownMessage(int messageType){ case MegaChatMessage.TYPE_CHAT_TITLE: case MegaChatMessage.TYPE_TRUNCATE: case MegaChatMessage.TYPE_REVOKE_NODE_ATTACHMENT: + case MegaChatMessage.TYPE_CALL_STARTED: case MegaChatMessage.TYPE_CALL_ENDED:{ return true; } @@ -1521,7 +1522,7 @@ public void bindCallMessage(ViewHolderMessageChat holder, AndroidMegaChatMessage String textToShow = ""; if(message.getType()==MegaChatMessage.TYPE_CALL_STARTED){ - ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_call_started)); + ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_calling)); textToShow = context.getResources().getString(R.string.call_started_messages); } else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaListChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaListChatLollipopAdapter.java index 6cf0de97658..5658d978ee3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaListChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaListChatLollipopAdapter.java @@ -1888,6 +1888,18 @@ else if(messageType==MegaChatMessage.TYPE_CHAT_TITLE) { ((ViewHolderNormalChatList)holder).textViewContent.setText(result); ((ViewHolderNormalChatList)holder).textViewContent.setTextColor(ContextCompat.getColor(context, R.color.file_list_second_row)); + + }else if(messageType==MegaChatMessage.TYPE_CALL_STARTED){ + String textToShow = context.getResources().getString(R.string.call_started_messages); + Spanned result = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + result = Html.fromHtml(textToShow, Html.FROM_HTML_MODE_LEGACY); + } else { + result = Html.fromHtml(textToShow); + } + + ((ViewHolderNormalChatList)holder).textViewContent.setText(result); + ((ViewHolderNormalChatList)holder).textViewContent.setTextColor(ContextCompat.getColor(context, R.color.file_list_second_row)); } else if(messageType==MegaChatMessage.TYPE_CALL_ENDED){ String messageContent = chat.getLastMessage(); From 2ad54bf7a668ecbbfed681ea3235234b1c573bdd Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 15 Oct 2018 12:42:02 +0200 Subject: [PATCH 084/247] Task#10613-Add suppport for messages type TYPE_CALL_STARTED --- .../lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index 45c7da6a6b3..77aecc4d2b6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -1530,7 +1530,6 @@ public void bindCallMessage(ViewHolderMessageChat holder, AndroidMegaChatMessage case MegaChatMessage.END_CALL_REASON_ENDED:{ ((ViewHolderMessageChat) holder).ownManagementMessageIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_calling)); - int minutes = (message.getDuration() % 3600) / 60; int seconds = message.getDuration() % 60; From 85a01965f6c8cb252244b736c70ca01fd69776e0 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 15 Oct 2018 13:05:36 +0200 Subject: [PATCH 085/247] The call icon in the chat is sometimes hidden --- .../megachat/ChatActivityLollipop.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index a210ff109d6..b32922525d1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1581,6 +1581,7 @@ public boolean onCreateOptionsMenu(Menu menu) { inflater.inflate(R.menu.chat_action, menu); callMenuItem = menu.findItem(R.id.cab_menu_call_chat); + videoMenuItem = menu.findItem(R.id.cab_menu_video_chat); inviteMenuItem = menu.findItem(R.id.cab_menu_invite_chat); clearHistoryMenuItem = menu.findItem(R.id.cab_menu_clear_history_chat); @@ -1602,9 +1603,7 @@ public boolean onPrepareOptionsMenu(Menu menu){ clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); contactInfoMenuItem.setVisible(false); - } - else { - + }else { if (megaChatApi.getChatConnectionState(idChat) != MegaChatApi.CHAT_CONNECTION_ONLINE) { leaveMenuItem.setVisible(false); callMenuItem.setVisible(false); @@ -1612,15 +1611,12 @@ public boolean onPrepareOptionsMenu(Menu menu){ clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); contactInfoMenuItem.setVisible(false); - } - else { - + }else { int callsInProgress = megaChatApi.getNumCalls(); - if(megaChatApi.getNumCalls()<=0){ + if(callsInProgress<=0){ callMenuItem.setVisible(true); videoMenuItem.setVisible(true); - } - else{ + }else{ callMenuItem.setVisible(false); videoMenuItem.setVisible(false); } @@ -1692,8 +1688,7 @@ public boolean onPrepareOptionsMenu(Menu menu){ } } } - } - else{ + }else{ log("Chatroom NULL on create menu"); leaveMenuItem.setVisible(false); callMenuItem.setVisible(false); @@ -7099,6 +7094,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("Hide call in progress"); callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); + invalidateOptionsMenu(); + } else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ long openCallChatId = MegaApplication.getOpenCallChatId(); From 1773e078f36fb7c35ddab38c79ee822d8a8661b6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 15 Oct 2018 13:37:45 +0200 Subject: [PATCH 086/247] The arrow icon in the chat does not work properly when there is a group call in progress --- .../android/app/lollipop/megachat/ChatActivityLollipop.java | 6 ++++-- .../app/lollipop/megachat/calls/ChatCallActivity.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index b32922525d1..004450f4e41 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1711,7 +1711,9 @@ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: { - finish(); + log("home"); + onBackPressed(); + //finish(); break; } case R.id.cab_menu_call_chat:{ @@ -2423,7 +2425,7 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onBackPressed() { - log("onBackPressedLollipop"); + log("onBackPressed"); if(megaChatApi.isSignalActivityRequired()){ megaChatApi.signalPresenceActivity(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 05a2ddba8dc..94868d5d1d1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -292,7 +292,7 @@ public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case android.R.id.home: { - log("Hang call"); + log("home"); onBackPressed(); break; } From d8f46ce09ad8eda27c9bca03554290ab115903fe Mon Sep 17 00:00:00 2001 From: aw Date: Thu, 25 Oct 2018 15:33:05 +1300 Subject: [PATCH 087/247] Bug#10840 when dragging videos, hide the icon of the video to have the same behavior in ListView. --- .../adapters/MegaOfflineLollipopAdapter.java | 11 ++++++----- .../managerSections/OfflineFragmentLollipop.java | 13 ++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java index a8834dca8a0..8cf4be1e9bc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java @@ -116,7 +116,6 @@ public ViewHolderOfflineGrid (View v){ public View fileLayout; public ImageView imageViewIcon; public RelativeLayout thumbLayoutForFile; - public ImageView fileGridIconForFile; public ImageButton imageButtonThreeDotsForFile; public TextView textViewFileNameForFile; public ImageView fileGridSelected; @@ -534,7 +533,6 @@ public ViewHolderOffline onCreateViewHolder(ViewGroup parent, int viewType) { holder.separator = (View) v.findViewById(R.id.offline_grid_separator); holder.imageViewIcon = (ImageView)v.findViewById(R.id.offline_grid_icon); - holder.fileGridIconForFile = (ImageView)v.findViewById(R.id.file_grid_icon_for_file); holder.thumbLayoutForFile = (RelativeLayout)v.findViewById(R.id.file_grid_thumbnail_layout_for_file); holder.imageButtonThreeDotsForFile = (ImageButton)v.findViewById(R.id.file_grid_three_dots_for_file); holder.textViewFileNameForFile = (TextView)v.findViewById(R.id.file_grid_filename_for_file); @@ -742,8 +740,6 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){ // long nodeSize = currentNode.getSize(); // holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); - holder.fileGridIconForFile.setVisibility(View.VISIBLE); - holder.fileGridIconForFile.setImageResource(MimeTypeThumbnail.typeForName(currentNode.getName()).getIconResourceId()); holder.thumbLayoutForFile.setBackgroundColor(Color.TRANSPARENT); if (multipleSelect && isItemChecked(position)) { @@ -1120,7 +1116,12 @@ public void onClick(View v) { imageView = (ImageView) v.findViewById(R.id.offline_list_thumbnail); } else { - imageView = (ImageView) v.findViewById(R.id.file_grid_thumbnail); + if (MimeTypeThumbnail.typeForName(mOff.getName()).isImage()){ + imageView = (ImageView) v.findViewById(R.id.file_grid_thumbnail); + }else{ + //videos don't have thumnail, only have icon.here should use the ImageView of icon. + imageView = (ImageView) v.findViewById(R.id.file_grid_icon_for_file); + } } imageView.getLocationOnScreen(screenPosition); int[] dimens = new int[4]; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java index cbe39bcda1e..4155084ba22 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java @@ -53,6 +53,7 @@ import mega.privacy.android.app.MegaOffline; import mega.privacy.android.app.MegaPreferences; import mega.privacy.android.app.MimeTypeList; +import mega.privacy.android.app.MimeTypeThumbnail; import mega.privacy.android.app.R; import mega.privacy.android.app.components.CustomizedGridLayoutManager; import mega.privacy.android.app.components.FloatingItemDecoration; @@ -222,9 +223,15 @@ public ImageView getImageDrag(int position) { } else if (gridLayoutManager != null){ View v = gridLayoutManager.findViewByPosition(position); - if (v != null) { - return (ImageView) v.findViewById(R.id.file_grid_thumbnail); - } + MegaOffline offline = adapter.getItemOff(position); + if (v != null && offline != null) { + if (MimeTypeThumbnail.typeForName(offline.getName()).isImage()){ + return v.findViewById(R.id.file_grid_thumbnail); + } else { + //videos don't have thumnail, only have icon.here should use the ImageView of icon. + return v.findViewById(R.id.file_grid_icon_for_file); + } + } } } From 20b6e7be8ef10a6b562d95e81392c267aaeffb1c Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 29 Oct 2018 14:06:36 +0100 Subject: [PATCH 088/247] Feature#9775-Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 2 +- build.gradle | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 94868d5d1d1..7252e9308a1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2559,7 +2559,7 @@ public void updateSubtitleToolbar(){ cont++; } } - participantText.setText(cont+"/5"); + participantText.setText(cont+"/6"); linearParticipants.setVisibility(View.VISIBLE); } diff --git a/build.gradle b/build.gradle index 5efd8e1f202..89098aabbfd 100644 --- a/build.gradle +++ b/build.gradle @@ -15,12 +15,13 @@ buildscript { allprojects { repositories { - jcenter() google() mavenCentral() maven { url "https://maven.google.com" // Google's Maven repository } + jcenter() + } } From de3e0881e98ebc2710f8801d95ea61eb651a8718 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 29 Oct 2018 14:11:08 +0100 Subject: [PATCH 089/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 7252e9308a1..458f6353932 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -789,21 +789,21 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ -// -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("Incoming group call"); @@ -851,17 +851,15 @@ protected void onCreate(Bundle savedInstanceState) { log("InProgress"); updateScreenStatusInProgress(); }else{ - -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } - + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("Outgoing group call"); From 71eadbe9a4611bdb52de26fc067572ec9d946d77 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 29 Oct 2018 14:30:45 +0100 Subject: [PATCH 090/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 89 ++++++++++++++----- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 458f6353932..33749c59034 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -128,7 +128,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque MegaChatCall callChat; private MegaApiAndroid megaApi = null; MegaChatApiAndroid megaChatApi = null; - private Handler handler; + private Handler handlerArrow1, handlerArrow2, handlerArrow3, handlerArrow4, handlerArrow5, handlerArrow6; Display display; DisplayMetrics outMetrics; float density; @@ -539,8 +539,6 @@ protected void onCreate(Bundle savedInstanceState) { myUser = megaApi.getMyUser(); dbH = DatabaseHandler.getDbHandler(getApplicationContext()); - handler = new Handler(); - mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); @@ -1709,17 +1707,32 @@ public void onClick(View v) { log("onClick video FAB"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ megaChatApi.answerChatCall(chatId, true, this); + if (handlerArrow1 != null){ + handlerArrow1.removeCallbacksAndMessages(null); + } + if (handlerArrow2 != null){ + handlerArrow2.removeCallbacksAndMessages(null); + } + if (handlerArrow3 != null){ + handlerArrow3.removeCallbacksAndMessages(null); + } + if (handlerArrow4 != null){ + handlerArrow4.removeCallbacksAndMessages(null); + } + if (handlerArrow5 != null){ + handlerArrow5.removeCallbacksAndMessages(null); + } + if (handlerArrow6 != null){ + handlerArrow6.removeCallbacksAndMessages(null); + } answerCallFAB.clearAnimation(); - } - else{ + videoFAB.clearAnimation(); + }else{ if(callChat.hasLocalVideo()){ log(" disableVideo"); - megaChatApi.disableVideo(chatId, this); - } - else{ + }else{ log(" enableVideo"); - megaChatApi.enableVideo(chatId, this); } } @@ -1753,10 +1766,36 @@ public void onClick(View v) { } case R.id.answer_call_fab:{ log("Click on answer fab"); - megaChatApi.answerChatCall(chatId, false, this); - videoFAB.clearAnimation(); + if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ + megaChatApi.answerChatCall(chatId, false, this); + if (handlerArrow1 != null){ + handlerArrow1.removeCallbacksAndMessages(null); + } + if (handlerArrow2 != null){ + handlerArrow2.removeCallbacksAndMessages(null); + } + if (handlerArrow3 != null){ + handlerArrow3.removeCallbacksAndMessages(null); + } + if (handlerArrow4 != null){ + handlerArrow4.removeCallbacksAndMessages(null); + } + if (handlerArrow5 != null){ + handlerArrow5.removeCallbacksAndMessages(null); + } + if (handlerArrow6 != null){ + handlerArrow6.removeCallbacksAndMessages(null); + } + answerCallFAB.clearAnimation(); + videoFAB.clearAnimation(); + }else{ + + } + + if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){ + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + } - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); break; } } @@ -1819,16 +1858,16 @@ public void showInitialFABConfiguration(){ linearFAB.setOrientation(LinearLayout.HORIZONTAL); animationAlphaArrows(fourArrowVideo); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow1 = new Handler(); + handlerArrow1.postDelayed(new Runnable() { public void run() { animationAlphaArrows(thirdArrowVideo); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow2 = new Handler(); + handlerArrow2.postDelayed(new Runnable() { public void run() { animationAlphaArrows(secondArrowVideo); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow3 = new Handler(); + handlerArrow3.postDelayed(new Runnable() { public void run() { animationAlphaArrows(firstArrowVideo); } @@ -1837,6 +1876,8 @@ public void run() { }, 250); } }, 250); + + videoFAB.setOnTouchListener(new OnSwipeTouchListener(this) { public void onSwipeTop() { log("onSwipeTop"); @@ -1906,16 +1947,16 @@ public void onSwipeBottom() {} linearArrowCall.setVisibility(View.VISIBLE); animationAlphaArrows(fourArrowCall); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow4 = new Handler(); + handlerArrow4.postDelayed(new Runnable() { public void run() { animationAlphaArrows(thirdArrowCall); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow5 = new Handler(); + handlerArrow5.postDelayed(new Runnable() { public void run() { animationAlphaArrows(secondArrowCall); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + handlerArrow6 = new Handler(); + handlerArrow6.postDelayed(new Runnable() { public void run() { animationAlphaArrows(firstArrowCall); } From 12a3b88bea3db3707d0c13963edcf2f2f2ac219a Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 29 Oct 2018 14:37:47 +0100 Subject: [PATCH 091/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 33749c59034..1fdd0e5bc6c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1215,6 +1215,7 @@ public void onDestroy(){ if (customHandler != null){ customHandler.removeCallbacksAndMessages(null); } + clearHandlers(); peerSelected = null; isManualMode = false; @@ -1248,6 +1249,8 @@ public void onBackPressed() { if (customHandler != null){ customHandler.removeCallbacksAndMessages(null); } + clearHandlers(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); @@ -1707,24 +1710,8 @@ public void onClick(View v) { log("onClick video FAB"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ megaChatApi.answerChatCall(chatId, true, this); - if (handlerArrow1 != null){ - handlerArrow1.removeCallbacksAndMessages(null); - } - if (handlerArrow2 != null){ - handlerArrow2.removeCallbacksAndMessages(null); - } - if (handlerArrow3 != null){ - handlerArrow3.removeCallbacksAndMessages(null); - } - if (handlerArrow4 != null){ - handlerArrow4.removeCallbacksAndMessages(null); - } - if (handlerArrow5 != null){ - handlerArrow5.removeCallbacksAndMessages(null); - } - if (handlerArrow6 != null){ - handlerArrow6.removeCallbacksAndMessages(null); - } + clearHandlers(); + answerCallFAB.clearAnimation(); videoFAB.clearAnimation(); }else{ @@ -1768,24 +1755,8 @@ public void onClick(View v) { log("Click on answer fab"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ megaChatApi.answerChatCall(chatId, false, this); - if (handlerArrow1 != null){ - handlerArrow1.removeCallbacksAndMessages(null); - } - if (handlerArrow2 != null){ - handlerArrow2.removeCallbacksAndMessages(null); - } - if (handlerArrow3 != null){ - handlerArrow3.removeCallbacksAndMessages(null); - } - if (handlerArrow4 != null){ - handlerArrow4.removeCallbacksAndMessages(null); - } - if (handlerArrow5 != null){ - handlerArrow5.removeCallbacksAndMessages(null); - } - if (handlerArrow6 != null){ - handlerArrow6.removeCallbacksAndMessages(null); - } + clearHandlers(); + answerCallFAB.clearAnimation(); videoFAB.clearAnimation(); }else{ @@ -1881,6 +1852,7 @@ public void run() { videoFAB.setOnTouchListener(new OnSwipeTouchListener(this) { public void onSwipeTop() { log("onSwipeTop"); + videoFAB.clearAnimation(); TranslateAnimation translateAnim = new TranslateAnimation( 0, 0 , 0, -380 ); @@ -2569,6 +2541,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { } public void answerAudioCall(){ + clearHandlers(); + if (megaChatApi.isSignalActivityRequired()) { megaChatApi.signalPresenceActivity(); } @@ -2576,6 +2550,7 @@ public void answerAudioCall(){ } public void answerVideoCall(){ log("answerVideoCall"); + clearHandlers(); if (megaChatApi.isSignalActivityRequired()) { megaChatApi.signalPresenceActivity(); } @@ -3021,4 +2996,26 @@ public void createDefaultAvatarGroupCall(long userHandle, String fullName) { avatarBigCameraGroupCallInitialLetter.setText(contactFirstLetter); avatarBigCameraGroupCallInitialLetter.setVisibility(View.VISIBLE); } + + public void clearHandlers(){ + log("clearHandlers"); + if (handlerArrow1 != null){ + handlerArrow1.removeCallbacksAndMessages(null); + } + if (handlerArrow2 != null){ + handlerArrow2.removeCallbacksAndMessages(null); + } + if (handlerArrow3 != null){ + handlerArrow3.removeCallbacksAndMessages(null); + } + if (handlerArrow4 != null){ + handlerArrow4.removeCallbacksAndMessages(null); + } + if (handlerArrow5 != null){ + handlerArrow5.removeCallbacksAndMessages(null); + } + if (handlerArrow6 != null){ + handlerArrow6.removeCallbacksAndMessages(null); + } + } } From d0d8282a6dd4b6905480b1727ca87c014518dfac Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 30 Oct 2018 09:33:12 +0100 Subject: [PATCH 092/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 189 ++++++++++-------- 1 file changed, 101 insertions(+), 88 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1fdd0e5bc6c..8988e27b8ee 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -830,7 +830,6 @@ protected void onCreate(Bundle savedInstanceState) { createNewAdapter(false); } } - }else{ log("Incoming individual call"); @@ -872,7 +871,6 @@ protected void onCreate(Bundle savedInstanceState) { peersOnCall.clear(); } - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); peersOnCall.add(myPeer); createNewAdapter(true); @@ -2579,139 +2577,154 @@ public void updateSubtitleToolbar(){ } public void createNewAdapter(boolean flag){ - log("createNewAdapter() ----> peersOnCall: "+peersOnCall.size()); if(flag){ + log("createNewAdapter() ----> call in progress: peersOnCall("+peersOnCall.size()+")"); + //Call IN PROGRESS updateSubtitleToolbar(); //arrayList-> peersOnCall if(peersOnCall.size() < 7){ - //1-6 peers - bigRecyclerView.setAdapter(null); - bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); - - if(peersOnCall.size() < 4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.MATCH_PARENT; - recyclerView.setLayoutParams(params); - - }else if(peersOnCall.size()==4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(360, outMetrics); - recyclerView.setLayoutParams(params); - }else{ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(540, outMetrics); - recyclerView.setLayoutParams(params); - } + if(peersOnCall.size()!=0){ + //1-6 peers + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); - }else{ recyclerView.setVisibility(View.VISIBLE); + + if(peersOnCall.size() < 4){ + //1-3 peers + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + recyclerView.setLayoutParams(params); + + }else if(peersOnCall.size()==4){ + //4 peers + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(360, outMetrics); + recyclerView.setLayoutParams(params); + + }else{ + //5-6 peers + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(540, outMetrics); + recyclerView.setLayoutParams(params); + } + + if(peersOnCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + + //recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); + recyclerView.setAdapter(adapter); + + }else{ + recyclerView.setAdapter(null); + recyclerView.setVisibility(View.GONE); + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); } }else{ - //7 + peers recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); - bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(View.VISIBLE); + +// bigRecyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); bigRecyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - bigRecyclerView.setVisibility(View.GONE); - }else{ - bigRecyclerView.setVisibility(View.VISIBLE); - } updateUserSelected(flag); - } }else{ //Call INCOMING + log("createNewAdapter() ----> call incoming: peersBeforeCall("+peersBeforeCall.size()+")"); linearParticipants.setVisibility(View.GONE); //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { - //1-6 peers - bigRecyclerView.setAdapter(null); - bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); - parentBigCameraGroupCall.setVisibility(View.GONE); - - if(peersBeforeCall.size() < 4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.MATCH_PARENT; - recyclerView.setLayoutParams(params); - - }else if(peersBeforeCall.size()==4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(360, outMetrics); - recyclerView.setLayoutParams(params); - }else{ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(540, outMetrics); - recyclerView.setLayoutParams(params); - } + if(peersBeforeCall.size() != 0){ + //1-6 peers + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); - } + recyclerView.setVisibility(View.VISIBLE); + + if(peersBeforeCall.size() < 4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + recyclerView.setLayoutParams(params); + + }else if(peersBeforeCall.size()==4){ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(360, outMetrics); + recyclerView.setLayoutParams(params); + + }else{ + ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = Util.scaleWidthPx(540, outMetrics); + recyclerView.setLayoutParams(params); + } + + if(peersBeforeCall.size() <= 3){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + +// recyclerView.setAdapter(null); + adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); + recyclerView.setAdapter(adapter); - recyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); - recyclerView.setAdapter(adapter); - if (adapter.getItemCount() == 0){ - recyclerView.setVisibility(View.GONE); }else{ - recyclerView.setVisibility(View.VISIBLE); + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); + bigRecyclerView.setAdapter(null); + bigRecyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); + parentBigCameraGroupCall.setVisibility(View.GONE); } }else{ //7 + peers - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); - bigRecyclerView.setAdapter(null); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + bigRecyclerView.setVisibility(View.VISIBLE); + +// bigRecyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); bigRecyclerView.setAdapter(adapter); - - if (adapter.getItemCount() == 0){ - bigRecyclerView.setVisibility(View.GONE); - }else{ - bigRecyclerView.setVisibility(View.VISIBLE); - } updateUserSelected(flag); } } From 5945eebd07d50932db64801aed72555b68d9adb2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 30 Oct 2018 10:02:24 +0100 Subject: [PATCH 093/247] Feature#9775-Group calls UI --- .../megachat/calls/ChatCallActivity.java | 70 ++++++++++++++----- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 8988e27b8ee..3e2c7dc9eee 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2638,20 +2638,37 @@ public void createNewAdapter(boolean flag){ } }else{ - //7 + peers - recyclerView.setAdapter(null); - recyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); + if((peersOnCall.size() == 7) && (recyclerView.isShown())){ + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); - bigRecyclerView.setVisibility(View.VISIBLE); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); + bigRecyclerView.setVisibility(View.VISIBLE); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + bigRecyclerView.setAdapter(adapter); + }else{ + adapter.notifyDataSetChanged(); + } updateUserSelected(flag); + +// //7 + peers +// recyclerView.setAdapter(null); +// recyclerView.setVisibility(GONE); +// +// parentBigCameraGroupCall.setOnClickListener(this); +// parentBigCameraGroupCall.setVisibility(View.VISIBLE); +// +// bigRecyclerView.setVisibility(View.VISIBLE); +// +//// bigRecyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); +// bigRecyclerView.setAdapter(adapter); +// +// updateUserSelected(flag); } }else{ @@ -2713,19 +2730,36 @@ public void createNewAdapter(boolean flag){ } }else{ - //7 + peers - recyclerView.setAdapter(null); - recyclerView.setVisibility(GONE); + if((peersBeforeCall.size() == 7) && (recyclerView.isShown())){ + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); - bigRecyclerView.setVisibility(View.VISIBLE); + bigRecyclerView.setVisibility(View.VISIBLE); + adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); + bigRecyclerView.setAdapter(adapter); -// bigRecyclerView.setAdapter(null); - adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); + }else{ + adapter.notifyDataSetChanged(); + } updateUserSelected(flag); + + +// //7 + peers +// recyclerView.setAdapter(null); +// recyclerView.setVisibility(GONE); +// +// parentBigCameraGroupCall.setOnClickListener(this); +// parentBigCameraGroupCall.setVisibility(View.VISIBLE); +// +// bigRecyclerView.setVisibility(View.VISIBLE); +// +//// bigRecyclerView.setAdapter(null); +// adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); +// bigRecyclerView.setAdapter(adapter); +// updateUserSelected(flag); } } } From 714e08f102e5e8dba4957dc4c04364c2c798df51 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 30 Oct 2018 10:28:52 +0100 Subject: [PATCH 094/247] Feature#9775-Group calls UI --- .../lollipop/megachat/calls/ChatCallActivity.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 3e2c7dc9eee..06ec5767056 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2718,8 +2718,6 @@ public void createNewAdapter(boolean flag){ // recyclerView.setAdapter(null); adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapter); - - }else{ recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); @@ -2840,16 +2838,16 @@ public void updateUserSelected(boolean flag){ } } } - //Rest of cases: + if(peerSelected.isVideoOn()){ //Video ON createBigFragment(peerSelected.getHandle()); if(peerSelected.isAudioOn()){ - //Disable audio icon GONE + //Audio on, icon GONE avatarBigCameraGroupCallMicro.setVisibility(GONE); microFragmentBigCameraGroupCall.setVisibility(GONE); }else{ - //Disable audio icon VISIBLE + //Audio off, icon VISIBLE avatarBigCameraGroupCallMicro.setVisibility(GONE); microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); } @@ -2857,11 +2855,11 @@ public void updateUserSelected(boolean flag){ //Video OFF createBigAvatar(peerSelected.getHandle(), peerSelected.getName()); if(peerSelected.isAudioOn()){ - //Disable audio icon GONE + //Audio on, icon GONE avatarBigCameraGroupCallMicro.setVisibility(GONE); microFragmentBigCameraGroupCall.setVisibility(GONE); }else{ - //Disable audio icon VISIBLE + //Audio off, icon VISIBLE avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); microFragmentBigCameraGroupCall.setVisibility(GONE); } From 237232de2a3c1db56cf135725b53f11158800e17 Mon Sep 17 00:00:00 2001 From: Javier Gomez Date: Wed, 7 Nov 2018 19:13:08 +0100 Subject: [PATCH 095/247] Task #10930: Improved management of overquota errors --- .../android/app/CameraSyncService.java | 19 ++++++----- .../privacy/android/app/DownloadService.java | 24 +++++++------ .../privacy/android/app/UploadService.java | 29 ++++++++++++---- .../app/jobservices/CameraUploadsService.java | 19 ++++++----- .../lollipop/AudioVideoPlayerLollipop.java | 14 ++++---- .../app/lollipop/ManagerActivityLollipop.java | 11 ++++-- .../lollipop/PdfViewerActivityLollipop.java | 14 ++++---- .../lollipop/megachat/ChatUploadService.java | 34 +++++++++++++------ 8 files changed, 105 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java index a01dece64e6..88a77625371 100644 --- a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java +++ b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java @@ -2458,14 +2458,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isImage()){ uploadNext(); } } - else if(e.getErrorCode()==MegaError.API_EOVERQUOTA){ - log("OVERQUOTA ERROR: "+e.getErrorCode()); - - isOverquota = true; - - CameraSyncService.this.cancel(); - - } else{ log("Image Sync FAIL: " + transfer.getFileName() + "___" + e.getErrorString()); megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); @@ -2500,6 +2492,17 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { @Override public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) { log("onTransferTemporaryError: " + transfer.getFileName()); + + if(e.getErrorCode()==MegaError.API_EOVERQUOTA){ + if (e.getValue() != 0) + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); + else + log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); + + isOverquota = true; + + CameraSyncService.this.cancel(); + } } @SuppressWarnings("deprecation") diff --git a/app/src/main/java/mega/privacy/android/app/DownloadService.java b/app/src/main/java/mega/privacy/android/app/DownloadService.java index 4f4d7e95886..6662549c583 100644 --- a/app/src/main/java/mega/privacy/android/app/DownloadService.java +++ b/app/src/main/java/mega/privacy/android/app/DownloadService.java @@ -2193,20 +2193,22 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) { log(transfer.getPath() + "\nDownload Temporary Error: " + e.getErrorString() + "__" + e.getErrorCode()); - if(e.getErrorCode() == MegaError.API_EOVERQUOTA) { - log("API_EOVERQUOTA error!!"); + if(transfer.getType()==MegaTransfer.TYPE_DOWNLOAD){ + if(e.getErrorCode() == MegaError.API_EOVERQUOTA) { + if (e.getValue() != 0) { + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); - if(transfer.getType()==MegaTransfer.TYPE_DOWNLOAD){ - UserCredentials credentials = dbH.getCredentials(); - if(credentials!=null){ - log("Credentials is NOT null"); - } + UserCredentials credentials = dbH.getCredentials(); + if(credentials!=null){ + log("Credentials is NOT null"); + } - downloadedBytesToOverquota = megaApi.getTotalDownloadedBytes() + megaApiFolder.getTotalDownloadedBytes(); - isOverquota = true; - log("downloaded bytes to reach overquota: "+downloadedBytesToOverquota); + downloadedBytesToOverquota = megaApi.getTotalDownloadedBytes() + megaApiFolder.getTotalDownloadedBytes(); + isOverquota = true; + log("downloaded bytes to reach overquota: "+downloadedBytesToOverquota); - showTransferOverquotaNotification(); + showTransferOverquotaNotification(); + } } } } diff --git a/app/src/main/java/mega/privacy/android/app/UploadService.java b/app/src/main/java/mega/privacy/android/app/UploadService.java index 2b158036be2..fd6b5e33f25 100644 --- a/app/src/main/java/mega/privacy/android/app/UploadService.java +++ b/app/src/main/java/mega/privacy/android/app/UploadService.java @@ -666,13 +666,6 @@ public void onTransferFinish(MegaApiJava api, MegaTransfer transfer, MegaError e mapProgressTransfers.put(transfer.getTag(), transfer); - if (error.getErrorCode() == MegaError.API_EOVERQUOTA) { - isOverquota = 1; - } - else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) { - isOverquota = 2; - } - if (!transfer.isFolderTransfer()) { if (transfer.getState() == MegaTransfer.STATE_COMPLETED) { @@ -940,6 +933,28 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) { log("onTransferTemporaryError: " + e.getErrorString() + "__" + e.getErrorCode()); + if(transfer.getType()==MegaTransfer.TYPE_UPLOAD) { + switch (e.getErrorCode()) + { + case MegaError.API_EOVERQUOTA: + case MegaError.API_EGOINGOVERQUOTA: + if (e.getErrorCode() == MegaError.API_EOVERQUOTA) { + isOverquota = 1; + } + else if (e.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) { + isOverquota = 2; + } + + if (e.getValue() != 0) { + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); + } + else { + log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); + showStorageOverquotaNotification(); + } + break; + } + } } private void showStorageOverquotaNotification(){ diff --git a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java index 75627de5d5b..f79ee20028d 100644 --- a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java +++ b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java @@ -1741,6 +1741,17 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { @Override public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) { log("onTransferTemporaryError: " + transfer.getFileName()); + + if(e.getErrorCode()==MegaError.API_EOVERQUOTA){ + if (e.getValue() != 0) + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); + else + log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); + + isOverquota = true; + + cancel(); + } } @Override @@ -1901,14 +1912,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isImage()){ uploadNext(); } } - else if(e.getErrorCode()==MegaError.API_EOVERQUOTA){ - log("OVERQUOTA ERROR: "+e.getErrorCode()); - - isOverquota = true; - - cancel(); - - } else{ log("Image Sync FAIL: " + transfer.getFileName() + "___" + e.getErrorString()); megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java index e46369885b6..c71f6c71937 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java @@ -3836,15 +3836,17 @@ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, Meg log("onTransferTemporaryError"); if(e.getErrorCode() == MegaError.API_EOVERQUOTA){ - log("API_EOVERQUOTA error!!"); + if (e.getValue() != 0) { + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); - if(alertDialogTransferOverquota==null){ - showTransferOverquotaDialog(); - } - else { - if (!(alertDialogTransferOverquota.isShowing())) { + if(alertDialogTransferOverquota==null){ showTransferOverquotaDialog(); } + else { + if (!(alertDialogTransferOverquota.isShowing())) { + showTransferOverquotaDialog(); + } + } } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index 828d343e160..533ceda6008 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -17605,9 +17605,14 @@ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, Meg log("onTransferTemporaryError: " + transfer.getFileName() + " - " + transfer.getTag()); if(e.getErrorCode() == MegaError.API_EOVERQUOTA){ - log("API_EOVERQUOTA error!!"); - if (fbFLol != null && fbFLol.isAdded()){ - fbFLol.setOverviewLayout(); + if (e.getValue() != 0) { + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); + if (fbFLol != null && fbFLol.isAdded()){ + fbFLol.setOverviewLayout(); + } + } + else { + log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java index 73affff991d..7a5d8339361 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java @@ -3161,15 +3161,17 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) { if(e.getErrorCode() == MegaError.API_EOVERQUOTA){ - log("API_EOVERQUOTA error!!"); + if (e.getValue() != 0) { + log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode()); - if(alertDialogTransferOverquota==null){ - showTransferOverquotaDialog(); - } - else { - if (!(alertDialogTransferOverquota.isShowing())) { + if(alertDialogTransferOverquota==null){ showTransferOverquotaDialog(); } + else { + if (!(alertDialogTransferOverquota.isShowing())) { + showTransferOverquotaDialog(); + } + } } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java index 384f62ac5c6..4a5649bbd84 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java @@ -886,14 +886,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isPdf()) { log("Transfer API_EEXIST: "+transfer.getNodeHandle()); } else{ - - if (error.getErrorCode() == MegaError.API_EOVERQUOTA) { - isOverquota = 1; - } - else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) { - isOverquota = 2; - } - //Find the pending message for(int i=0; i Date: Wed, 7 Nov 2018 19:17:54 +0100 Subject: [PATCH 096/247] SDK submodule update (required) --- app/src/main/jni/mega/sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/jni/mega/sdk b/app/src/main/jni/mega/sdk index d07d8bb6c9e..8d632e0f316 160000 --- a/app/src/main/jni/mega/sdk +++ b/app/src/main/jni/mega/sdk @@ -1 +1 @@ -Subproject commit d07d8bb6c9e8f6a7815cb0123c85dbec66476219 +Subproject commit 8d632e0f31614e2160418639ae9337216ec42aae From fb5efbc94da143bc0347fe724108f690d75bd8d6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 13 Nov 2018 12:38:09 +0100 Subject: [PATCH 097/247] Group calls --- app/src/main/res/layout/activity_calls_chat.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 0376b1b9bfc..33757869eba 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -106,8 +106,6 @@ android:id="@+id/micro_avatar_big_camera_group_call" android:layout_width="24dp" android:layout_height="24dp" - android:layout_toRightOf="@+id/rl_avatar_big_camera_group_call" - android:layout_alignTop="@+id/rl_avatar_big_camera_group_call" android:background="@android:color/transparent" android:visibility="gone" android:src="@drawable/ic_mic_off_contact"/> @@ -126,6 +124,7 @@ android:visibility="gone"/> + Date: Thu, 15 Nov 2018 12:41:45 +0100 Subject: [PATCH 098/247] Group Calls UI --- .../megachat/calls/ChatCallActivity.java | 17 ++++++++++++++--- .../megachat/chatAdapters/GroupCallAdapter.java | 12 ++++++++++++ app/src/main/res/layout/activity_calls_chat.xml | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 06ec5767056..278e7af86c9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1391,7 +1391,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); peersOnCall.add(myPeer); -// createNewAdapter(true); + createNewAdapter(true); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -2624,9 +2624,11 @@ public void createNewAdapter(boolean flag){ recyclerView.setColumnWidth((int) widthScreenPX/2); } - //recyclerView.setAdapter(null); + if(adapter!=null){ + adapter.removeSurfacesView(); + } adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); - recyclerView.setAdapter(adapter); + recyclerView.setAdapter(adapter); }else{ recyclerView.setAdapter(null); @@ -2647,6 +2649,9 @@ public void createNewAdapter(boolean flag){ parentBigCameraGroupCall.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); + if(adapter!=null){ + adapter.removeSurfacesView(); + } adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); bigRecyclerView.setAdapter(adapter); @@ -2716,6 +2721,9 @@ public void createNewAdapter(boolean flag){ } // recyclerView.setAdapter(null); + if(adapter!=null){ + adapter.removeSurfacesView(); + } adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapter); }else{ @@ -2736,6 +2744,9 @@ public void createNewAdapter(boolean flag){ parentBigCameraGroupCall.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); + if(adapter!=null){ + adapter.removeSurfacesView(); + } adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); bigRecyclerView.setAdapter(adapter); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7e74095ae98..0994d213c5a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -721,6 +721,18 @@ public void setListFragment(RecyclerView recyclerViewFragment) { this.recyclerViewFragment = recyclerViewFragment; } + public void removeSurfacesView(){ + if((peers!=null)&&(peers.size())>0){ + for(int i=0;i From 7134604d2e04335220a7fa7653ef06bf821aabd1 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 16 Nov 2018 12:01:06 +0100 Subject: [PATCH 099/247] Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 1 + .../megachat/calls/ChatCallActivity.java | 392 +++++++------- .../megachat/calls/InfoPeerGroupCall.java | 2 +- .../chatAdapters/GroupCallAdapter.java | 489 +++++++++--------- .../main/res/layout/activity_calls_chat.xml | 5 +- .../res/layout/item_camera_group_call.xml | 25 +- 6 files changed, 446 insertions(+), 468 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index eee2e968036..5c9002964b4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -75,6 +75,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } + public void setWidth(int width) { this.width = width; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 278e7af86c9..ce370017b26 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -161,7 +161,8 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque LinearLayoutManager layoutManager; RecyclerView bigRecyclerView; - GroupCallAdapter adapter; + GroupCallAdapter adapterGrid; + GroupCallAdapter adapterList; int isRemoteVideo = REMOTE_VIDEO_NOT_INIT; @@ -187,6 +188,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FloatingActionButton microFAB; FloatingActionButton hangFAB; FloatingActionButton answerCallFAB; + boolean isNecesaryCreateAdapter = true; AudioManager audioManager; MediaPlayer thePlayer; @@ -353,7 +355,7 @@ public void updateScreenStatusInProgress(){ } } if(changes){ - createNewAdapter(true); + updatePeers(true); } }else{ @@ -377,7 +379,7 @@ public void updateScreenStatusInProgress(){ } } if(changes){ - createNewAdapter(true); + updatePeers(true); } } @@ -642,7 +644,7 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setPadding(0, 0, 0, 0); recyclerView.setClipToPadding(false); recyclerView.setHasFixedSize(true); - recyclerView.setColumnWidth((int) widthScreenPX); + recyclerView.setColumnWidth((int) widthScreenPX/2); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setVisibility(GONE); @@ -788,20 +790,20 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); - ringerTimer = new Timer(); - MyRingerTask myRingerTask = new MyRingerTask(); - ringerTimer.schedule(myRingerTask, 0, 500); - - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - long[] pattern = {0, 1000, 500, 500, 1000}; - if (vibrator != null){ - if (vibrator.hasVibrator()){ - //FOR API>=26 - //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? - vibrator.vibrate(pattern, 0); - } - } +// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); +// ringerTimer = new Timer(); +// MyRingerTask myRingerTask = new MyRingerTask(); +// ringerTimer.schedule(myRingerTask, 0, 500); +// +// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); +// long[] pattern = {0, 1000, 500, 500, 1000}; +// if (vibrator != null){ +// if (vibrator.hasVibrator()){ +// //FOR API>=26 +// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? +// vibrator.vibrate(pattern, 0); +// } +// } if(chat.isGroup()){ log("Incoming group call"); @@ -827,7 +829,7 @@ protected void onCreate(Bundle savedInstanceState) { changes = true; } if(changes){ - createNewAdapter(false); + updatePeers(false); } } }else{ @@ -848,15 +850,15 @@ protected void onCreate(Bundle savedInstanceState) { log("InProgress"); updateScreenStatusInProgress(); }else{ - int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - if (volume == 0) { - toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); - toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); - }else { - thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); - thePlayer.setLooping(true); - thePlayer.start(); - } +// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); +// if (volume == 0) { +// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); +// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); +// }else { +// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); +// thePlayer.setLooping(true); +// thePlayer.start(); +// } if(chat.isGroup()){ log("Outgoing group call"); @@ -873,7 +875,7 @@ protected void onCreate(Bundle savedInstanceState) { InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); peersOnCall.add(myPeer); - createNewAdapter(true); + updatePeers(true); }else{ log("Outgoing individual call"); @@ -1386,12 +1388,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); peersOnCall.add(myPeer); - createNewAdapter(true); + updatePeers(true); } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); peersOnCall.add(myPeer); - createNewAdapter(true); + updatePeers(true); } updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1499,7 +1501,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null, null); peersOnCall.add(0, userPeer); - createNewAdapter(true); + updatePeers(true); } } @@ -1515,8 +1517,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i= 7) && (peerSelected != null)){ - if(peerSelected.getHandle().equals(userHandle)){ - createBigFragment(peerSelected.getHandle()); - if(peerSelected.isAudioOn()){ - //Disable audio icon GONE - avatarBigCameraGroupCallMicro.setVisibility(GONE); - microFragmentBigCameraGroupCall.setVisibility(GONE); - }else{ - //Disable audio icon VISIBLE - avatarBigCameraGroupCallMicro.setVisibility(GONE); - microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + if(peersOnCall.size()<7){ + adapterGrid.notifyItemChanged(i); + }else{ + adapterList.notifyItemChanged(i); + if(peerSelected != null){ + if(peerSelected.getHandle().equals(userHandle)){ + createBigFragment(peerSelected.getHandle()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + } } } } + break; } } @@ -2207,22 +2230,29 @@ public void updateRemoteVideoStatus(long userHandle){ if(peersOnCall.get(i).getHandle().equals(userHandle)){ if(peersOnCall.get(i).isVideoOn()){ peersOnCall.get(i).setVideoOn(false); - adapter.notifyItemChanged(i); updateSubtitleToolbar(); - if((peersOnCall.size() >= 7) && (peerSelected != null)){ - if(peerSelected.getHandle().equals(userHandle)){ - createBigAvatar(peerSelected.getHandle(),peerSelected.getName()); - if(peerSelected.isAudioOn()){ - //Disable audio icon GONE - avatarBigCameraGroupCallMicro.setVisibility(GONE); - microFragmentBigCameraGroupCall.setVisibility(GONE); - }else{ - //Disable audio icon VISIBLE - avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); - microFragmentBigCameraGroupCall.setVisibility(GONE); + + if(peersOnCall.size()<7){ + adapterGrid.notifyItemChanged(i); + }else{ + adapterList.notifyItemChanged(i); + if(peerSelected != null){ + if(peerSelected.getHandle().equals(userHandle)){ + createBigAvatar(peerSelected.getHandle(),peerSelected.getName()); + if(peerSelected.isAudioOn()){ + //Disable audio icon GONE + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + }else{ + //Disable audio icon VISIBLE + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } + } + break; } } @@ -2315,11 +2345,16 @@ public void updateRemoteAudioStatus(long userHandle){ if(peersOnCall.get(i).getHandle().equals(userHandle)){ if(!peersOnCall.get(i).isAudioOn()){ peersOnCall.get(i).setAudioOn(true); - adapter.changesInAudio(i,null); - if((peersOnCall.size() >= 7) && (peerSelected != null)){ - if(peerSelected.getHandle().equals(userHandle)){ - avatarBigCameraGroupCallMicro.setVisibility(GONE); - microFragmentBigCameraGroupCall.setVisibility(GONE); + + if(peersOnCall.size()<7){ + adapterGrid.changesInAudio(i,null); + }else{ + adapterList.changesInAudio(i,null); + if(peerSelected!=null){ + if(peerSelected.getHandle().equals(userHandle)){ + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } break; @@ -2334,18 +2369,24 @@ public void updateRemoteAudioStatus(long userHandle){ if(peersOnCall.get(i).getHandle().equals(userHandle)){ if(peersOnCall.get(i).isAudioOn()){ peersOnCall.get(i).setAudioOn(false); - adapter.changesInAudio(i,null); - if((peersOnCall.size() >= 7) && (peerSelected != null)){ - if(peerSelected.getHandle().equals(userHandle)){ - if(peerSelected.isVideoOn()){ - avatarBigCameraGroupCallMicro.setVisibility(GONE); - microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); - }else{ - avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); - microFragmentBigCameraGroupCall.setVisibility(GONE); + + if(peersOnCall.size()<7){ + adapterGrid.changesInAudio(i,null); + }else{ + adapterList.changesInAudio(i,null); + if(peerSelected != null){ + if(peerSelected.getHandle().equals(userHandle)){ + if(peerSelected.isVideoOn()){ + avatarBigCameraGroupCallMicro.setVisibility(GONE); + microFragmentBigCameraGroupCall.setVisibility(View.VISIBLE); + }else{ + avatarBigCameraGroupCallMicro.setVisibility(View.VISIBLE); + microFragmentBigCameraGroupCall.setVisibility(GONE); + } } } } + break; } } @@ -2576,59 +2617,33 @@ public void updateSubtitleToolbar(){ } - public void createNewAdapter(boolean flag){ - + public void updatePeers(boolean flag){ if(flag){ - log("createNewAdapter() ----> call in progress: peersOnCall("+peersOnCall.size()+")"); + log("updatePeers() ----> IN PROGRESS: peersOnCall("+peersOnCall.size()+")"); //Call IN PROGRESS updateSubtitleToolbar(); - //arrayList-> peersOnCall if(peersOnCall.size() < 7){ - + //1-6 if(peersOnCall.size()!=0){ - //1-6 peers bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); - - if(peersOnCall.size() < 4){ - //1-3 peers - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.MATCH_PARENT; - recyclerView.setLayoutParams(params); - - }else if(peersOnCall.size()==4){ - //4 peers - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(360, outMetrics); - recyclerView.setLayoutParams(params); - + if(adapterGrid == null){ + adapterGrid = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); + recyclerView.setAdapter(adapterGrid); }else{ - //5-6 peers - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(540, outMetrics); - recyclerView.setLayoutParams(params); - } - - if(peersOnCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersOnCall.size() > 3)&&(peersOnCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - - if(adapter!=null){ - adapter.removeSurfacesView(); + if(isNecesaryCreateAdapter){ + recyclerView.setAdapter(null); + adapterGrid = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); + recyclerView.setAdapter(adapterGrid); + }else{ + adapterGrid.notifyDataSetChanged(); + } } - adapter = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); - recyclerView.setAdapter(adapter); }else{ recyclerView.setAdapter(null); @@ -2640,93 +2655,54 @@ public void createNewAdapter(boolean flag){ } }else{ - - if((peersOnCall.size() == 7) && (recyclerView.isShown())){ - recyclerView.setAdapter(null); - recyclerView.setVisibility(GONE); - - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - - bigRecyclerView.setVisibility(View.VISIBLE); - if(adapter!=null){ - adapter.removeSurfacesView(); - } - adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); - + //7 + + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + + bigRecyclerView.setVisibility(View.VISIBLE); + if(adapterList==null){ + adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + bigRecyclerView.setAdapter(adapterList); }else{ - adapter.notifyDataSetChanged(); + if(isNecesaryCreateAdapter){ + bigRecyclerView.setAdapter(null); + adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); + bigRecyclerView.setAdapter(adapterList); + }else{ + adapterList.notifyDataSetChanged(); + } } updateUserSelected(flag); - -// //7 + peers -// recyclerView.setAdapter(null); -// recyclerView.setVisibility(GONE); -// -// parentBigCameraGroupCall.setOnClickListener(this); -// parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// -// bigRecyclerView.setVisibility(View.VISIBLE); -// -//// bigRecyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); -// bigRecyclerView.setAdapter(adapter); -// -// updateUserSelected(flag); } + isNecesaryCreateAdapter = false; }else{ + isNecesaryCreateAdapter = true; //Call INCOMING - log("createNewAdapter() ----> call incoming: peersBeforeCall("+peersBeforeCall.size()+")"); + log("updatePeers() ----> call incoming: peersBeforeCall("+peersBeforeCall.size()+")"); linearParticipants.setVisibility(View.GONE); - //arrayList-> peersBeforeCall if(peersBeforeCall.size() < 7) { if(peersBeforeCall.size() != 0){ //1-6 peers bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); - if(peersBeforeCall.size() < 4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = ViewGroup.LayoutParams.MATCH_PARENT; - recyclerView.setLayoutParams(params); - - }else if(peersBeforeCall.size()==4){ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(360, outMetrics); - recyclerView.setLayoutParams(params); - + if(adapterGrid==null){ + adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); + recyclerView.setAdapter(adapterGrid); }else{ - ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - params.height = Util.scaleWidthPx(540, outMetrics); - recyclerView.setLayoutParams(params); - } - - if(peersBeforeCall.size() <= 3){ - recyclerView.setColumnWidth((int) widthScreenPX); - }else if((peersBeforeCall.size() > 3)&&(peersBeforeCall.size() <= 6)){ - recyclerView.setColumnWidth((int) widthScreenPX/2); - } - -// recyclerView.setAdapter(null); - if(adapter!=null){ - adapter.removeSurfacesView(); + adapterGrid.notifyDataSetChanged(); } - adapter = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); - recyclerView.setAdapter(adapter); - }else{ + }else{ recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); bigRecyclerView.setAdapter(null); @@ -2736,39 +2712,23 @@ public void createNewAdapter(boolean flag){ } }else{ - if((peersBeforeCall.size() == 7) && (recyclerView.isShown())){ - recyclerView.setAdapter(null); - recyclerView.setVisibility(GONE); - parentBigCameraGroupCall.setOnClickListener(this); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); + //7 + + recyclerView.setAdapter(null); + recyclerView.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(this); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + bigRecyclerView.setVisibility(View.VISIBLE); + if(adapterList==null){ bigRecyclerView.setVisibility(View.VISIBLE); - if(adapter!=null){ - adapter.removeSurfacesView(); - } - adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); - bigRecyclerView.setAdapter(adapter); - + adapterList = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); + bigRecyclerView.setAdapter(adapterList); }else{ - adapter.notifyDataSetChanged(); + adapterList.notifyDataSetChanged(); + } updateUserSelected(flag); - - -// //7 + peers -// recyclerView.setAdapter(null); -// recyclerView.setVisibility(GONE); -// -// parentBigCameraGroupCall.setOnClickListener(this); -// parentBigCameraGroupCall.setVisibility(View.VISIBLE); -// -// bigRecyclerView.setVisibility(View.VISIBLE); -// -//// bigRecyclerView.setAdapter(null); -// adapter = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); -// bigRecyclerView.setAdapter(adapter); -// updateUserSelected(flag); } } } @@ -2788,15 +2748,15 @@ public void updateUserSelected(boolean flag){ if(i==position){ if(!peersOnCall.get(position).hasGreenLayer()){ peersOnCall.get(position).setGreenLayer(true); - if(adapter!=null){ - adapter.changesInGreenLayer(position,null); + if(adapterList!=null){ + adapterList.changesInGreenLayer(position,null); } } }else{ if(peersOnCall.get(i).hasGreenLayer()){ peersOnCall.get(i).setGreenLayer(false); - if(adapter!=null){ - adapter.changesInGreenLayer(i,null); + if(adapterList!=null){ + adapterList.changesInGreenLayer(i,null); } } } @@ -2836,15 +2796,15 @@ public void updateUserSelected(boolean flag){ if(peersOnCall.get(i).getHandle().equals(peerSelected.getHandle())){ if(!peersOnCall.get(i).hasGreenLayer()){ peersOnCall.get(i).setGreenLayer(true); - if(adapter!=null){ - adapter.changesInGreenLayer(i,null); + if(adapterList!=null){ + adapterList.changesInGreenLayer(i,null); } } }else{ if(peersOnCall.get(i).hasGreenLayer()){ peersOnCall.get(i).setGreenLayer(false); - if(adapter!=null){ - adapter.changesInGreenLayer(i,null); + if(adapterList!=null){ + adapterList.changesInGreenLayer(i,null); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java index 4b853aabf55..9043ac55cb5 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java @@ -14,7 +14,7 @@ public class InfoPeerGroupCall { boolean greenLayer; GroupCallListener listener = null; - SurfaceView surfaceview; + SurfaceView surfaceview = null; public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, boolean greenLayer, GroupCallListener listener, SurfaceView surfaceview) { this.handle = handle; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 0994d213c5a..bcd110af754 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -50,6 +50,9 @@ public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { + public static final int ITEM_VIEW_TYPE_LIST = 0; + public static final int ITEM_VIEW_TYPE_GRID = 1; + Context context; MegaApiAndroid megaApi; MegaChatApiAndroid megaChatApi = null; @@ -60,6 +63,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress) { log("GroupCallAdapter(peers: "+peers.size()+")"); @@ -78,6 +97,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList= 4) && (numPeersOnCall < 7)){ + if(numPeersOnCall < 7){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; }else{ @@ -162,9 +180,10 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); holderGrid.greenLayer = (RelativeLayout) v.findViewById(R.id.green_layer); + holderGrid.surfaceMicroLayout = (RelativeLayout) v.findViewById(R.id.rl_surface_and_micro); - holderGrid.surfaceViewLayout = (RelativeLayout) v.findViewById(R.id.rl_surface); - holderGrid.surfaceViewLayout.removeAllViewsInLayout(); + holderGrid.parentSurfaceView = (RelativeLayout) v.findViewById(R.id.parent_surface_view); + holderGrid.parentSurfaceView.removeAllViewsInLayout(); holderGrid.avatarMicroLayout = (RelativeLayout) v.findViewById(R.id.layout_avatar_micro); @@ -174,44 +193,11 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.avatarLayout.setLayoutParams(layoutParams); holderGrid.microAvatar = (ImageView) v.findViewById(R.id.micro_avatar); - - holderGrid.microSurface = new ImageView(context); - holderGrid.microSurface.setVisibility(View.GONE); + holderGrid.microSurface = (ImageView) v.findViewById(R.id.micro_surface_view); holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image); holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter); - if(numPeersOnCall < 7){ - RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); - paramsMicroAvatar.height = Util.scaleWidthPx(24, outMetrics); - paramsMicroAvatar.width = Util.scaleWidthPx(24, outMetrics); - paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); - paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); - paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); - holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); - - ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); - paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); - paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); - holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); - - }else{ - RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holderGrid.microAvatar.getLayoutParams()); - paramsMicroAvatar.height = Util.scaleWidthPx(15, outMetrics); - paramsMicroAvatar.width = Util.scaleWidthPx(15, outMetrics); - paramsMicroAvatar.setMargins(0, 0, 0, 0); - paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); - paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); - holderGrid.microAvatar.setLayoutParams(paramsMicroAvatar); - - ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holderGrid.avatarImage.getLayoutParams(); - paramsAvatarImage.width = Util.scaleWidthPx(60, outMetrics); - paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); - holderGrid.avatarImage.setLayoutParams(paramsAvatarImage); - holderGrid.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); - } - v.setTag(holderGrid); return holderGrid; } @@ -247,126 +233,64 @@ public void onClick(View v) { holder.rlGeneral.setOnClickListener(null); } - - if(peer.isVideoOn()) { - log("Video ON - numPeersOnCall: "+numPeersOnCall); - if(numPeersOnCall < 7){ - if(numPeersOnCall == 1){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = maxScreenWidth; - layoutParamsSurface.height = maxScreenWidth; - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 2){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 3){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 4){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else{ - layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - - } - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - }else if(numPeersOnCall == 5){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - }else{ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = (maxScreenWidth/2); - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - }else if(numPeersOnCall == 6){ - //Surface Layout: - RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.surfaceViewLayout.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.surfaceViewLayout.setLayoutParams(layoutParamsSurface); - } - } holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); - //Clear surfaceViewLayout and remove listener - if(holder.surfaceViewLayout.getChildCount() != 0){ - holder.surfaceViewLayout.removeAllViewsInLayout(); - } + holder.surfaceMicroLayout.setVisibility(View.VISIBLE); - if(peer.getListener() != null){ - peer.setListener(null); + //Create Surface View + if(peer.getSurfaceview() == null){ + + holder.surfaceView = new SurfaceView(context); + holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); + holder.surfaceView.setZOrderMediaOverlay(true); + holder.localSurfaceHolder = holder.surfaceView.getHolder(); + holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); + holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); + peer.setSurfaceview(holder.surfaceView); + holder.parentSurfaceView.addView(holder.surfaceView); + if(numPeersOnCall < 7){ + holder.localRenderer.addListener(null); + }else{ + holder.localRenderer.addListener(this); + } + }else { } - //Create Surface View - holder.surfaceView = new SurfaceView(context); - holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - holder.surfaceView.setZOrderMediaOverlay(true); - holder.localSurfaceHolder = holder.surfaceView.getHolder(); - holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); - holder.surfaceViewLayout.addView(holder.surfaceView); - if(numPeersOnCall < 7){ - log("remove listener in local Renderer"); - holder.localRenderer.addListener(null); + //Listener + if(peer.getListener() == null){ + GroupCallListener listenerPeer = new GroupCallListener(context, holder); + peer.setListener(listenerPeer); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); + } else { + megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); + } }else{ - log("add listener in local Renderer"); - holder.localRenderer.addListener(this); } - //Update micro icon - holder.microSurface.setImageResource(R.drawable.ic_mic_off_contact); if(numPeersOnCall < 7){ - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams( Util.scaleWidthPx(24, outMetrics),Util.scaleWidthPx(24, outMetrics)); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); + paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); + paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); - + holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ - RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams( Util.scaleWidthPx(15, outMetrics),Util.scaleWidthPx(15, outMetrics)); + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); + paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); + paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); - holder.surfaceViewLayout.addView(holder.microSurface,paramsMicroSurface); + holder.microSurface.setLayoutParams(paramsMicroSurface); } + //Visibility of audio icon if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ @@ -376,108 +300,34 @@ public void onClick(View v) { holder.microSurface.setVisibility(View.GONE); } } - holder.surfaceViewLayout.setVisibility(View.VISIBLE); - //Green Layer - if(numPeersOnCall >= 7){ + //Visibility of green layer + if(numPeersOnCall < 7){ + holder.greenLayer.setVisibility(View.GONE); + }else{ if(peer.hasGreenLayer()){ holder.greenLayer.setVisibility(View.VISIBLE); }else{ holder.greenLayer.setVisibility(View.GONE); } - }else{ - holder.greenLayer.setVisibility(View.GONE); - } - - //Create listener - GroupCallListener listenerPeer = new GroupCallListener(context, holder); - peer.setListener(listenerPeer); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video ON-> addChatLocalVideoListener() "); - megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); - } else { - log("Video ON-> addChatRemoteVideoListener()"); - megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); } }else{ - log("Video OFF - numPeersOnCall: "+numPeersOnCall); - - if(numPeersOnCall < 7){ - if(numPeersOnCall == 1){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = maxScreenWidth; - layoutParamsAvatar.height = maxScreenWidth; - layoutParamsAvatar.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 2){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 3){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 4){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - - if((position < 2)){ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - }else{ - layoutParamsAvatar.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); - } - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - }else if(numPeersOnCall == 5){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - }else{ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = (maxScreenWidth/2); - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - - }else if(numPeersOnCall == 6){ - //Avatar Layout: - RelativeLayout.LayoutParams layoutParamsAvatar = (RelativeLayout.LayoutParams) holder.avatarMicroLayout.getLayoutParams(); - layoutParamsAvatar.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.height = Util.scaleWidthPx(180, outMetrics); - layoutParamsAvatar.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - holder.avatarMicroLayout.setLayoutParams(layoutParamsAvatar); - } + if(holder.surfaceView!=null){ + holder.surfaceView.setVisibility(GONE); } + peer.setSurfaceview(null); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); + }else{ + megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); + } + peer.setListener(null); + //Remove the surface view and the micro surface + holder.parentSurfaceView.removeAllViewsInLayout(); - holder.microSurface.setVisibility(View.GONE); - - //Clear surfaceViewLayout - holder.surfaceViewLayout.removeAllViewsInLayout(); - holder.surfaceViewLayout.setVisibility(View.GONE); + holder.surfaceMicroLayout.setVisibility(GONE); //Create the avatar if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -487,15 +337,48 @@ public void onClick(View v) { } //Update micro icon + if(numPeersOnCall < 7){ + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(24, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(24, outMetrics); + paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); + holder.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holder.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); + holder.avatarImage.setLayoutParams(paramsAvatarImage); + holder.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); + + }else{ + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(15, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(15, outMetrics); + paramsMicroAvatar.setMargins(0, 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); + holder.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holder.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(60, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); + holder.avatarImage.setLayoutParams(paramsAvatarImage); + holder.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); + } + if(peer.isAudioOn()){ holder.microAvatar.setVisibility(View.GONE); }else{ if(isCallInProgress){ holder.microAvatar.setVisibility(View.VISIBLE); + }else{ holder.microAvatar.setVisibility(View.GONE); } } + holder.avatarMicroLayout.setVisibility(View.VISIBLE); //Green Layer @@ -509,16 +392,6 @@ public void onClick(View v) { holder.greenLayer.setVisibility(View.GONE); } - //Remove listener - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - log("Video OFF-> removeChatMyVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); - peer.setListener(null); - }else{ - log("Video OFF-> removeChatVideoListener()"); - megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); - peer.setListener(null); - } } } @@ -726,12 +599,89 @@ public void removeSurfacesView(){ for(int i=0;i addChatLocalVideoListener() "); +// megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); +// } else { +// log("Video ON-> addChatRemoteVideoListener()"); +// megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); +// } +// }else{ +// log("++++ Listener-> height y widht 0"); +// +// peer.getListener().setHeight(0); +// peer.getListener().setWidth(0); +// } +// +// holder.surfaceViewLayout.setVisibility(View.VISIBLE); +// holder.avatarMicroLayout.setVisibility(View.GONE); +// +// }else{ +// log("++++++ changesInVideo() isVideoOff"); +// +// //Remove surface view +// holder.surfaceView.setVisibility(GONE); +// holder.surfaceViewLayout.removeAllViewsInLayout(); +// if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { +// log("Video OFF-> removeChatMyVideoListener()"); +// megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); +// }else{ +// log("Video OFF-> removeChatVideoListener()"); +// megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); +// } +// peer.setListener(null); +// holder.surfaceViewLayout.setVisibility(View.GONE); +// holder.avatarMicroLayout.setVisibility(View.VISIBLE); +// +// } +// }else{ +// log("++++++ changesInVideo() holder == NULL -> notifyItemChanged"); +// +// notifyItemChanged(position); +// } +// } public void changesInAudio(int position, ViewHolderGroupCall holder){ log("changesInAudio"); @@ -744,16 +694,56 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ if (peer == null){ return; } + if(peer.isAudioOn()){ holder.microAvatar.setVisibility(View.GONE); holder.microSurface.setVisibility(View.GONE); + }else{ if(!peer.isVideoOn()){ - holder.microAvatar.setVisibility(View.VISIBLE); holder.microSurface.setVisibility(View.GONE); + + holder.microAvatar.setVisibility(View.VISIBLE); + if(peers.size() < 7){ + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(24, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(24, outMetrics); + paramsMicroAvatar.setMargins(Util.scaleWidthPx(10, outMetrics), 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); + holder.microAvatar.setLayoutParams(paramsMicroAvatar); + }else{ + RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); + paramsMicroAvatar.height = Util.scaleWidthPx(15, outMetrics); + paramsMicroAvatar.width = Util.scaleWidthPx(15, outMetrics); + paramsMicroAvatar.setMargins(0, 0, 0, 0); + paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); + paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); + holder.microAvatar.setLayoutParams(paramsMicroAvatar); + } + }else{ - holder.microSurface.setVisibility(View.VISIBLE); holder.microAvatar.setVisibility(View.GONE); + + holder.microSurface.setVisibility(View.VISIBLE); + if(peers.size() < 7){ + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); + paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); + paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + holder.microSurface.setLayoutParams(paramsMicroSurface); + }else{ + RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); + paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); + paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); + paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + holder.microSurface.setLayoutParams(paramsMicroSurface); + } + } } }else{ @@ -813,4 +803,9 @@ private static void log(String log) { Util.log("GroupCallAdapter", log); } + public void removeAt(int position) { + peers.remove(position); + notifyItemRemoved(position); + notifyItemRangeChanged(position, peers.size()); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 7024499fb93..a1047107b56 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -30,10 +30,11 @@ - + + + + + + + + Date: Fri, 16 Nov 2018 14:37:03 +0100 Subject: [PATCH 100/247] Group calls UI --- .../lollipop/listeners/GroupCallListener.java | 30 ++-- .../megachat/calls/ChatCallActivity.java | 35 +++-- .../megachat/calls/InfoPeerGroupCall.java | 27 +--- .../calls/MegaSurfaceRendererGroup.java | 1 - .../chatAdapters/GroupCallAdapter.java | 140 +++++++++++------- 5 files changed, 136 insertions(+), 97 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index 5c9002964b4..196918b948c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -2,13 +2,16 @@ import android.content.Context; import android.graphics.Bitmap; +import android.graphics.PixelFormat; import android.util.Log; import android.view.SurfaceHolder; +import android.view.SurfaceView; import android.widget.RelativeLayout; import java.nio.ByteBuffer; import mega.privacy.android.app.R; +import mega.privacy.android.app.lollipop.megachat.calls.MegaSurfaceRendererGroup; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaChatApiJava; @@ -18,18 +21,19 @@ public class GroupCallListener implements MegaChatVideoListenerInterface { Context context; - GroupCallAdapter.ViewHolderGroupCall holder; - int width; int height; Bitmap bitmap; + SurfaceView surfaceView = null; + MegaSurfaceRendererGroup localRenderer = null; - public GroupCallListener(Context context, GroupCallAdapter.ViewHolderGroupCall holder) { + public GroupCallListener(Context context, SurfaceView surfaceView, Long peerHandle) { log("GroupCallListener"); this.context = context; - this.holder = holder; this.width = 0; this.height = 0; + this.surfaceView = surfaceView; + this.localRenderer = new MegaSurfaceRendererGroup(surfaceView, peerHandle); } @Override @@ -43,10 +47,12 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.height = height; - SurfaceHolder Sholder = holder.surfaceView.getHolder(); + SurfaceHolder Sholder = surfaceView.getHolder(); + Sholder.setFormat(PixelFormat.TRANSPARENT); + if (Sholder != null) { - int viewWidth = holder.surfaceView.getWidth(); - int viewHeight = holder.surfaceView.getHeight(); + int viewWidth = surfaceView.getWidth(); + int viewHeight = surfaceView.getHeight(); if ((viewWidth != 0) && (viewHeight != 0)) { int holderWidth = viewWidth < width ? viewWidth : width; @@ -56,7 +62,7 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderHeight = viewHeight; holderWidth = holderHeight * viewWidth / viewHeight; } - this.bitmap = holder.localRenderer.CreateBitmap(width, height); + this.bitmap = localRenderer.CreateBitmap(width, height); Sholder.setFixedSize(holderWidth, holderHeight); }else{ this.width = -1; @@ -70,11 +76,17 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app - holder.localRenderer.DrawBitmap(false); + localRenderer.DrawBitmap(false); } } + public SurfaceView getSurfaceView() { + return surfaceView; + } + public MegaSurfaceRendererGroup getLocalRenderer() { + return localRenderer; + } public void setWidth(int width) { this.width = width; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index ce370017b26..75efa9effa2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -337,7 +337,7 @@ public void updateScreenStatusInProgress(){ if(userHandle == megaChatApi.getMyUserHandle()){ log("updateScreenStatusInProgress()-peersOnCall.add("+megaChatApi.getMyFullname()+")-> ME"); - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); changes = true; }else{ @@ -345,7 +345,7 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress()-peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); changes = true; } @@ -363,14 +363,14 @@ public void updateScreenStatusInProgress(){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle == megaChatApi.getMyUserHandle()){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); changes = true; }else{ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); changes = true; }else{} @@ -824,7 +824,7 @@ protected void onCreate(Bundle savedInstanceState) { boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); peersBeforeCall.add(0, userPeer); changes = true; } @@ -873,7 +873,7 @@ protected void onCreate(Bundle savedInstanceState) { peersOnCall.clear(); } - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null, null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); updatePeers(true); @@ -1386,12 +1386,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } if(!peerContain){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); updatePeers(true); } }else{ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); updatePeers(true); } @@ -1499,9 +1499,14 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } } if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null, null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); - updatePeers(true); + if((peersOnCall.size()<7)&&(adapterGrid!= null)){ + adapterGrid.addAt(0); + }else{ + updatePeers(true); + } + } } @@ -1517,9 +1522,13 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i= 7){ if(peer.hasGreenLayer()){ holder.greenLayer.setVisibility(View.VISIBLE); @@ -804,8 +830,12 @@ private static void log(String log) { } public void removeAt(int position) { - peers.remove(position); +// peers.remove(position); notifyItemRemoved(position); notifyItemRangeChanged(position, peers.size()); } + public void addAt(int position) { + notifyItemInserted(position); + notifyItemRangeChanged(position, peers.size()); + } } \ No newline at end of file From aae2c32e185b17579de55cc7d4659f11d001c5cf Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sat, 17 Nov 2018 17:28:46 +0100 Subject: [PATCH 101/247] Group Calls UI --- .../megachat/ChatActivityLollipop.java | 69 ++++----- .../megachat/calls/ChatCallActivity.java | 141 +++++++++++++----- .../chatAdapters/GroupCallAdapter.java | 89 +++++------ 3 files changed, 170 insertions(+), 129 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index cc113bae7b6..3f2b306298c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2570,52 +2570,45 @@ public void run() { if(fileStorageLayout.isShown()){ hideFileStorageSection(); }else{ - if(emojiKeyboard.getLetterKeyboardShown()){ - emojiKeyboard.hideBothKeyboard(this); - handlerEmojiKeyboard.postDelayed(new Runnable() { - @Override - public void run() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - boolean hasStoragePermission = (ContextCompat.checkSelfPermission(chatActivity, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); - if (!hasStoragePermission) { - ActivityCompat.requestPermissions(chatActivity,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},Constants.REQUEST_READ_STORAGE); - }else{ + if(emojiKeyboard!=null){ + + if(emojiKeyboard.getLetterKeyboardShown()){ + emojiKeyboard.hideBothKeyboard(this); + handlerEmojiKeyboard.postDelayed(new Runnable() { + @Override + public void run() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + boolean hasStoragePermission = (ContextCompat.checkSelfPermission(chatActivity, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); + if (!hasStoragePermission) { + ActivityCompat.requestPermissions(chatActivity,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},Constants.REQUEST_READ_STORAGE); + }else{ + chatActivity.attachFromFileStorage(); + } + } + else{ chatActivity.attachFromFileStorage(); } } - else{ - chatActivity.attachFromFileStorage(); - } + },250); + }else{ + if(emojiKeyboard!=null){ + emojiKeyboard.hideBothKeyboard(this); } - },250); - }else{ - emojiKeyboard.hideBothKeyboard(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); - if (!hasStoragePermission) { - ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},Constants.REQUEST_READ_STORAGE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); + if (!hasStoragePermission) { + ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},Constants.REQUEST_READ_STORAGE); - }else{ + }else{ + this.attachFromFileStorage(); + } + } + else{ this.attachFromFileStorage(); } } - else{ - this.attachFromFileStorage(); - } } -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { -// boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); -// if (!hasStoragePermission) { -// ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},Constants.REQUEST_READ_STORAGE); -// -// }else{ -// this.attachFromFileStorage(); -// } -// } -// else{ -// this.attachFromFileStorage(); -// } } break; } @@ -5990,7 +5983,9 @@ protected void onStop() { @Override protected void onDestroy(){ - emojiKeyboard.hideBothKeyboard(this); + if(emojiKeyboard!=null){ + emojiKeyboard.hideBothKeyboard(this); + } if (handlerEmojiKeyboard != null){ handlerEmojiKeyboard.removeCallbacksAndMessages(null); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 75efa9effa2..093dc4dc1d4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -334,22 +334,21 @@ public void updateScreenStatusInProgress(){ } } if (!peerContain) { - if(userHandle == megaChatApi.getMyUserHandle()){ - log("updateScreenStatusInProgress()-peersOnCall.add("+megaChatApi.getMyFullname()+")-> ME"); - - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - peersOnCall.add(myPeer); - changes = true; - }else{ + if(userHandle != megaChatApi.getMyUserHandle()){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("updateScreenStatusInProgress()-peersOnCall.add("+chat.getPeerFullnameByHandle(userHandle)+")"); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); changes = true; } } + }else{ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + peersOnCall.add(myPeer); + changes = true; + + } } } @@ -362,19 +361,25 @@ public void updateScreenStatusInProgress(){ boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); - if(userHandle == megaChatApi.getMyUserHandle()){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - peersOnCall.add(myPeer); - changes = true; - }else{ + if(userHandle != megaChatApi.getMyUserHandle()){ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("***** "+userPeer.getName()+"is adding updateScreenStatusInProgress 2º"); + peersOnCall.add(0, userPeer); changes = true; }else{} } + }else{ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("***** Me "+megaChatApi.getMyFullname()+"is adding updateScreenStatusInProgress 3º"); + + peersOnCall.add(myPeer); + changes = true; + } } @@ -825,7 +830,7 @@ protected void onCreate(Bundle savedInstanceState) { for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); - peersBeforeCall.add(0, userPeer); + peersBeforeCall.add(userPeer); changes = true; } if(changes){ @@ -874,6 +879,8 @@ protected void onCreate(Bundle savedInstanceState) { } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("***** Me "+myPeer.getName()+"is adding Outgoing"); + peersOnCall.add(myPeer); updatePeers(true); @@ -1219,7 +1226,8 @@ public void onDestroy(){ peerSelected = null; isManualMode = false; - + recyclerView.setAdapter(null); + bigRecyclerView.setAdapter(null); peersOnCall.clear(); peersBeforeCall.clear(); stopAudioSignals(); @@ -1387,11 +1395,15 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("***** Me "+myPeer.getName()+"is adding updateScreenStatusInProgress"); + peersOnCall.add(myPeer); updatePeers(true); } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("***** Me "+myPeer.getName()+"is adding updateScreenStatusInProgress"); + peersOnCall.add(myPeer); updatePeers(true); } @@ -1501,11 +1513,12 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); - if((peersOnCall.size()<7)&&(adapterGrid!= null)){ - adapterGrid.addAt(0); - }else{ + log("****** add "+userPeer.getName()+" is adding in the call (SESSION_STATUS_IN_PROGRESS)"); +// if((peersOnCall.size()<7)&&(adapterGrid!= null)){ +// adapterGrid.addAt(0); +// }else{ updatePeers(true); - } +// } } @@ -1522,6 +1535,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i IN PROGRESS: peersOnCall("+peersOnCall.size()+")"); //Call IN PROGRESS updateSubtitleToolbar(); if(peersOnCall.size() < 7){ //1-6 if(peersOnCall.size()!=0){ + + if(adapterList!=null){ + adapterList =null; + } bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(null); @@ -2642,6 +2677,7 @@ public void updatePeers(boolean flag){ recyclerView.setVisibility(View.VISIBLE); if(adapterGrid == null){ + recyclerView.setAdapter(null); adapterGrid = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); recyclerView.setAdapter(adapterGrid); }else{ @@ -2655,6 +2691,12 @@ public void updatePeers(boolean flag){ } }else{ + if(adapterGrid != null){ + adapterGrid = null; + } + if(adapterList!=null){ + adapterList =null; + } recyclerView.setAdapter(null); recyclerView.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); @@ -2664,14 +2706,18 @@ public void updatePeers(boolean flag){ } }else{ + //7 + + if(adapterGrid != null){ + adapterGrid = null; + } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); - if(adapterList==null){ + if(adapterList == null){ adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); bigRecyclerView.setAdapter(adapterList); }else{ @@ -2685,6 +2731,7 @@ public void updatePeers(boolean flag){ } updateUserSelected(flag); } + isNecesaryCreateAdapter = false; }else{ @@ -2697,21 +2744,32 @@ public void updatePeers(boolean flag){ if(peersBeforeCall.size() < 7) { if(peersBeforeCall.size() != 0){ - //1-6 peers + //1-6 + + if(adapterList != null){ + adapterList = null; + } bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); - - if(adapterGrid==null){ + if(adapterGrid == null){ adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapterGrid); }else{ adapterGrid.notifyDataSetChanged(); } + }else{ + + if(adapterGrid != null){ + adapterGrid = null; + } + if(adapterList != null){ + adapterList = null; + } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); bigRecyclerView.setAdapter(null); @@ -2723,6 +2781,9 @@ public void updatePeers(boolean flag){ }else{ //7 + + if(adapterGrid != null){ + adapterGrid = null; + } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(this); @@ -2730,7 +2791,7 @@ public void updatePeers(boolean flag){ bigRecyclerView.setVisibility(View.VISIBLE); if(adapterList==null){ - bigRecyclerView.setVisibility(View.VISIBLE); + bigRecyclerView.setAdapter(null); adapterList = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); bigRecyclerView.setAdapter(adapterList); }else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7b1caf34ddc..25edcde324d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -143,7 +143,7 @@ public ViewHolderGroupCallGrid(View v) { ViewHolderGroupCallGrid holderGrid = null; @Override public GroupCallAdapter.ViewHolderGroupCall onCreateViewHolder(ViewGroup parent, int viewType) { - log("**** onCreateViewHolder()"); + log("onCreateViewHolder()"); display = ((ChatCallActivity) context).getWindowManager().getDefaultDisplay(); outMetrics = new DisplayMetrics(); @@ -180,6 +180,8 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.surfaceMicroLayout = (RelativeLayout) v.findViewById(R.id.rl_surface_and_micro); holderGrid.parentSurfaceView = (RelativeLayout) v.findViewById(R.id.parent_surface_view); + holderGrid.parentSurfaceView.removeAllViews(); + holderGrid.parentSurfaceView.removeAllViewsInLayout(); holderGrid.avatarMicroLayout = (RelativeLayout) v.findViewById(R.id.layout_avatar_micro); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); @@ -228,13 +230,13 @@ public void onClick(View v) { } if(peer.isVideoOn()) { - log("**** Peer: "+peer.getName()+", VIDEO ON"); + log("***** "+peer.getName()+" VIDEO ON"); holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); - - holder.parentSurfaceView.removeAllViewsInLayout(); - holder.parentSurfaceView.removeAllViews(); + if(holder.parentSurfaceView.getChildCount()!=0){ + holder.parentSurfaceView.removeAllViewsInLayout(); + } holder.surfaceMicroLayout.setVisibility(GONE); //Listener && SurfaceView @@ -256,53 +258,27 @@ public void onClick(View v) { peer.getListener().getLocalRenderer().addListener(this); } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - }else{ - if(holder.parentSurfaceView.getChildCount()!=0){ - log("******** "+peer.getName()+"has "+holder.parentSurfaceView.getChildCount()+" childs"); - }else{ - log("******** "+peer.getName()+"has not childs"); + }else{ + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); } - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + if(holder.parentSurfaceView.getChildCount() == 0){ + if(peer.getListener().getSurfaceView().getParent()!=null){ + if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeAllViewsInLayout(); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + }else{ } + }else{ + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + } + }else{ } } - holder.surfaceMicroLayout.setVisibility(View.VISIBLE); - - // public MegaSurfaceRendererGroup localRenderer; -// SurfaceHolder localSurfaceHolder; -// //Create Surface View -// if(peer.getSurfaceview() == null){ -// -// holder.surfaceView = new SurfaceView(context); -// holder.surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); -// holder.surfaceView.setZOrderMediaOverlay(true); -// holder.localSurfaceHolder = holder.surfaceView.getHolder(); -// holder.localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); -// holder.localRenderer = new MegaSurfaceRendererGroup(holder.surfaceView, peer.getHandle()); -// peer.setSurfaceview(holder.surfaceView); -// holder.parentSurfaceView.addView(holder.surfaceView); -// if(numPeersOnCall < 7){ -// holder.localRenderer.addListener(null); -// }else{ -// holder.localRenderer.addListener(this); -// } -// }else { -// } - - //Listener -// if(peer.getListener() == null){ -// GroupCallListener listenerPeer = new GroupCallListener(context, peer.getSurfaceview(), peer.getLocalRenderer()); -// peer.setListener(listenerPeer); -// if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { -// megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); -// } else { -// megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); -// } -// }else{ -// } - //Audio icon: if(numPeersOnCall < 7){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); @@ -343,22 +319,32 @@ public void onClick(View v) { } }else{ - log("**** Peer: "+peer.getName()+", VIDEO OFF"); + log("***** "+peer.getName()+" VIDEO OFF"); //Remove Surface view && Listener: - holder.parentSurfaceView.removeAllViewsInLayout(); holder.surfaceMicroLayout.setVisibility(GONE); holder.avatarMicroLayout.setVisibility(View.VISIBLE); - if(peer.getListener()!=null){ + if(peer.getListener() != null){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); }else{ megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); } + + if(holder.parentSurfaceView.getChildCount() == 0){ + if(peer.getListener().getSurfaceView().getParent()!=null){ + if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeAllViewsInLayout(); + }else{ } + }else{ } + }else{ + holder.parentSurfaceView.removeAllViews(); + holder.parentSurfaceView.removeAllViewsInLayout(); + } peer.setListener(null); - } + }else{ } //Create Avatar: if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -417,7 +403,6 @@ public void onClick(View v) { }else{ holder.greenLayer.setVisibility(View.GONE); } - } } From 150dcd18b859e95b0f0f636fd31e4fca98d64b47 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 18 Nov 2018 02:29:21 +0100 Subject: [PATCH 102/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 84 ++++--- .../chatAdapters/GroupCallAdapter.java | 227 +++++++++++++++--- .../main/res/layout/activity_calls_chat.xml | 44 +++- .../res/layout/item_camera_group_call.xml | 15 +- 4 files changed, 280 insertions(+), 90 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 093dc4dc1d4..5411b904b4a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -347,8 +347,6 @@ public void updateScreenStatusInProgress(){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); peersOnCall.add(myPeer); changes = true; - - } } } @@ -362,25 +360,18 @@ public void updateScreenStatusInProgress(){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle != megaChatApi.getMyUserHandle()){ - MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("***** "+userPeer.getName()+"is adding updateScreenStatusInProgress 2º"); - peersOnCall.add(0, userPeer); changes = true; - }else{} + } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("***** Me "+megaChatApi.getMyFullname()+"is adding updateScreenStatusInProgress 3º"); - peersOnCall.add(myPeer); changes = true; - - } } if(changes){ @@ -647,9 +638,9 @@ protected void onCreate(Bundle savedInstanceState) { //Recycler View for 1-6 peers recyclerView = (CustomizedGridCallRecyclerView) findViewById(R.id.recycler_view_cameras); recyclerView.setPadding(0, 0, 0, 0); - recyclerView.setClipToPadding(false); - recyclerView.setHasFixedSize(true); - recyclerView.setColumnWidth((int) widthScreenPX/2); +// recyclerView.setClipToPadding(false); +// recyclerView.setHasFixedSize(true); + recyclerView.setColumnWidth((int) widthScreenPX); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setVisibility(GONE); @@ -879,8 +870,6 @@ protected void onCreate(Bundle savedInstanceState) { } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("***** Me "+myPeer.getName()+"is adding Outgoing"); - peersOnCall.add(myPeer); updatePeers(true); @@ -1395,15 +1384,11 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("***** Me "+myPeer.getName()+"is adding updateScreenStatusInProgress"); - peersOnCall.add(myPeer); updatePeers(true); } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("***** Me "+myPeer.getName()+"is adding updateScreenStatusInProgress"); - peersOnCall.add(myPeer); updatePeers(true); } @@ -1513,15 +1498,21 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); - log("****** add "+userPeer.getName()+" is adding in the call (SESSION_STATUS_IN_PROGRESS)"); -// if((peersOnCall.size()<7)&&(adapterGrid!= null)){ -// adapterGrid.addAt(0); -// }else{ + log("onChatCallUpdate()-USER INPROGRESS -> "+userPeer.getName()+" added"); + if((peersOnCall.size()<7)&&(adapterGrid!= null)){ + log(" onChatCallUpdate()-USER INPROGRESS -> addAt (0)"); + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemInserted(0); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + }else{ + log("onChatCallUpdate()-USER INPROGRESS -> updatePeers ("+peersOnCall.size()+")"); updatePeers(true); -// } - + } } - } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ @@ -1535,12 +1526,19 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); if((peersOnCall.size()<6)&&(adapterGrid!=null)){ - adapterGrid.removeAt(i); + log("onChatCallUpdate()-USER DESTROYED -> removeAt ("+i+")"); + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); }else{ + log("onChatCallUpdate()-USER DESTROYED -> updatePeers ("+peersOnCall.size()+")"); updatePeers(true); } break; @@ -1608,9 +1606,11 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ long userHandle = call.getParticipants().get(i); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); peersBeforeCall.add(userPeer); + log("onChatCallUpdate()-USER COMPOSITION -> "+userPeer.getName()+" added"); changes = true; } if(changes){ + log("onChatCallUpdate()-USER COMPOSITION -> updatePeers ("+peersOnCall.size()+")"); updatePeers(false); } } @@ -2053,7 +2053,7 @@ public void updateLocalVideoStatus(){ log("activate Local Video for "+peersOnCall.get(position).getName()); item.setVideoOn(true); if(peersOnCall.size()<7){ - log("**** updateLocalVideo "+peersOnCall.get(position).getName()+" Conencted video"); + log("updateLocalVideo "+peersOnCall.get(position).getName()+" Conencted video"); adapterGrid.notifyItemChanged(position); }else{ @@ -2074,7 +2074,7 @@ public void updateLocalVideoStatus(){ log("remove Local Video fot "+peersOnCall.get(position).getName()); item.setVideoOn(false); if(peersOnCall.size()<7){ - log("**** updateLocalVideo "+peersOnCall.get(position).getName()+" Disconnected video"); + log("updateLocalVideo "+peersOnCall.get(position).getName()+" Disconnected video"); adapterGrid.notifyItemChanged(position); }else{ @@ -2175,7 +2175,6 @@ public void updateLocalAudioStatus(){ if(!peersOnCall.get(position).isAudioOn()){ peersOnCall.get(position).setAudioOn(true); if(peersOnCall.size()<7){ - log("**** updateLocalAudio "+peersOnCall.get(position)+" Connected audio"); adapterGrid.changesInAudio(position,null); }else{ adapterList.changesInAudio(position,null); @@ -2191,7 +2190,6 @@ public void updateLocalAudioStatus(){ if(peersOnCall.get(position).isAudioOn()){ peersOnCall.get(position).setAudioOn(false); if(peersOnCall.size()<7){ - log("**** updateLocalAudio "+peersOnCall.get(position).getName()+" Disconnected audio"); adapterGrid.changesInAudio(position,null); }else{ @@ -2231,7 +2229,7 @@ public void updateRemoteVideoStatus(long userHandle){ peersOnCall.get(i).setVideoOn(true); updateSubtitleToolbar(); if(peersOnCall.size()<7){ - log("**** updateRemoteVideo "+peersOnCall.get(i).getName()+" Connected video"); + log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Connected video"); adapterGrid.notifyItemChanged(i); }else{ @@ -2267,7 +2265,7 @@ public void updateRemoteVideoStatus(long userHandle){ updateSubtitleToolbar(); if(peersOnCall.size()<7){ - log("**** updateRemoteVideo "+peersOnCall.get(i).getName()+" Disconnected video"); + log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Disconnected video"); adapterGrid.notifyItemChanged(i); }else{ @@ -2383,8 +2381,6 @@ public void updateRemoteAudioStatus(long userHandle){ peersOnCall.get(i).setAudioOn(true); if(peersOnCall.size()<7){ - log("**** updateRemoteAudio "+peersOnCall.get(i).getName()+" Connected audio"); - adapterGrid.changesInAudio(i,null); }else{ adapterList.changesInAudio(i,null); @@ -2409,7 +2405,6 @@ public void updateRemoteAudioStatus(long userHandle){ peersOnCall.get(i).setAudioOn(false); if(peersOnCall.size()<7){ - log("**** updateRemoteAudio "+peersOnCall.get(i).getName()+" Disconnected audio"); adapterGrid.changesInAudio(i,null); }else{ @@ -2658,6 +2653,7 @@ public void updateSubtitleToolbar(){ } public void updatePeers(boolean flag){ + log("updatePeers()"); if(flag){ @@ -2666,7 +2662,6 @@ public void updatePeers(boolean flag){ if(peersOnCall.size() < 7){ //1-6 if(peersOnCall.size()!=0){ - if(adapterList!=null){ adapterList =null; } @@ -2676,6 +2671,11 @@ public void updatePeers(boolean flag){ parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } if(adapterGrid == null){ recyclerView.setAdapter(null); adapterGrid = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag); @@ -2717,6 +2717,7 @@ public void updatePeers(boolean flag){ parentBigCameraGroupCall.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); + if(adapterList == null){ adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); bigRecyclerView.setAdapter(adapterList); @@ -2755,6 +2756,11 @@ public void updatePeers(boolean flag){ parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } if(adapterGrid == null){ adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); recyclerView.setAdapter(adapterGrid); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 25edcde324d..57444663772 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -13,6 +13,7 @@ import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Display; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -158,19 +159,56 @@ public ViewHolderGroupCallGrid(View v) { maxScreenWidth = parent.getMeasuredWidth(); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); - int numPeersOnCall = getItemCount(); +// int numPeersOnCall = getItemCount(); +// CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); + +// if(numPeersOnCall == 1){ +// lp.height = maxScreenHeight; +// lp.width = maxScreenWidth; +// }else if(numPeersOnCall == 2){ +// lp.height = maxScreenHeight/numPeersOnCall; +// lp.width = maxScreenWidth; +// }else if(numPeersOnCall == 3){ +// lp.height = maxScreenHeight/numPeersOnCall; +// lp.width = maxScreenWidth; +// }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ +// lp.height = Util.scaleWidthPx(180, outMetrics); +// lp.width = maxScreenWidth/2; +// }else{ +// +// lp.height = Util.scaleWidthPx(90, outMetrics); +// lp.width = Util.scaleWidthPx(90, outMetrics); +// } +// v.setLayoutParams(lp); - CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - if(numPeersOnCall < 7){ - lp.height = Util.scaleWidthPx(180, outMetrics); - lp.width = maxScreenWidth/2; - }else{ - lp.height = Util.scaleWidthPx(90, outMetrics); - lp.width = Util.scaleWidthPx(90, outMetrics); - } - v.setLayoutParams(lp); +// if(numPeersOnCall < 4) { +// lp.height = maxScreenHeight/numPeersOnCall; +// lp.width = maxScreenWidth; +// +// }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ +// lp.height = Util.scaleWidthPx(180, outMetrics); +// lp.width = maxScreenWidth/2; +// }else{ +// lp.height = Util.scaleWidthPx(90, outMetrics); +// lp.width = Util.scaleWidthPx(90, outMetrics); +// } + + + +// CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); +// +// if(numPeersOnCall < 7){ +// lp.height = Util.scaleWidthPx(180, outMetrics); +//// lp.width = maxScreenWidth/2; +// lp.width = Util.scaleWidthPx(180, outMetrics); +// }else{ +// lp.height = Util.scaleWidthPx(90, outMetrics); +// lp.width = Util.scaleWidthPx(90, outMetrics); +// } +// +// v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); @@ -206,7 +244,7 @@ public void onBindViewHolder(ViewHolderGroupCall holder, int position) { } public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final int position){ - log("**** onBindViewHolderGrid() - position: "+position); + log("onBindViewHolderGrid() - position: "+position); final InfoPeerGroupCall peer = getNodeAt(position); if (peer == null){ @@ -214,6 +252,22 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in } int numPeersOnCall = getItemCount(); + + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); + + if(numPeersOnCall < 4){ + lp.height = maxScreenHeight/numPeersOnCall; + lp.width = maxScreenWidth; + }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ + lp.height = Util.scaleWidthPx(180, outMetrics); + lp.width = maxScreenWidth/2; + }else{ + lp.height = Util.scaleWidthPx(90, outMetrics); + lp.width = Util.scaleWidthPx(90, outMetrics); + } + holder.rlGeneral.setLayoutParams(lp); + holder.rlGeneral.setGravity(RelativeLayout.CENTER_HORIZONTAL); + if(isCallInProgress){ holder.rlGeneral.setOnClickListener(new View.OnClickListener() { @Override @@ -230,17 +284,96 @@ public void onClick(View v) { } if(peer.isVideoOn()) { - log("***** "+peer.getName()+" VIDEO ON"); holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); - if(holder.parentSurfaceView.getChildCount()!=0){ - holder.parentSurfaceView.removeAllViewsInLayout(); + if(numPeersOnCall == 1){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = maxScreenWidth; + layoutParamsSurface.height = maxScreenWidth; + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 2){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 3){ + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 4){ + + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + if((position < 2)){ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + }else{ + layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); + + } + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); + + }else if(numPeersOnCall == 5){ + + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); + + if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + }else{ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = (maxScreenWidth/2); + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + + }else if(numPeersOnCall == 6){ + + //Surface Layout: + RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); + layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); } - holder.surfaceMicroLayout.setVisibility(GONE); + + + +// if(holder.parentSurfaceView.getChildCount()!=0){ +// holder.parentSurfaceView.removeAllViewsInLayout(); +// } +// holder.surfaceMicroLayout.setVisibility(GONE); //Listener && SurfaceView if(peer.getListener() == null){ + SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); surfaceView.setZOrderMediaOverlay(true); @@ -258,35 +391,70 @@ public void onClick(View v) { peer.getListener().getLocalRenderer().addListener(this); } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); }else{ - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + +// if(peer.getListener().getHeight() != 0){ +// peer.getListener().setHeight(0); +// } +// if(peer.getListener().getWidth() != 0){ +// peer.getListener().setWidth(0); +// } if(holder.parentSurfaceView.getChildCount() == 0){ if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeAllViewsInLayout(); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - }else{ } + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + + }else{ + + } }else{ + + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + } - }else{ } + }else{ + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + + +// if(peer.getListener().getHeight() != 0){ +// peer.getListener().setHeight(0); +// } +// if(peer.getListener().getWidth() != 0){ +// peer.getListener().setWidth(0); +// } +// holder.parentSurfaceView.setGravity(RelativeLayout.CENTER_HORIZONTAL); + } +// peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + } holder.surfaceMicroLayout.setVisibility(View.VISIBLE); + //Audio icon: if(numPeersOnCall < 7){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); @@ -319,7 +487,6 @@ public void onClick(View v) { } }else{ - log("***** "+peer.getName()+" VIDEO OFF"); //Remove Surface view && Listener: holder.surfaceMicroLayout.setVisibility(GONE); @@ -814,13 +981,5 @@ private static void log(String log) { Util.log("GroupCallAdapter", log); } - public void removeAt(int position) { -// peers.remove(position); - notifyItemRemoved(position); - notifyItemRangeChanged(position, peers.size()); - } - public void addAt(int position) { - notifyItemInserted(position); - notifyItemRangeChanged(position, peers.size()); - } + } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index a1047107b56..58e196a4d67 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -27,18 +27,42 @@ android:layout_height="match_parent" android:background="@color/black"> - - + + + + + + + + + + + + + + android:gravity="center" + android:orientation="vertical"> + + + + + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/orange"> @@ -19,9 +19,10 @@ android:id="@+id/parent_surface_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="center" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" android:layout_centerInParent="true" - android:background="@android:color/transparent"> + android:background="@android:color/holo_red_dark"> Date: Sun, 18 Nov 2018 15:14:57 +0100 Subject: [PATCH 103/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 10 ++- .../chatAdapters/GroupCallAdapter.java | 77 ++++++------------- .../res/layout/item_camera_group_call.xml | 4 +- 3 files changed, 31 insertions(+), 60 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 5411b904b4a..44d78358a0d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1508,6 +1508,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } adapterGrid.notifyItemInserted(0); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + + updateSubtitleToolbar(); + }else{ log("onChatCallUpdate()-USER INPROGRESS -> updatePeers ("+peersOnCall.size()+")"); updatePeers(true); @@ -1532,11 +1535,14 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("onChatCallUpdate()-USER DESTROYED -> removeAt ("+i+")"); if(peersOnCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); } - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); }else{ log("onChatCallUpdate()-USER DESTROYED -> updatePeers ("+peersOnCall.size()+")"); updatePeers(true); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 57444663772..7b1d3dbbcab 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -159,56 +159,6 @@ public ViewHolderGroupCallGrid(View v) { maxScreenWidth = parent.getMeasuredWidth(); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); -// int numPeersOnCall = getItemCount(); -// CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); - -// if(numPeersOnCall == 1){ -// lp.height = maxScreenHeight; -// lp.width = maxScreenWidth; -// }else if(numPeersOnCall == 2){ -// lp.height = maxScreenHeight/numPeersOnCall; -// lp.width = maxScreenWidth; -// }else if(numPeersOnCall == 3){ -// lp.height = maxScreenHeight/numPeersOnCall; -// lp.width = maxScreenWidth; -// }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ -// lp.height = Util.scaleWidthPx(180, outMetrics); -// lp.width = maxScreenWidth/2; -// }else{ -// -// lp.height = Util.scaleWidthPx(90, outMetrics); -// lp.width = Util.scaleWidthPx(90, outMetrics); -// } -// v.setLayoutParams(lp); - - - -// if(numPeersOnCall < 4) { -// lp.height = maxScreenHeight/numPeersOnCall; -// lp.width = maxScreenWidth; -// -// }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ -// lp.height = Util.scaleWidthPx(180, outMetrics); -// lp.width = maxScreenWidth/2; -// }else{ -// lp.height = Util.scaleWidthPx(90, outMetrics); -// lp.width = Util.scaleWidthPx(90, outMetrics); -// } - - - -// CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) v.getLayoutParams(); -// -// if(numPeersOnCall < 7){ -// lp.height = Util.scaleWidthPx(180, outMetrics); -//// lp.width = maxScreenWidth/2; -// lp.width = Util.scaleWidthPx(180, outMetrics); -// }else{ -// lp.height = Util.scaleWidthPx(90, outMetrics); -// lp.width = Util.scaleWidthPx(90, outMetrics); -// } -// -// v.setLayoutParams(lp); holderGrid = new ViewHolderGroupCallGrid(v); @@ -284,10 +234,12 @@ public void onClick(View v) { } if(peer.isVideoOn()) { + log(peer.getName()+" VIDEO ON"); holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); if(numPeersOnCall == 1){ + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = maxScreenWidth; @@ -298,6 +250,7 @@ public void onClick(View v) { holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 2){ + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); @@ -308,6 +261,7 @@ public void onClick(View v) { holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); }else if(numPeersOnCall == 3){ + //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); @@ -324,6 +278,8 @@ public void onClick(View v) { layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); + layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); if((position < 2)){ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); @@ -454,14 +410,12 @@ public void onClick(View v) { paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); holder.microSurface.setLayoutParams(paramsMicroSurface); } @@ -487,12 +441,13 @@ public void onClick(View v) { } }else{ + log(peer.getName()+" VIDEO OFF"); //Remove Surface view && Listener: holder.surfaceMicroLayout.setVisibility(GONE); - holder.avatarMicroLayout.setVisibility(View.VISIBLE); + if(peer.getListener() != null){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); @@ -882,6 +837,7 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ holder.microSurface.setVisibility(View.GONE); holder.microAvatar.setVisibility(View.VISIBLE); + //Micro icon: if(peers.size() < 7){ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); paramsMicroAvatar.height = Util.scaleWidthPx(24, outMetrics); @@ -890,6 +846,12 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); holder.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holder.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(88, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(88, outMetrics); + holder.avatarImage.setLayoutParams(paramsAvatarImage); + holder.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50f); }else{ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); paramsMicroAvatar.height = Util.scaleWidthPx(15, outMetrics); @@ -898,18 +860,24 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ paramsMicroAvatar.addRule(RelativeLayout.RIGHT_OF, R.id.avatar_rl); paramsMicroAvatar.addRule(RelativeLayout.ALIGN_TOP, R.id.avatar_rl); holder.microAvatar.setLayoutParams(paramsMicroAvatar); + + ViewGroup.LayoutParams paramsAvatarImage = (ViewGroup.LayoutParams) holder.avatarImage.getLayoutParams(); + paramsAvatarImage.width = Util.scaleWidthPx(60, outMetrics); + paramsAvatarImage.height = Util.scaleWidthPx(60, outMetrics); + holder.avatarImage.setLayoutParams(paramsAvatarImage); + holder.avatarInitialLetter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30f); } }else{ holder.microAvatar.setVisibility(View.GONE); holder.microSurface.setVisibility(View.VISIBLE); + //Audio icon: if(peers.size() < 7){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ @@ -917,7 +885,6 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); holder.microSurface.setLayoutParams(paramsMicroSurface); } diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 071abddfa3c..24b133e9e01 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -28,8 +28,6 @@ android:id="@+id/micro_surface_view" android:layout_width="24dp" android:layout_height="24dp" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" android:background="@android:color/transparent" android:visibility="gone" android:src="@drawable/ic_mic_off_contact"/> @@ -43,7 +41,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" - android:background="@android:color/transparent" + android:background="@android:color/holo_green_dark" android:visibility="gone"> From a67076e9502784635da0458a4529b14a6e8b77c8 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 18 Nov 2018 15:57:44 +0100 Subject: [PATCH 104/247] Group calls UI --- .../chatAdapters/GroupCallAdapter.java | 38 ++++++++++--------- .../main/res/layout/activity_calls_chat.xml | 4 +- .../res/layout/item_camera_group_call.xml | 8 ++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7b1d3dbbcab..db9409183d1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -9,6 +9,7 @@ import android.graphics.Paint; import android.graphics.PixelFormat; import android.support.v4.content.ContextCompat; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.util.TypedValue; @@ -163,7 +164,8 @@ public ViewHolderGroupCallGrid(View v) { holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); - +// holderGrid.rlGeneral.setGravity(RelativeLayout.CENTER_HORIZONTAL); +// holderGrid.rlGeneral.setGravity(RelativeLayout.CENTER_VERTICAL); holderGrid.greenLayer = (RelativeLayout) v.findViewById(R.id.green_layer); holderGrid.surfaceMicroLayout = (RelativeLayout) v.findViewById(R.id.rl_surface_and_micro); @@ -216,7 +218,9 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in lp.width = Util.scaleWidthPx(90, outMetrics); } holder.rlGeneral.setLayoutParams(lp); - holder.rlGeneral.setGravity(RelativeLayout.CENTER_HORIZONTAL); +// holder.rlGeneral.setGravity(RelativeLayout.CENTER_HORIZONTAL); +// holder.rlGeneral.setGravity(RelativeLayout.CENTER_VERTICAL); + if(isCallInProgress){ holder.rlGeneral.setOnClickListener(new View.OnClickListener() { @@ -245,7 +249,6 @@ public void onClick(View v) { layoutParamsSurface.width = maxScreenWidth; layoutParamsSurface.height = maxScreenWidth; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE); - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -255,7 +258,6 @@ public void onClick(View v) { RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -266,7 +268,6 @@ public void onClick(View v) { RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -278,9 +279,6 @@ public void onClick(View v) { layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - layoutParamsSurface.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); - layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); - if((position < 2)){ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); }else{ @@ -402,23 +400,25 @@ public void onClick(View v) { } holder.surfaceMicroLayout.setVisibility(View.VISIBLE); - //Audio icon: - if(numPeersOnCall < 7){ + if(peers.size() < 7){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view); holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view); holder.microSurface.setLayoutParams(paramsMicroSurface); } + if(peer.isAudioOn()){ holder.microSurface.setVisibility(View.GONE); }else{ @@ -441,11 +441,10 @@ public void onClick(View v) { } }else{ - log(peer.getName()+" VIDEO OFF"); + log(" "+peer.getName()+" VIDEO OFF"); //Remove Surface view && Listener: holder.surfaceMicroLayout.setVisibility(GONE); - holder.avatarMicroLayout.setVisibility(View.VISIBLE); if(peer.getListener() != null){ @@ -475,6 +474,9 @@ public void onClick(View v) { setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } + holder.avatarMicroLayout.setVisibility(View.VISIBLE); + + //Micro icon: if(numPeersOnCall < 7){ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); @@ -870,22 +872,24 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ }else{ holder.microAvatar.setVisibility(View.GONE); - holder.microSurface.setVisibility(View.VISIBLE); + //Audio icon: if(peers.size() < 7){ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(24, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(15, outMetrics), Util.scaleWidthPx(15, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view); holder.microSurface.setLayoutParams(paramsMicroSurface); }else{ RelativeLayout.LayoutParams paramsMicroSurface = new RelativeLayout.LayoutParams(holder.microSurface.getLayoutParams()); paramsMicroSurface.height = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.width = Util.scaleWidthPx(15, outMetrics); paramsMicroSurface.setMargins(0, Util.scaleWidthPx(7, outMetrics), Util.scaleWidthPx(7, outMetrics), 0); - paramsMicroSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view); + paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view); holder.microSurface.setLayoutParams(paramsMicroSurface); } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 58e196a4d67..33441a2243f 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -40,7 +40,7 @@ - - + diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 24b133e9e01..7aaeeb67d69 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -3,6 +3,8 @@ android:id="@+id/general" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_centerVertical="true" + android:layout_centerInParent="true" android:background="@color/orange"> @@ -41,6 +47,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" + android:layout_centerVertical="true" + android:gravity="center_vertical" android:background="@android:color/holo_green_dark" android:visibility="gone"> From 5fc87fab6f5d12369c9d895941482d0b3351e58d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 18 Nov 2018 18:43:23 +0100 Subject: [PATCH 105/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 20 ++-- .../chatAdapters/GroupCallAdapter.java | 103 +++++++----------- .../main/res/layout/activity_calls_chat.xml | 2 +- .../res/layout/item_camera_group_call.xml | 8 +- 4 files changed, 53 insertions(+), 80 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 44d78358a0d..664cbb789cc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1201,7 +1201,7 @@ protected void onResume() { @Override public void onDestroy(){ - log("onDestroy()"); + log("+++++ onDestroy()"); if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); @@ -1368,7 +1368,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ if(chat.isGroup()){ - log("CALL_STATUS_IN_PROGRESS"); + log("+++++ CALL_STATUS_IN_PROGRESS"); if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); @@ -1428,7 +1428,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_TERMINATING_USER_PARTICIPATION"); //I have finished the group call but I can join again - log("Terminating call of chat: "+chatId); + log("+++++++ Terminating call of chat: "+chatId); if(chat.isGroup()){ stopAudioSignals(); rtcAudioManager.stop(); @@ -1450,7 +1450,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ - log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); + log("+++++ CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); //The group call has finished but I can not join again stopAudioSignals(); @@ -1480,7 +1480,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("SESSION_STATUS_IN_PROGRESS"); + log("+++++ SESSION_STATUS_IN_PROGRESS -> "+chat.getPeerFullnameByHandle(userHandle)+" joined"); updateSubTitle(); @@ -1519,7 +1519,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ - log("SESSION_STATUS_DESTROYED"); + log("++++++ SESSION_STATUS_DESTROYED -> "+chat.getPeerFullnameByHandle(userHandle)+" left "); updateSubTitle(); @@ -1540,7 +1540,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); } updateSubtitleToolbar(); }else{ @@ -1589,7 +1589,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION"); + log("+++++++ CHANGE_TYPE_CALL_COMPOSITION"); if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ @@ -1612,11 +1612,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ long userHandle = call.getParticipants().get(i); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); peersBeforeCall.add(userPeer); - log("onChatCallUpdate()-USER COMPOSITION -> "+userPeer.getName()+" added"); changes = true; } if(changes){ - log("onChatCallUpdate()-USER COMPOSITION -> updatePeers ("+peersOnCall.size()+")"); updatePeers(false); } } @@ -2762,7 +2760,7 @@ public void updatePeers(boolean flag){ parentBigCameraGroupCall.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); - if(peersOnCall.size()< 4){ + if(peersBeforeCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index db9409183d1..753e067472e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -208,19 +208,28 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); if(numPeersOnCall < 4){ + lp.height = maxScreenHeight/numPeersOnCall; lp.width = maxScreenWidth; + }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ lp.height = Util.scaleWidthPx(180, outMetrics); lp.width = maxScreenWidth/2; + + if((peers.size()==5)&&(peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + }else{ + lp.height = Util.scaleWidthPx(90, outMetrics); lp.width = Util.scaleWidthPx(90, outMetrics); + } holder.rlGeneral.setLayoutParams(lp); -// holder.rlGeneral.setGravity(RelativeLayout.CENTER_HORIZONTAL); -// holder.rlGeneral.setGravity(RelativeLayout.CENTER_VERTICAL); - if(isCallInProgress){ holder.rlGeneral.setOnClickListener(new View.OnClickListener() { @@ -238,7 +247,6 @@ public void onClick(View v) { } if(peer.isVideoOn()) { - log(peer.getName()+" VIDEO ON"); holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -278,6 +286,7 @@ public void onClick(View v) { RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); if((position < 2)){ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); @@ -296,18 +305,6 @@ public void onClick(View v) { layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); - if(peer.getHandle().equals(megaChatApi.getMyUserHandle())){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - }else{ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = (maxScreenWidth/2); - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); - holder.rlGeneral.setLayoutParams(layoutParamsPeer); - } - }else if(numPeersOnCall == 6){ //Surface Layout: @@ -318,16 +315,8 @@ public void onClick(View v) { holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); } - - -// if(holder.parentSurfaceView.getChildCount()!=0){ -// holder.parentSurfaceView.removeAllViewsInLayout(); -// } -// holder.surfaceMicroLayout.setVisibility(GONE); - //Listener && SurfaceView if(peer.getListener() == null){ - SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); surfaceView.setZOrderMediaOverlay(true); @@ -344,59 +333,45 @@ public void onClick(View v) { }else{ peer.getListener().getLocalRenderer().addListener(this); } + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); }else{ - -// if(peer.getListener().getHeight() != 0){ -// peer.getListener().setHeight(0); -// } -// if(peer.getListener().getWidth() != 0){ -// peer.getListener().setWidth(0); -// } if(holder.parentSurfaceView.getChildCount() == 0){ if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeAllViewsInLayout(); + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - }else{ - - } - }else{ - - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - } }else{ - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - + //Remove items of parent + holder.parentSurfaceView.removeAllViews(); -// if(peer.getListener().getHeight() != 0){ -// peer.getListener().setHeight(0); -// } -// if(peer.getListener().getWidth() != 0){ -// peer.getListener().setWidth(0); -// } -// holder.parentSurfaceView.setGravity(RelativeLayout.CENTER_HORIZONTAL); + //Remove parent of Surface + if(peer.getListener().getSurfaceView().getParent()!=null){ + if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + } + } } -// peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - } holder.surfaceMicroLayout.setVisibility(View.VISIBLE); @@ -441,12 +416,9 @@ public void onClick(View v) { } }else{ - log(" "+peer.getName()+" VIDEO OFF"); //Remove Surface view && Listener: holder.surfaceMicroLayout.setVisibility(GONE); - - if(peer.getListener() != null){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); @@ -467,16 +439,19 @@ public void onClick(View v) { peer.setListener(null); }else{ } - //Create Avatar: + if(peers.size() == 4){ + + } + + holder.avatarMicroLayout.setVisibility(View.VISIBLE); + + //Avatar: if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { setProfileMyAvatar(holder); }else{ setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); } - holder.avatarMicroLayout.setVisibility(View.VISIBLE); - - //Micro icon: if(numPeersOnCall < 7){ RelativeLayout.LayoutParams paramsMicroAvatar = new RelativeLayout.LayoutParams(holder.microAvatar.getLayoutParams()); diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 33441a2243f..ae476f3c6cb 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -55,7 +55,7 @@ android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true" - android:background="@android:color/holo_blue_bright" + android:background="@android:color/transparent" android:nestedScrollingEnabled="false" android:horizontalSpacing="0dp" android:verticalSpacing="0dp" diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 7aaeeb67d69..73a109012d9 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:layout_centerVertical="true" android:layout_centerInParent="true" - android:background="@color/orange"> + android:background="@color/black"> @@ -24,7 +24,7 @@ android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true" - android:background="@android:color/holo_red_dark"> + android:background="@android:color/transparent"> From 75b5f17bdae81bac332ea92ecc96ec9e31f07b1a Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 18 Nov 2018 19:41:11 +0100 Subject: [PATCH 106/247] Group Calls UI --- .../megachat/calls/ChatCallActivity.java | 67 ++++++++++++------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 664cbb789cc..cc2ecd1511d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1499,21 +1499,28 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); peersOnCall.add(0, userPeer); log("onChatCallUpdate()-USER INPROGRESS -> "+userPeer.getName()+" added"); - if((peersOnCall.size()<7)&&(adapterGrid!= null)){ - log(" onChatCallUpdate()-USER INPROGRESS -> addAt (0)"); - if(peersOnCall.size()< 4){ - recyclerView.setColumnWidth((int) widthScreenPX); + + if(peersOnCall.size()<7){ + if(adapterGrid != null){ + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemInserted(0); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); }else{ - recyclerView.setColumnWidth((int) widthScreenPX/2); + updatePeers(true); } - adapterGrid.notifyItemInserted(0); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - - updateSubtitleToolbar(); - }else{ - log("onChatCallUpdate()-USER INPROGRESS -> updatePeers ("+peersOnCall.size()+")"); - updatePeers(true); + if(adapterList != null){ + adapterList.notifyItemInserted(0); + adapterList.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); + }else{ + updatePeers(true); + } } } } @@ -1531,21 +1538,32 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(peersOnCall.get(i).getHandle() == userHandle){ peersOnCall.remove(i); log("onChatCallUpdate()-USER DESTROYED -> "+peersOnCall.get(i).getName()+" removed"); - if((peersOnCall.size()<6)&&(adapterGrid!=null)){ - log("onChatCallUpdate()-USER DESTROYED -> removeAt ("+i+")"); - if(peersOnCall.size()< 4){ - recyclerView.setColumnWidth((int) widthScreenPX); - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + + if(peersOnCall.size()<7){ + + if(adapterGrid != null){ + if(peersOnCall.size()< 4){ + recyclerView.setColumnWidth((int) widthScreenPX); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + }else{ + recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + } + updateSubtitleToolbar(); }else{ - recyclerView.setColumnWidth((int) widthScreenPX/2); - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updatePeers(true); } - updateSubtitleToolbar(); + }else{ - log("onChatCallUpdate()-USER DESTROYED -> updatePeers ("+peersOnCall.size()+")"); - updatePeers(true); + if(adapterList != null){ + adapterList.notifyItemRemoved(i); + adapterList.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); + }else{ + updatePeers(true); + } } break; } @@ -2723,6 +2741,7 @@ public void updatePeers(boolean flag){ bigRecyclerView.setVisibility(View.VISIBLE); if(adapterList == null){ + bigRecyclerView.setAdapter(null); adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag); bigRecyclerView.setAdapter(adapterList); }else{ From b5b4d6ef9ce28ce1d5114efe2bc578978fd0b22c Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 18 Nov 2018 20:02:48 +0100 Subject: [PATCH 107/247] Group Calls UI --- .../lollipop/megachat/calls/ChatCallActivity.java | 14 +++++++------- app/src/main/res/layout/activity_calls_chat.xml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index cc2ecd1511d..c05006c7137 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1201,7 +1201,7 @@ protected void onResume() { @Override public void onDestroy(){ - log("+++++ onDestroy()"); + log("onDestroy()"); if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); @@ -1368,7 +1368,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ if(chat.isGroup()){ - log("+++++ CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS"); if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); @@ -1428,7 +1428,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("CALL_STATUS_TERMINATING_USER_PARTICIPATION"); //I have finished the group call but I can join again - log("+++++++ Terminating call of chat: "+chatId); + log("Terminating call of chat: "+chatId); if(chat.isGroup()){ stopAudioSignals(); rtcAudioManager.stop(); @@ -1450,7 +1450,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ - log("+++++ CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); + log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); //The group call has finished but I can not join again stopAudioSignals(); @@ -1480,7 +1480,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("+++++ SESSION_STATUS_IN_PROGRESS -> "+chat.getPeerFullnameByHandle(userHandle)+" joined"); + log("SESSION_STATUS_IN_PROGRESS -> "+chat.getPeerFullnameByHandle(userHandle)+" joined"); updateSubTitle(); @@ -1526,7 +1526,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ - log("++++++ SESSION_STATUS_DESTROYED -> "+chat.getPeerFullnameByHandle(userHandle)+" left "); + log("SESSION_STATUS_DESTROYED -> "+chat.getPeerFullnameByHandle(userHandle)+" left "); updateSubTitle(); @@ -1607,7 +1607,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("+++++++ CHANGE_TYPE_CALL_COMPOSITION"); + log("CHANGE_TYPE_CALL_COMPOSITION"); if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index ae476f3c6cb..abe793d357f 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -131,8 +131,8 @@ android:id="@+id/micro_avatar_big_camera_group_call" android:layout_width="24dp" android:layout_height="24dp" - android:layout_alignParentTop="true" - android:layout_alignParentRight="true" + android:layout_toRightOf="@+id/rl_avatar_big_camera_group_call" + android:layout_alignTop="@+id/rl_avatar_big_camera_group_call" android:background="@android:color/transparent" android:visibility="gone" android:src="@drawable/ic_mic_off_contact"/> From e8430785007a7bfd54a9f6f371a33bebaed4f20f Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 19 Nov 2018 10:11:25 +0100 Subject: [PATCH 108/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 152 +++++++++++++----- .../chatAdapters/GroupCallAdapter.java | 96 ++++++----- .../main/res/layout/activity_calls_chat.xml | 1 + .../res/layout/item_camera_group_call.xml | 2 - 4 files changed, 166 insertions(+), 85 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index c05006c7137..d67a66c177c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -156,6 +156,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout bigElementsIndividualCallLayout; RelativeLayout bigElementsGroupCallLayout; + RelativeLayout recyclerViewLayout; CustomizedGridCallRecyclerView recyclerView; LinearLayoutManager layoutManager; @@ -339,12 +340,16 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("#### updateScreenStatusInProgress() "+userPeer.getName()+" added A"); + peersOnCall.add(0, userPeer); changes = true; } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("#### updateScreenStatusInProgress() MY PEER added A"); + peersOnCall.add(myPeer); changes = true; } @@ -364,12 +369,16 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("#### updateScreenStatusInProgress() "+userPeer.getName()+" added B"); + peersOnCall.add(0, userPeer); changes = true; } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("#### updateScreenStatusInProgress() MY PEER added B"); + peersOnCall.add(myPeer); changes = true; } @@ -636,6 +645,7 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsGroupCallLayout.setVisibility(GONE); //Recycler View for 1-6 peers + recyclerViewLayout = (RelativeLayout) findViewById(R.id.rl_recycler_view); recyclerView = (CustomizedGridCallRecyclerView) findViewById(R.id.recycler_view_cameras); recyclerView.setPadding(0, 0, 0, 0); // recyclerView.setClipToPadding(false); @@ -786,20 +796,20 @@ protected void onCreate(Bundle savedInstanceState) { if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ -// ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); -// ringerTimer = new Timer(); -// MyRingerTask myRingerTask = new MyRingerTask(); -// ringerTimer.schedule(myRingerTask, 0, 500); -// -// vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// long[] pattern = {0, 1000, 500, 500, 1000}; -// if (vibrator != null){ -// if (vibrator.hasVibrator()){ -// //FOR API>=26 -// //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? -// vibrator.vibrate(pattern, 0); -// } -// } + ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); + ringerTimer = new Timer(); + MyRingerTask myRingerTask = new MyRingerTask(); + ringerTimer.schedule(myRingerTask, 0, 500); + + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + long[] pattern = {0, 1000, 500, 500, 1000}; + if (vibrator != null){ + if (vibrator.hasVibrator()){ + //FOR API>=26 + //vibrator.vibrate(createWaveform(pattern, 0), USAGE_NOTIFICATION_RINGTONE); ?? + vibrator.vibrate(pattern, 0); + } + } if(chat.isGroup()){ log("Incoming group call"); @@ -846,15 +856,15 @@ protected void onCreate(Bundle savedInstanceState) { log("InProgress"); updateScreenStatusInProgress(); }else{ -// int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); -// if (volume == 0) { -// toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); -// toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); -// }else { -// thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); -// thePlayer.setLooping(true); -// thePlayer.start(); -// } + int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + if (volume == 0) { + toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100); + toneGenerator.startTone(ToneGenerator.TONE_SUP_RINGTONE, 60000); + }else { + thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call); + thePlayer.setLooping(true); + thePlayer.start(); + } if(chat.isGroup()){ log("Outgoing group call"); @@ -1368,11 +1378,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ if(chat.isGroup()){ - log("CALL_STATUS_IN_PROGRESS"); - - if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ - peersBeforeCall.clear(); - } + log("#### CALL_STATUS_IN_PROGRESS"); if((peersOnCall != null)&&(peersOnCall.size() != 0)){ boolean peerContain = false; @@ -1384,11 +1390,20 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("#### CALL_STATUS_IN_PROGRESS add MyPeer A"); peersOnCall.add(myPeer); updatePeers(true); } }else{ + if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ + for(InfoPeerGroupCall peerBefore: peersBeforeCall){ + log("#### CALL_STATUS_IN_PROGRESS add "+peerBefore.getName()+" in peersOnCall"); + peersOnCall.add(peerBefore); + + } + } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("#### CALL_STATUS_IN_PROGRESS add MyPeer B"); peersOnCall.add(myPeer); updatePeers(true); } @@ -1480,7 +1495,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("SESSION_STATUS_IN_PROGRESS -> "+chat.getPeerFullnameByHandle(userHandle)+" joined"); + log("#### SESSION_STATUS_IN_PROGRESS"); updateSubTitle(); @@ -1497,15 +1512,22 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("#### SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); peersOnCall.add(0, userPeer); - log("onChatCallUpdate()-USER INPROGRESS -> "+userPeer.getName()+" added"); if(peersOnCall.size()<7){ if(adapterGrid != null){ if(peersOnCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); + recyclerViewLayout.setPadding(0,0,0,0); + }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + }else{ + recyclerViewLayout.setPadding(0,0,0,0); + } } adapterGrid.notifyItemInserted(0); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); @@ -1526,7 +1548,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ - log("SESSION_STATUS_DESTROYED -> "+chat.getPeerFullnameByHandle(userHandle)+" left "); + log("#### SESSION_STATUS_DESTROYED "); updateSubTitle(); @@ -1536,18 +1558,24 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); peersOnCall.remove(i); - log("onChatCallUpdate()-USER DESTROYED -> "+peersOnCall.get(i).getName()+" removed"); - if(peersOnCall.size()<7){ if(adapterGrid != null){ if(peersOnCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); + recyclerViewLayout.setPadding(0,0,0,0); + adapterGrid.notifyItemRemoved(i); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + }else{ + recyclerViewLayout.setPadding(0,0,0,0); + } adapterGrid.notifyItemRemoved(i); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); } @@ -1607,13 +1635,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("CHANGE_TYPE_CALL_COMPOSITION"); + log("#### CHANGE_TYPE_CALL_COMPOSITION -> participants: "+call.getParticipants().size()); if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ - if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ - peersBeforeCall.clear(); - } - boolean isMe = false; for(int i = 0; i < call.getParticipants().size(); i++){ Long userHandle = call.getParticipants().get(i); @@ -1625,16 +1649,45 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if(!isMe){ boolean changes = false; - //Get all participant and add them + //Get all participant and check it for(int i = 0; i < call.getParticipants().size(); i++){ + boolean peerContain = false; long userHandle = call.getParticipants().get(i); - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); - peersBeforeCall.add(userPeer); - changes = true; + for(InfoPeerGroupCall peerBeforeCall: peersBeforeCall){ + if(peerBeforeCall.getHandle().equals(userHandle)){ + peerContain = true; + break; + } + } + if(!peerContain){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("#### CHANGE_TYPE_CALL_COMPOSITION -> "+userPeer.getName()+" added"); + + peersBeforeCall.add(0, userPeer); + changes = true; + } + } + for(int i=0;i "+peersBeforeCall.get(i).getName()+" removed"); + + peersBeforeCall.remove(i); + changes = true; + + } } + if(changes){ updatePeers(false); } + } } @@ -2678,6 +2731,9 @@ public void updatePeers(boolean flag){ log("updatePeers()"); if(flag){ + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } //Call IN PROGRESS updateSubtitleToolbar(); @@ -2695,8 +2751,14 @@ public void updatePeers(boolean flag){ recyclerView.setVisibility(View.VISIBLE); if(peersOnCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); + recyclerViewLayout.setPadding(0,0,0,0); }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + }else{ + recyclerViewLayout.setPadding(0,0,0,0); + } } if(adapterGrid == null){ recyclerView.setAdapter(null); @@ -2781,8 +2843,14 @@ public void updatePeers(boolean flag){ recyclerView.setVisibility(View.VISIBLE); if(peersBeforeCall.size()< 4){ recyclerView.setColumnWidth((int) widthScreenPX); + recyclerViewLayout.setPadding(0,0,0,0); }else{ recyclerView.setColumnWidth((int) widthScreenPX/2); + if(peersBeforeCall.size() == 4){ + recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); + }else{ + recyclerViewLayout.setPadding(0,0,0,0); + } } if(adapterGrid == null){ adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 753e067472e..6b7be890d0c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -213,21 +213,17 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in lp.width = maxScreenWidth; }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ - lp.height = Util.scaleWidthPx(180, outMetrics); + lp.height = maxScreenWidth/2; lp.width = maxScreenWidth/2; - if((peers.size()==5)&&(peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsPeer.height = maxScreenWidth/2; holder.rlGeneral.setLayoutParams(layoutParamsPeer); } - }else{ - lp.height = Util.scaleWidthPx(90, outMetrics); lp.width = Util.scaleWidthPx(90, outMetrics); - } holder.rlGeneral.setLayoutParams(lp); @@ -264,8 +260,8 @@ public void onClick(View v) { //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(320, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(320, outMetrics); + layoutParamsSurface.width = maxScreenHeight/numPeersOnCall; + layoutParamsSurface.height = maxScreenHeight/numPeersOnCall; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -274,8 +270,8 @@ public void onClick(View v) { //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(212, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(212, outMetrics); + layoutParamsSurface.width = maxScreenHeight/numPeersOnCall; + layoutParamsSurface.height = maxScreenHeight/numPeersOnCall; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -284,10 +280,10 @@ public void onClick(View v) { //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); - + layoutParamsSurface.width = maxScreenWidth/2; + layoutParamsSurface.height = maxScreenWidth/2; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + if((position < 2)){ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); }else{ @@ -300,8 +296,8 @@ public void onClick(View v) { //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.width = maxScreenWidth/2; + layoutParamsSurface.height = maxScreenWidth/2; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); @@ -309,8 +305,8 @@ public void onClick(View v) { //Surface Layout: RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams(); - layoutParamsSurface.width = Util.scaleWidthPx(180, outMetrics); - layoutParamsSurface.height = Util.scaleWidthPx(180, outMetrics); + layoutParamsSurface.width = maxScreenWidth/2; + layoutParamsSurface.height = maxScreenWidth/2; layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); holder.parentSurfaceView.setLayoutParams(layoutParamsSurface); } @@ -335,44 +331,58 @@ public void onClick(View v) { } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); }else{ + if(holder.parentSurfaceView.getChildCount() == 0){ if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + }else{ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); } } }else{ - //Remove items of parent - holder.parentSurfaceView.removeAllViews(); - //Remove parent of Surface - if(peer.getListener().getSurfaceView().getParent()!=null){ - if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); + if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + }else{ + //Remove items of parent + holder.parentSurfaceView.removeAllViews(); + //Remove parent of Surface + if(peer.getListener().getSurfaceView().getParent()!=null){ + if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); } - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); } } + } } + + holder.surfaceMicroLayout.setVisibility(View.VISIBLE); //Audio icon: @@ -417,7 +427,7 @@ public void onClick(View v) { }else{ - //Remove Surface view && Listener: + //Remove SurfaceView && Listener: holder.surfaceMicroLayout.setVisibility(GONE); if(peer.getListener() != null){ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -429,20 +439,24 @@ public void onClick(View v) { if(holder.parentSurfaceView.getChildCount() == 0){ if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeAllViewsInLayout(); - }else{ } - }else{ } + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); + } + } }else{ holder.parentSurfaceView.removeAllViews(); holder.parentSurfaceView.removeAllViewsInLayout(); - } - peer.setListener(null); - }else{ } - if(peers.size() == 4){ + if(peer.getListener().getSurfaceView().getParent()!=null){ + if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); + } + } + } + peer.setListener(null); } + holder.avatarMicroLayout.setVisibility(View.VISIBLE); //Avatar: diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index abe793d357f..feea93160a3 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -41,6 +41,7 @@ Date: Mon, 19 Nov 2018 10:47:51 +0100 Subject: [PATCH 109/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index d67a66c177c..7cda5091017 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -340,15 +340,12 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("#### updateScreenStatusInProgress() "+userPeer.getName()+" added A"); - peersOnCall.add(0, userPeer); changes = true; } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("#### updateScreenStatusInProgress() MY PEER added A"); peersOnCall.add(myPeer); changes = true; @@ -369,15 +366,12 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("#### updateScreenStatusInProgress() "+userPeer.getName()+" added B"); - peersOnCall.add(0, userPeer); changes = true; } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("#### updateScreenStatusInProgress() MY PEER added B"); peersOnCall.add(myPeer); changes = true; @@ -1378,7 +1372,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ if(chat.isGroup()){ - log("#### CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS"); if((peersOnCall != null)&&(peersOnCall.size() != 0)){ boolean peerContain = false; @@ -1390,20 +1384,20 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("#### CALL_STATUS_IN_PROGRESS add MyPeer A"); + log("CALL_STATUS_IN_PROGRESS add MyPeer A"); peersOnCall.add(myPeer); updatePeers(true); } }else{ if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ for(InfoPeerGroupCall peerBefore: peersBeforeCall){ - log("#### CALL_STATUS_IN_PROGRESS add "+peerBefore.getName()+" in peersOnCall"); + log("CALL_STATUS_IN_PROGRESS add "+peerBefore.getName()+" in peersOnCall"); peersOnCall.add(peerBefore); } } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("#### CALL_STATUS_IN_PROGRESS add MyPeer B"); + log("CALL_STATUS_IN_PROGRESS add MyPeer B"); peersOnCall.add(myPeer); updatePeers(true); } @@ -1495,7 +1489,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ MegaChatSession userSession = callChat.getMegaChatSession(userHandle); if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - log("#### SESSION_STATUS_IN_PROGRESS"); + log("SESSION_STATUS_IN_PROGRESS"); updateSubTitle(); @@ -1512,7 +1506,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("#### SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); + log("SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); peersOnCall.add(0, userPeer); if(peersOnCall.size()<7){ @@ -1548,7 +1542,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ - log("#### SESSION_STATUS_DESTROYED "); + log("SESSION_STATUS_DESTROYED "); updateSubTitle(); @@ -1558,7 +1552,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); + log("SESSION_STATUS_DESTROYED -> "+peersOnCall.get(i).getName()+" removed"); peersOnCall.remove(i); if(peersOnCall.size()<7){ @@ -1635,7 +1629,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("#### CHANGE_TYPE_CALL_COMPOSITION -> participants: "+call.getParticipants().size()); + log("CHANGE_TYPE_CALL_COMPOSITION -> participants: "+call.getParticipants().size()); if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ boolean isMe = false; @@ -1661,8 +1655,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); - log("#### CHANGE_TYPE_CALL_COMPOSITION -> "+userPeer.getName()+" added"); - + log("CHANGE_TYPE_CALL_COMPOSITION -> "+userPeer.getName()+" added"); peersBeforeCall.add(0, userPeer); changes = true; } @@ -1676,8 +1669,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } if(!peerContained){ - log("#### CHANGE_TYPE_CALL_COMPOSITION -> "+peersBeforeCall.get(i).getName()+" removed"); - + log("CHANGE_TYPE_CALL_COMPOSITION -> "+peersBeforeCall.get(i).getName()+" removed"); peersBeforeCall.remove(i); changes = true; From 9c503718905120c293806c7d0cfd45b088b80c7c Mon Sep 17 00:00:00 2001 From: Javier Gomez Date: Mon, 19 Nov 2018 18:25:57 +0100 Subject: [PATCH 110/247] Detect changes of the state storage state --- .../privacy/android/app/MegaApplication.java | 10 + .../app/lollipop/ManagerActivityLollipop.java | 311 ++++++++++-------- .../privacy/android/app/utils/Constants.java | 2 + 3 files changed, 190 insertions(+), 133 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index b66c89a8d48..05835e40e40 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -1306,7 +1306,17 @@ public void onRequestTemporaryError(MegaChatApiJava api, MegaChatRequest request @Override public void onEvent(MegaApiJava api, MegaEvent event) { + log("onEvent: " + event.getText()); + if (event.getType() == MegaEvent.EVENT_STORAGE) { + log("Storage status changed"); + Intent intent = new Intent(Constants.BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS); + intent.setAction(Constants.ACTION_STORAGE_STATE_CHANGED); + intent.putExtra("state", event.getNumber()); + LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); + + api.getAccountDetails(null); + } } public void updateAppBadge(){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index a437e636d35..80a7cb9f6d1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -339,7 +339,9 @@ public class ManagerActivityLollipop extends PinActivityLollipop implements Mega public boolean openSettingsQR = false; boolean newAccount = false; - boolean showStorageAlmostFullDialog = true; + private int storageState = MegaApiJava.STORAGE_STATE_GREEN; + private boolean showStorageOverquotaDialog = true; + private boolean showStorageAlmostFullDialog = true; int orientationSaved; @@ -606,11 +608,15 @@ public String getTitle(Context context) { private BroadcastReceiver updateMyAccountReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - - int actionType; - if (intent != null){ - actionType = intent.getIntExtra("actionType", -1); + if (intent.getAction() == Constants.ACTION_STORAGE_STATE_CHANGED) { + storageState = intent.getIntExtra("state", MegaApiJava.STORAGE_STATE_GREEN); + showStorageStatusDialog(); + updateAccountDetailsVisibleInfo(); + return; + } + + int actionType = intent.getIntExtra("actionType", -1); if(actionType == Constants.UPDATE_GET_PRICING){ log("BROADCAST TO UPDATE AFTER GET PRICING"); @@ -1629,6 +1635,7 @@ public void onSaveInstanceState(Bundle outState) { outState.putBoolean("isEnable2FADialogShown", isEnable2FADialogShown); outState.putInt("bottomNavigationCurrentItem", bottomNavigationCurrentItem); outState.putBoolean("searchExpand", searchExpand); + outState.putInt("storageState", storageState); } @Override @@ -1686,6 +1693,7 @@ protected void onCreate(Bundle savedInstanceState) { isEnable2FADialogShown = savedInstanceState.getBoolean("isEnable2FADialogShown", false); bottomNavigationCurrentItem = savedInstanceState.getInt("bottomNavigationCurrentItem", -1); searchExpand = savedInstanceState.getBoolean("searchExpand", false); + storageState = savedInstanceState.getInt("storageState", -1); } else{ log("Bundle is NULL"); @@ -1702,10 +1710,21 @@ protected void onCreate(Bundle savedInstanceState) { this.setPathNavigationOffline("/"); } - LocalBroadcastManager.getInstance(this).registerReceiver(receiverUpdatePosition, new IntentFilter(Constants.BROADCAST_ACTION_INTENT_FILTER_UPDATE_POSITION)); - LocalBroadcastManager.getInstance(this).registerReceiver(updateMyAccountReceiver, new IntentFilter(Constants.BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS)); - LocalBroadcastManager.getInstance(this).registerReceiver(receiverUpdate2FA, new IntentFilter(Constants.BROADCAST_ACTION_INTENT_UPDATE_2FA_SETTINGS)); - LocalBroadcastManager.getInstance(this).registerReceiver(networkReceiver, new IntentFilter(Constants.BROADCAST_ACTION_INTENT_CONNECTIVITY_CHANGE)); + LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this); + if (localBroadcastManager != null) { + localBroadcastManager.registerReceiver(receiverUpdatePosition, + new IntentFilter(Constants.BROADCAST_ACTION_INTENT_FILTER_UPDATE_POSITION)); + + IntentFilter filter = new IntentFilter(Constants.BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS); + filter.addAction(Constants.ACTION_STORAGE_STATE_CHANGED); + localBroadcastManager.registerReceiver(updateMyAccountReceiver, filter); + + localBroadcastManager.registerReceiver(receiverUpdate2FA, + new IntentFilter(Constants.BROADCAST_ACTION_INTENT_UPDATE_2FA_SETTINGS)); + + localBroadcastManager.registerReceiver(networkReceiver, + new IntentFilter(Constants.BROADCAST_ACTION_INTENT_CONNECTIVITY_CHANGE)); + } nC = new NodeController(this); cC = new ContactController(this); @@ -2854,7 +2873,7 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){ drawerLayout.closeDrawer(Gravity.LEFT); } - showStorageAlmostFullDialog(); + showStorageStatusDialog(); //INITIAL FRAGMENT if(selectDrawerItemPending){ @@ -4571,6 +4590,7 @@ public void showOnlineMode(){ // } updateAccountDetailsVisibleInfo(); updateAccountDetailsVisibleInfo(); + showStorageStatusDialog(); } else { log("showOnlineMode - Root is NULL"); if (getApplicationContext() != null) { @@ -12812,6 +12832,13 @@ else if(dialog instanceof ContactsBottomSheetDialogFragment){ private void showOverquotaAlert(boolean prewarning){ log("showOverquotaAlert: prewarning: "+prewarning); + if(!showStorageOverquotaDialog){ + log("Storage overquota dialog already shown"); + return; + } + + showStorageOverquotaDialog = false; + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.overquota_alert_title)); @@ -12829,6 +12856,7 @@ private void showOverquotaAlert(boolean prewarning){ @Override public void onClick(DialogInterface dialog, int which) { + showStorageOverquotaDialog = true; //Show UpgradeAccountActivity drawerItem = DrawerItem.ACCOUNT; accountFragment=Constants.UPGRADE_ACCOUNT_FRAGMENT; @@ -12840,6 +12868,7 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); + showStorageOverquotaDialog = true; overquotaDialog=null; } }); @@ -12916,25 +12945,22 @@ public void updateAccountDetailsVisibleInfo(){ } } - showStorageAlmostFullDialog(); + switch (storageState) { + case MegaApiJava.STORAGE_STATE_GREEN: + usedSpacePB.setProgressDrawable(getResources().getDrawable( + R.drawable.custom_progress_bar_horizontal_ok)); + break; - if (((MegaApplication) getApplication()).getMyAccountInfo().getUsedPerc() < 90){ - usedSpacePB.setProgressDrawable(getResources().getDrawable(R.drawable.custom_progress_bar_horizontal_ok)); -// wordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.used_space_ok)), 0, used.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -// usedSpaceWarning.setVisibility(View.INVISIBLE); - } - else if ((((MegaApplication) getApplication()).getMyAccountInfo().getUsedPerc() >= 90) && (((MegaApplication) getApplication()).getMyAccountInfo().getUsedPerc() <= 95)){ - usedSpacePB.setProgressDrawable(getResources().getDrawable(R.drawable.custom_progress_bar_horizontal_warning)); -// wordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.used_space_warning)), 0, used.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -// usedSpaceWarning.setVisibility(View.VISIBLE); - } - else{ - if (((MegaApplication) getApplication()).getMyAccountInfo().getUsedPerc() > 100){ + case MegaApiJava.STORAGE_STATE_ORANGE: + usedSpacePB.setProgressDrawable(getResources().getDrawable( + R.drawable.custom_progress_bar_horizontal_warning)); + break; + + case MegaApiJava.STORAGE_STATE_RED: ((MegaApplication) getApplication()).getMyAccountInfo().setUsedPerc(100); - } - usedSpacePB.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.custom_progress_bar_horizontal_exceed)); -// wordtoSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(this, R.color.used_space_exceed)), 0, used.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -// usedSpaceWarning.setVisibility(View.VISIBLE); + usedSpacePB.setProgressDrawable(getResources().getDrawable( + R.drawable.custom_progress_bar_horizontal_exceed)); + break; } } @@ -14919,6 +14945,32 @@ public void onClick(View v) { alertDialogTransferOverquota.show(); } + private void showStorageStatusDialog() { + switch (storageState) { + case MegaApiJava.STORAGE_STATE_GREEN: + log("STORAGE STATE GREEN"); + int accountType = ((MegaApplication) getApplication()).getMyAccountInfo().getAccountType(); + if(accountType == MegaAccountDetails.ACCOUNT_TYPE_FREE){ + log("ACCOUNT TYPE FREE"); + if(Util.showMessageRandom()){ + log("Show message random: TRUE"); + showProPanel(); + } + } + break; + + case MegaApiJava.STORAGE_STATE_ORANGE: + log("STORAGE STATE ORANGE"); + showStorageAlmostFullDialog(); + break; + + case MegaApiJava.STORAGE_STATE_RED: + log("STORAGE STATE RED"); + showOverquotaAlert(false); + break; + } + } + public void showStorageAlmostFullDialog(){ log("showStorageAlmostFullDialog"); @@ -14927,141 +14979,134 @@ public void showStorageAlmostFullDialog(){ return; } - if(((MegaApplication) getApplication()).getMyAccountInfo().getUsedPerc()>=95){ - if(showStorageAlmostFullDialog){ - - showStorageAlmostFullDialog = false; - - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); - - LayoutInflater inflater = this.getLayoutInflater(); - View dialogView = inflater.inflate(R.layout.storage_almost_full_layout, null); - dialogBuilder.setView(dialogView); + if(!showStorageAlmostFullDialog){ + log("Storage almost full dialog already shown"); + return; + } - TextView title = (TextView) dialogView.findViewById(R.id.storage_almost_full_title); - title.setText(getString(R.string.action_upgrade_account)); + showStorageAlmostFullDialog = false; - TextView text = (TextView) dialogView.findViewById(R.id.text_storage_almost_full); - text.setText(getString(R.string.text_almost_full_warning)); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); - LinearLayout horizontalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.horizontal_buttons_storage_almost_full_layout); - LinearLayout verticalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.vertical_buttons_storage_almost_full_layout); - Button verticalDismissButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_dissmiss); - Button horizontalDismissButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_dissmiss); - Button verticalActionButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_action); - Button horizontalActionButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_payment); - Button achievementsButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_achievements); + LayoutInflater inflater = this.getLayoutInflater(); + View dialogView = inflater.inflate(R.layout.storage_almost_full_layout, null); + dialogBuilder.setView(dialogView); - if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==MegaAccountDetails.ACCOUNT_TYPE_FREE){ - log("show StorageAlmostFull Dialog for FREE USER"); + TextView title = (TextView) dialogView.findViewById(R.id.storage_almost_full_title); + title.setText(getString(R.string.action_upgrade_account)); - if(megaApi.isAchievementsEnabled()){ - horizontalButtonsLayout.setVisibility(View.GONE); - verticalButtonsLayout.setVisibility(View.VISIBLE); - verticalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); + TextView text = (TextView) dialogView.findViewById(R.id.text_storage_almost_full); + text.setText(getString(R.string.text_almost_full_warning)); - verticalDismissButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - } + LinearLayout horizontalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.horizontal_buttons_storage_almost_full_layout); + LinearLayout verticalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.vertical_buttons_storage_almost_full_layout); + Button verticalDismissButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_dissmiss); + Button horizontalDismissButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_dissmiss); + Button verticalActionButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_action); + Button horizontalActionButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_payment); + Button achievementsButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_achievements); - }); + if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==MegaAccountDetails.ACCOUNT_TYPE_FREE){ + log("show StorageAlmostFull Dialog for FREE USER"); - achievementsButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - log("Go to achievements section"); - navigateToAchievements(); - } + if(megaApi.isAchievementsEnabled()){ + horizontalButtonsLayout.setVisibility(View.GONE); + verticalButtonsLayout.setVisibility(View.VISIBLE); + verticalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); - }); + verticalDismissButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + } - verticalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - navigateToUpgradeAccount(); - } + }); - }); + achievementsButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + log("Go to achievements section"); + navigateToAchievements(); } - else{ - horizontalButtonsLayout.setVisibility(View.VISIBLE); - verticalButtonsLayout.setVisibility(View.GONE); - horizontalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); - horizontalDismissButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - } - }); - - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - navigateToUpgradeAccount(); - } + }); - }); + verticalActionButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + navigateToUpgradeAccount(); } - } - else{ - horizontalButtonsLayout.setVisibility(View.VISIBLE); - verticalButtonsLayout.setVisibility(View.GONE); + }); + } + else{ + horizontalButtonsLayout.setVisibility(View.VISIBLE); + verticalButtonsLayout.setVisibility(View.GONE); + horizontalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); - if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()>=MegaAccountDetails.ACCOUNT_TYPE_PROIII){ - log("show StorageAlmostFull Dialog for USER PRO III"); - horizontalActionButton.setText(getString(R.string.button_custom_almost_full_warning)); + horizontalDismissButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - askForCustomizedPlan(); - } + } + }); - }); + horizontalActionButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + navigateToUpgradeAccount(); } - else{ - log("show StorageAlmostFull Dialog for USER PRO"); - horizontalActionButton.setText(getString(R.string.my_account_upgrade_pro)); + }); + } + } + else{ + horizontalButtonsLayout.setVisibility(View.VISIBLE); + verticalButtonsLayout.setVisibility(View.GONE); - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - navigateToUpgradeAccount(); - } + if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()>=MegaAccountDetails.ACCOUNT_TYPE_PROIII){ + log("show StorageAlmostFull Dialog for USER PRO III"); + horizontalActionButton.setText(getString(R.string.button_custom_almost_full_warning)); - }); + horizontalActionButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + askForCustomizedPlan(); } + }); + } + else{ + log("show StorageAlmostFull Dialog for USER PRO"); + horizontalActionButton.setText(getString(R.string.my_account_upgrade_pro)); - horizontalDismissButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - } - - }); + horizontalActionButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; + navigateToUpgradeAccount(); + } + }); + } + horizontalDismissButton.setOnClickListener(new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageAlmostFull.dismiss(); + showStorageAlmostFullDialog = true; } - alertDialogStorageAlmostFull = dialogBuilder.create(); + }); - alertDialogStorageAlmostFull.setCancelable(false); - alertDialogStorageAlmostFull.setCanceledOnTouchOutside(false); - alertDialogStorageAlmostFull.show(); - } - else{ - log("Storage almost full dialog already shown"); - } - } - else{ - if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==MegaAccountDetails.ACCOUNT_TYPE_FREE){ - log("usedSpacePerc<95"); - if(Util.showMessageRandom()){ - log("Random: TRUE"); - showProPanel(); - } - } } + + alertDialogStorageAlmostFull = dialogBuilder.create(); + + alertDialogStorageAlmostFull.setCancelable(false); + alertDialogStorageAlmostFull.setCanceledOnTouchOutside(false); + alertDialogStorageAlmostFull.show(); } public void askForCustomizedPlan(){ diff --git a/app/src/main/java/mega/privacy/android/app/utils/Constants.java b/app/src/main/java/mega/privacy/android/app/utils/Constants.java index 9dfc398c8ca..53c85d353ac 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/Constants.java +++ b/app/src/main/java/mega/privacy/android/app/utils/Constants.java @@ -189,6 +189,8 @@ public class Constants { public static String ACTION_RECOVERY_KEY_EXPORTED = "RECOVERY_KEY_EXPORTED"; public static String ACTION_REQUEST_DOWNLOAD_FOLDER_LOGOUT = "REQUEST_DOWNLOAD_FOLDER_LOGOUT"; + public static String ACTION_STORAGE_STATE_CHANGED = "ACTION_STORAGE_STATE_CHANGED"; + public static String BROADCAST_ACTION_INTENT_FILTER_UPDATE_POSITION = "INTENT_FILTER_UPDATE_POSITION"; public static String BROADCAST_ACTION_INTENT_FILTER_UPDATE_IMAGE_DRAG = "INTENT_FILTER_UPDATE_IMAGE_DRAG"; public static String BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS = "INTENT_UPDATE_ACCOUNT_DETAILS"; From 03f2ab87c5043c48814d4ac68fcd00c6f7890a3e Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 20 Nov 2018 14:13:48 +0100 Subject: [PATCH 111/247] Group calls UI --- .../megachat/ChatActivityLollipop.java | 17 +- .../calls/BigCameraGroupCallFragment.java | 7 + .../megachat/calls/ChatCallActivity.java | 706 +++++++++++++----- .../calls/LocalCameraCallFragment.java | 25 +- .../LocalCameraCallFullScreenFragment.java | 7 + .../RemoteCameraCallFullScreenFragment.java | 7 + .../chatAdapters/GroupCallAdapter.java | 39 +- .../main/res/layout/activity_calls_chat.xml | 17 +- 8 files changed, 594 insertions(+), 231 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 3f2b306298c..64a2570ccf2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -7031,14 +7031,23 @@ public void showJumpMessage(){ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("onChatCallUpdate"); if(call.getChatid()==idChat){ - if(call.getStatus()==MegaChatCall.CALL_STATUS_DESTROYED||call.getStatus()==MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION){ - log("Hide call in progress"); + log(" call.getStatus(): "+call.getStatus()); + if(call.getStatus()==MegaChatCall.CALL_STATUS_DESTROYED){ + log("CALL_STATUS_DESTROYED"); callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); invalidateOptionsMenu(); - } - else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + }else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log(" CALL_STATUS_IN_PROGRESS"); + + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressLayout.setOnClickListener(this); + invalidateOptionsMenu(); + + }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ + log("CALL_STATUS_RING_IN"); + long openCallChatId = MegaApplication.getOpenCallChatId(); log("openCallId: "+openCallChatId); if(openCallChatId!=-1){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 4825201697a..c8f1aee1b2b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -146,6 +146,13 @@ public void onAttach(Context context) { @Override public void onDestroy(){ + if(fullScreenSurfaceView.getParent()!=null){ + if(fullScreenSurfaceView.getParent().getParent()!=null){ + ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); + }else{ + ((ViewGroup)fullScreenSurfaceView.getParent()).removeAllViewsInLayout(); + } + } if(userHandle.equals(megaChatApi.getMyUserHandle())){ megaChatApi.removeChatVideoListener(chatId, -1, this); }else{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 7cda5091017..56e5a3daedc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -304,13 +304,13 @@ public boolean onOptionsItemSelected(MenuItem item) { } public void updateScreenStatusInProgress(){ - log("updateScreenStatusInProgress()"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - flagMyAvatar = true; - setProfileMyAvatar(); - flagContactAvatar = false; - setProfileContactAvatar(); + log("updateScreenStatusInProgress() chatId: "+chatId); +// relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; +// relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; +// flagMyAvatar = true; +// setProfileMyAvatar(); +// flagContactAvatar = false; +// setProfileContactAvatar(); if(chat.isGroup()){ @@ -322,73 +322,135 @@ public void updateScreenStatusInProgress(){ peersBeforeCall.clear(); } - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - boolean changes = false; - for(int i = 0; i < callChat.getParticipants().size(); i++){ - long userHandle = callChat.getParticipants().get(i); - if((peersOnCall != null)&&(peersOnCall.size() != 0)) { + if(peersOnCall!=null){ + if(peersOnCall.size() != 0){ + boolean changes = false; + //Get all participant and check it + for (int i = 0; i < callChat.getParticipants().size(); i++) { boolean peerContain = false; - for (InfoPeerGroupCall peer : peersOnCall) { - if (peer.getHandle().equals(userHandle)) { + Long userHandler = callChat.getParticipants().get(i); + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle() == userHandler) { peerContain = true; break; } } if (!peerContain) { - if(userHandle != megaChatApi.getMyUserHandle()){ - MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if (userHandler != megaChatApi.getMyUserHandle()) { + + MegaChatSession userSession = callChat.getMegaChatSession(userHandler); if(userSession!=null){ - if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - peersOnCall.add(0, userPeer); + if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandler, chat.getPeerFullnameByHandle(userHandler), userSession.hasVideo(), userSession.hasAudio(), false,null); + peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); changes = true; } } - }else{ + } else { InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - peersOnCall.add(myPeer); changes = true; } } } - } - if(changes){ - updatePeers(true); - } - - }else{ - boolean changes = false; - for(int i = 0; i < callChat.getParticipants().size(); i++){ - long userHandle = callChat.getParticipants().get(i); - if(userHandle != megaChatApi.getMyUserHandle()){ - MegaChatSession userSession = callChat.getMegaChatSession(userHandle); - if(userSession!=null){ - if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - peersOnCall.add(0, userPeer); - changes = true; + for (int i = 0; i < peersOnCall.size(); i++) { + boolean peerContained = false; + for (int j = 0; j < callChat.getParticipants().size(); j++) { + long userHandle = callChat.getParticipants().get(j); + if (peersOnCall.get(i).getHandle() == userHandle){ + peerContained = true; + break; } } - }else{ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + if (!peerContained) { + peersOnCall.remove(i); + changes = true; + } + } + if(changes){ + updatePeers(true); + } - peersOnCall.add(myPeer); - changes = true; + }else{ + boolean changes = false; + for(int i = 0; i < callChat.getParticipants().size(); i++){ + long userHandle = callChat.getParticipants().get(i); + if(userHandle != megaChatApi.getMyUserHandle()){ + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession!=null){ + if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); + changes = true; + } + } + }else{ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + peersOnCall.add(myPeer); + changes = true; + } + } + if(changes){ + updatePeers(true); } - } - if(changes){ - updatePeers(true); } } }else{ - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - flagMyAvatar = false; - setProfileMyAvatar(); - flagContactAvatar = true; - setProfileContactAvatar(); + + callChat = megaChatApi.getChatCall(chatId); + if (callChat == null){ + + }else{ + int callStatus = callChat.getStatus(); + if(callStatus == MegaChatCall.CALL_STATUS_RING_IN){ + log("updateScreenStatusInProgress() - RING IN"); + + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; + relativeVideo.requestLayout(); + myAvatarLayout.setVisibility(View.VISIBLE); + contactAvatarLayout.setVisibility(View.VISIBLE); + flagMyAvatar = true; + setProfileMyAvatar(); + flagContactAvatar = false; + setProfileContactAvatar(); + + }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log(" updateScreenStatusInProgress() - IN PROGRESS"); + + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.requestLayout(); + myAvatarLayout.setVisibility(View.VISIBLE); + contactAvatarLayout.setVisibility(View.VISIBLE); + flagMyAvatar = true; + setProfileMyAvatar(); + flagContactAvatar = false; + setProfileContactAvatar(); + + }else{ + log("updateScreenStatusInProgress() - OUTGOING"); + + relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; + relativeVideo.requestLayout(); + flagMyAvatar = false; + setProfileMyAvatar(); + flagContactAvatar = true; + setProfileContactAvatar(); + myAvatarLayout.setVisibility(View.VISIBLE); + } + } +// +// flagMyAvatar = false; +// setProfileMyAvatar(); +// flagContactAvatar = true; +// setProfileContactAvatar(); + + + + } updateLocalVideoStatus(); @@ -406,7 +468,6 @@ public void updateSubTitle(){ int sessionStatus = -1; if(callChat.getStatus()<=MegaChatCall.CALL_STATUS_RING_IN){ -// aB.setSubtitle(getString(R.string.call_starting)); subtitleToobar.setText(getString(R.string.call_starting)); }else if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ @@ -423,17 +484,14 @@ public void updateSubTitle(){ if(sessionStatus==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ startClock(); }else{ -// aB.setSubtitle(getString(R.string.chat_connecting)); subtitleToobar.setText(getString(R.string.chat_connecting)); } }else{ log("Error getting the session of the user"); -// aB.setSubtitle(null); subtitleToobar.setText(null); } } }else{ -// aB.setSubtitle(null); subtitleToobar.setText(null); } @@ -448,10 +506,142 @@ protected void onNewIntent(Intent intent) { if (extras != null) { long newChatId = extras.getLong("chatHandle", -1); log("New chat id: "+newChatId); - if(chatId==newChatId){ + if(chatId == newChatId){ log("Its the same call"); + callChat = megaChatApi.getChatCall(chatId); + + if(callChat.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ + log(" onNewIntent() CALL_STATUS_RING_IN -> participants: "+callChat.getParticipants().size()); + + boolean isMe = false; + for(int i = 0; i < callChat.getParticipants().size(); i++){ + Long userHandle = callChat.getParticipants().get(i); + if (userHandle.equals(megaChatApi.getMyUserHandle())) { + isMe = true; + break; + } + } + + if(!isMe){ + if(peersBeforeCall!=null){ + if(peersBeforeCall.size()!=0){ + boolean changes = false; + for(int i = 0; i < callChat.getParticipants().size(); i++){ + boolean peerContain = false; + long userHandle = callChat.getParticipants().get(i); + for(InfoPeerGroupCall peerBeforeCall: peersBeforeCall){ + if(peerBeforeCall.getHandle() == userHandle){ + peerContain = true; + break; + } + } + if(!peerContain){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); + changes = true; + } + } + for(int i=0;i participants: "+callChat.getParticipants().size()); + if(peersOnCall != null){ + if(peersOnCall.size() != 0){ + boolean changes = false; + //Get all participant and check it + for (int i = 0; i < callChat.getParticipants().size(); i++) { + boolean peerContain = false; + Long userHandle = callChat.getParticipants().get(i); + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle().equals(userHandle)) { + peerContain = true; + break; + } + } + if (!peerContain) { + if (userHandle.equals(megaChatApi.getMyUserHandle())) { + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, null); + peersOnCall.add(myPeer); + changes = true; + } else { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); + peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + changes = true; + } + } + } + for (int i = 0; i < peersOnCall.size(); i++) { + boolean peerContained = false; + for (int j = 0; j < callChat.getParticipants().size(); j++) { + long userHandle = callChat.getParticipants().get(j); + if (peersOnCall.get(i).getHandle() == userHandle){ + peerContained = true; + break; + } + } + if (!peerContained) { + peersOnCall.remove(i); + changes = true; + } + } + if(changes){ + updatePeers(true); + } + + }else{ + boolean changes = false; + for(int i=0; i= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); } @@ -1384,20 +1595,16 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("CALL_STATUS_IN_PROGRESS add MyPeer A"); peersOnCall.add(myPeer); updatePeers(true); } }else{ if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ for(InfoPeerGroupCall peerBefore: peersBeforeCall){ - log("CALL_STATUS_IN_PROGRESS add "+peerBefore.getName()+" in peersOnCall"); - peersOnCall.add(peerBefore); - - } + peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), peerBefore); + } } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); - log("CALL_STATUS_IN_PROGRESS add MyPeer B"); peersOnCall.add(myPeer); updatePeers(true); } @@ -1442,6 +1649,38 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { stopAudioSignals(); rtcAudioManager.stop(); MegaApplication.activityPaused(); + if (bigCameraGroupCallFragment != null) { + bigCameraGroupCallFragment.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + super.finishAndRemoveTask(); + } + else { + super.finish(); + } + }else{ + if (localCameraFragment != null) { + localCameraFragment.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(localCameraFragment); + localCameraFragment = null; + } + if (localCameraFragmentFS != null) { + localCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(localCameraFragmentFS); + localCameraFragmentFS = null; + } + if (remoteCameraFragmentFS != null) { + remoteCameraFragmentFS.setVideoFrame(false); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.remove(remoteCameraFragmentFS); + remoteCameraFragmentFS = null; + } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); @@ -1451,6 +1690,9 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } + + + break; } case MegaChatCall.CALL_STATUS_USER_NO_PRESENT:{ @@ -1477,7 +1719,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ - log("CHANGE_TYPE_SESSION_STATUS"); + log("#### CHANGE_TYPE_SESSION_STATUS"); if(chat.isGroup()){ @@ -1490,107 +1732,107 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("SESSION_STATUS_IN_PROGRESS"); - updateSubTitle(); //contact joined the group call log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - - boolean peerContain = false; - for(InfoPeerGroupCall peer : peersOnCall) { - if (peer.getHandle().equals(userHandle)) { - peerContain = true; - break; - } - } - if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); - peersOnCall.add(0, userPeer); - - if(peersOnCall.size()<7){ - if(adapterGrid != null){ - if(peersOnCall.size()< 4){ - recyclerView.setColumnWidth((int) widthScreenPX); - recyclerViewLayout.setPadding(0,0,0,0); - - }else{ - recyclerView.setColumnWidth((int) widthScreenPX/2); - if(peersOnCall.size() == 4){ - recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); - }else{ - recyclerViewLayout.setPadding(0,0,0,0); - } - } - adapterGrid.notifyItemInserted(0); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubtitleToolbar(); - }else{ - updatePeers(true); - } - }else{ - if(adapterList != null){ - adapterList.notifyItemInserted(0); - adapterList.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubtitleToolbar(); - }else{ - updatePeers(true); - } - } - } - } +// if((peersOnCall != null)&&(peersOnCall.size() != 0)){ +// +// boolean peerContain = false; +// for(InfoPeerGroupCall peer : peersOnCall) { +// if (peer.getHandle().equals(userHandle)) { +// peerContain = true; +// break; +// } +// } +// if(!peerContain){ +// InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); +// log("#### SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); +// peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); +// +//// peersOnCall.add(0, userPeer); +// +// if(peersOnCall.size()<7){ +// if(adapterGrid != null){ +// if(peersOnCall.size()< 4){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// recyclerViewLayout.setPadding(0,0,0,0); +// +// }else{ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// if(peersOnCall.size() == 4){ +// recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); +// }else{ +// recyclerViewLayout.setPadding(0,0,0,0); +// } +// } +// adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); +// +// updateSubtitleToolbar(); +// }else{ +// updatePeers(true); +// } +// }else{ +// if(adapterList != null){ +// adapterList.notifyItemInserted((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1))); +// adapterList.notifyItemRangeChanged(0, peersOnCall.size()); +// updateSubtitleToolbar(); +// }else{ +// updatePeers(true); +// } +// } +// } +// } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ log("SESSION_STATUS_DESTROYED "); - updateSubTitle(); //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); - if((peersOnCall != null)&&(peersOnCall.size() != 0)){ - - for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); - peersOnCall.remove(i); - if(peersOnCall.size()<7){ - - if(adapterGrid != null){ - if(peersOnCall.size()< 4){ - recyclerView.setColumnWidth((int) widthScreenPX); - recyclerViewLayout.setPadding(0,0,0,0); - - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - }else{ - recyclerView.setColumnWidth((int) widthScreenPX/2); - if(peersOnCall.size() == 4){ - recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); - }else{ - recyclerViewLayout.setPadding(0,0,0,0); - } - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - } - updateSubtitleToolbar(); - }else{ - updatePeers(true); - } - - }else{ - if(adapterList != null){ - adapterList.notifyItemRemoved(i); - adapterList.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubtitleToolbar(); - }else{ - updatePeers(true); - } - } - break; - } - } - } +// if((peersOnCall != null)&&(peersOnCall.size() != 0)){ +// +// for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); +// peersOnCall.remove(i); +// if(peersOnCall.size()<7){ +// +// if(adapterGrid != null){ +// if(peersOnCall.size()< 4){ +// recyclerView.setColumnWidth((int) widthScreenPX); +// recyclerViewLayout.setPadding(0,0,0,0); +// adapterGrid.notifyItemRemoved(i); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); +// }else{ +// recyclerView.setColumnWidth((int) widthScreenPX/2); +// if(peersOnCall.size() == 4){ +// recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); +// }else{ +// recyclerViewLayout.setPadding(0,0,0,0); +// } +// adapterGrid.notifyItemRemoved(i); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); +// } +// updateSubtitleToolbar(); +// }else{ +// updatePeers(true); +// } +// +// }else{ +// if(adapterList != null){ +// adapterList.notifyItemRemoved(i); +// adapterList.notifyItemRangeChanged(0, peersOnCall.size()); +// updateSubtitleToolbar(); +// }else{ +// updatePeers(true); +// } +// } +// break; +// } +// } +// } } updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1601,7 +1843,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ updateSubTitle(); } - updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); updateLocalVideoStatus(); @@ -1629,13 +1870,13 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ - log("CHANGE_TYPE_CALL_COMPOSITION -> participants: "+call.getParticipants().size()); if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ + log("CHANGE_TYPE_CALL_COMPOSITION RING IN -> participants: "+call.getParticipants().size()); boolean isMe = false; for(int i = 0; i < call.getParticipants().size(); i++){ - Long userHandle = call.getParticipants().get(i); - if (userHandle.equals(megaChatApi.getMyUserHandle())) { + long userHandle = call.getParticipants().get(i); + if (userHandle == megaChatApi.getMyUserHandle()){ isMe = true; break; } @@ -1648,15 +1889,14 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ boolean peerContain = false; long userHandle = call.getParticipants().get(i); for(InfoPeerGroupCall peerBeforeCall: peersBeforeCall){ - if(peerBeforeCall.getHandle().equals(userHandle)){ + if(peerBeforeCall.getHandle() == userHandle){ peerContain = true; break; } } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); - log("CHANGE_TYPE_CALL_COMPOSITION -> "+userPeer.getName()+" added"); - peersBeforeCall.add(0, userPeer); + peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; } } @@ -1669,10 +1909,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } if(!peerContained){ - log("CHANGE_TYPE_CALL_COMPOSITION -> "+peersBeforeCall.get(i).getName()+" removed"); peersBeforeCall.remove(i); changes = true; - } } @@ -1681,8 +1919,108 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } - } + }else if(call.getStatus() == MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("CHANGE_TYPE_CALL_COMPOSITION IN PROGRESS -> participants: "+call.getParticipants().size()); + if((peersOnCall != null)&&(peersOnCall.size() != 0)) { + //Get all participant and check it + for (int i = 0; i < call.getParticipants().size(); i++) { + boolean peerContain = false; + long userHandle = call.getParticipants().get(i); + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle() == userHandle) { + peerContain = true; + break; + } + } + if (!peerContain) { + if (userHandle == megaChatApi.getMyUserHandle()){ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, null); + peersOnCall.add(myPeer); + updatePeers(true); + } else { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); + peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + + if (peersOnCall.size() < 7) { + if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX); + }else{ + if(peersOnCall.size() == 4) { + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + }else{ + recyclerViewLayout.setPadding(0, 0, 0, 0); + } + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubTitle(); + updateSubtitleToolbar(); + }else{ + updatePeers(true); + } + } else { + if (adapterList != null) { + adapterList.notifyItemInserted((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1))); + adapterList.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubTitle(); + updateSubtitleToolbar(); + } else { + updatePeers(true); + } + } + } + } + } + for (int i = 0; i < peersOnCall.size(); i++) { + boolean peerContained = false; + for (int j = 0; j < call.getParticipants().size(); j++) { + long userHandle = call.getParticipants().get(j); + if (peersOnCall.get(i).getHandle() == userHandle){ + peerContained = true; + break; + } + } + if (!peerContained) { + peersOnCall.remove(i); + if (peersOnCall.size() < 7) { + + if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX); + } else { + if (peersOnCall.size() == 4) { + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + } else { + recyclerViewLayout.setPadding(0, 0, 0, 0); + } + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubTitle(); + updateSubtitleToolbar(); + } else { + updatePeers(true); + } + } else { + if (adapterList != null) { + adapterList.notifyItemRemoved(i); + adapterList.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubTitle(); + updateSubtitleToolbar(); + } else { + updatePeers(true); + } + } + } + } + } + } }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_AUDIO_LEVEL)) { log("onChatCallUpdate()-CHANGE_TYPE_SESSION_AUDIO_LEVEL"); @@ -2164,7 +2502,6 @@ public void updateLocalVideoStatus(){ log("callStatus: CALL_STATUS_REQUEST_SENT"); if(localCameraFragmentFS == null){ - log("CREATE localCameraFragmentFS"); localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); @@ -2176,10 +2513,11 @@ public void updateLocalVideoStatus(){ fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("callStatus: CALL_STATUS_IN_PROGRESS"); + log(" callStatus: CALL_STATUS_IN_PROGRESS"); + + log("callStatus: parentLocal.CHILDS: "+parentLocal.getChildCount()); if(localCameraFragment == null){ - log("CREATE localCameraFragment"); localCameraFragment = LocalCameraCallFragment.newInstance(chatId); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); @@ -2199,7 +2537,6 @@ public void updateLocalVideoStatus(){ log("callStatus: CALL_STATUS_REQUEST_SENT"); if (localCameraFragmentFS != null) { - log("REMOVE localCameraFragmentFS"); localCameraFragmentFS.setVideoFrame(false); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); @@ -2211,9 +2548,8 @@ public void updateLocalVideoStatus(){ }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("callStatus: CALL_STATUS_IN_PROGRESS"); + log("callStatus: CALL_STATUS_IN_PROGRESS "); if (localCameraFragment != null) { - log("REMOVE localCameraFragment"); localCameraFragment.setVideoFrame(false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(localCameraFragment); @@ -2399,7 +2735,7 @@ public void updateRemoteVideoStatus(long userHandle){ fragmentContainerRemoteCameraFS.setVisibility(View.GONE); } }else{ - if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(!userSession.hasVideo())){ + if((isRemoteVideo==REMOTE_VIDEO_ENABLED)&&(userSession!=null)&&(!userSession.hasVideo())){ isRemoteVideo = REMOTE_VIDEO_DISABLED; if (remoteCameraFragmentFS != null) { @@ -2414,7 +2750,7 @@ public void updateRemoteVideoStatus(long userHandle){ parentRemoteFS.setVisibility(View.GONE); fragmentContainerRemoteCameraFS.setVisibility(View.GONE); - }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession.hasVideo())){ + }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession!=null)&&(userSession.hasVideo())){ isRemoteVideo = REMOTE_VIDEO_ENABLED; if(remoteCameraFragmentFS == null){ @@ -2709,11 +3045,14 @@ public void animationAlphaArrows(final ImageView arrow){ public void updateSubtitleToolbar(){ int cont = 0; - for(int i=0;i peers, long chatId, boolean isCallInProgress) { @@ -99,7 +84,6 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList - - - - - - - - - - - - - From 152af389a295c0f411371e1e98fb122fe763e365 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 20 Nov 2018 21:55:22 +0100 Subject: [PATCH 112/247] Group calls UI --- .../megachat/ChatActivityLollipop.java | 8 +- .../calls/BigCameraGroupCallFragment.java | 32 ++-- .../megachat/calls/ChatCallActivity.java | 165 ++++++++++-------- .../calls/LocalCameraCallFragment.java | 51 +++--- .../LocalCameraCallFullScreenFragment.java | 25 +-- .../RemoteCameraCallFullScreenFragment.java | 36 ++-- 6 files changed, 157 insertions(+), 160 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 64a2570ccf2..b3c1198e4ac 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -7029,25 +7029,19 @@ public void showJumpMessage(){ @Override public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { - log("onChatCallUpdate"); + log("onChatCallUpdate()"); if(call.getChatid()==idChat){ - log(" call.getStatus(): "+call.getStatus()); if(call.getStatus()==MegaChatCall.CALL_STATUS_DESTROYED){ - log("CALL_STATUS_DESTROYED"); callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log(" CALL_STATUS_IN_PROGRESS"); - callInProgressLayout.setVisibility(View.VISIBLE); callInProgressLayout.setOnClickListener(this); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ - log("CALL_STATUS_RING_IN"); - long openCallChatId = MegaApplication.getOpenCallChatId(); log("openCallId: "+openCallChatId); if(openCallChatId!=-1){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index c8f1aee1b2b..e0f0f27375f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -55,8 +55,8 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); - this.width = 0; - this.height = 0; +// this.width = 0; +// this.height = 0; super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -83,7 +83,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); } - return v; } @@ -122,22 +121,12 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app renderer.DrawBitmap(false); } } - - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - context = activity; - } - - @Override public void onAttach(Context context) { super.onAttach(context); @@ -149,8 +138,6 @@ public void onDestroy(){ if(fullScreenSurfaceView.getParent()!=null){ if(fullScreenSurfaceView.getParent().getParent()!=null){ ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); - }else{ - ((ViewGroup)fullScreenSurfaceView.getParent()).removeAllViewsInLayout(); } } if(userHandle.equals(megaChatApi.getMyUserHandle())){ @@ -168,12 +155,17 @@ public void onResume() { super.onResume(); } - public void setVideoFrame(boolean visible){ - if(visible){ - fullScreenSurfaceView.setVisibility(View.VISIBLE); + public void removeSurfaceView(){ + log("removeSurfaceView()"); + if(fullScreenSurfaceView.getParent()!=null){ + if(fullScreenSurfaceView.getParent().getParent()!=null){ + ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); + } } - else{ - fullScreenSurfaceView.setVisibility(View.GONE); + if(userHandle.equals(megaChatApi.getMyUserHandle())){ + megaChatApi.removeChatVideoListener(chatId, -1, this); + }else{ + megaChatApi.removeChatVideoListener(chatId, userHandle, this); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 56e5a3daedc..177d86f30e4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -6,6 +6,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.ColorStateList; + import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -202,7 +203,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ViewGroup parentLocalFS; ViewGroup parentRemoteFS; - private LocalCameraCallFragment localCameraFragment; + private LocalCameraCallFragment localCameraFragment = null; private LocalCameraCallFullScreenFragment localCameraFragmentFS = null; private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null; @@ -397,6 +398,7 @@ public void updateScreenStatusInProgress(){ } }else{ + log("updateScreenStatusInProgress() chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); if (callChat == null){ @@ -404,7 +406,7 @@ public void updateScreenStatusInProgress(){ }else{ int callStatus = callChat.getStatus(); if(callStatus == MegaChatCall.CALL_STATUS_RING_IN){ - log("updateScreenStatusInProgress() - RING IN"); + log("updateScreenStatusInProgress() - CALL_STATUS_RING_IN"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -417,11 +419,12 @@ public void updateScreenStatusInProgress(){ setProfileContactAvatar(); }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log(" updateScreenStatusInProgress() - IN PROGRESS"); + log("updateScreenStatusInProgress() - CALL_STATUS_IN_PROGRESS"); relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.requestLayout(); + myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; @@ -511,7 +514,6 @@ protected void onNewIntent(Intent intent) { callChat = megaChatApi.getChatCall(chatId); if(callChat.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ - log(" onNewIntent() CALL_STATUS_RING_IN -> participants: "+callChat.getParticipants().size()); boolean isMe = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ @@ -641,7 +643,7 @@ protected void onNewIntent(Intent intent) { } }else{ - log("New intent to the activity with a new chatId: "+newChatId); + log(" It is not the same: "+newChatId); //Check the new call if in progress chatId = newChatId; chat = megaChatApi.getChatRoom(chatId); @@ -764,7 +766,6 @@ protected void onCreate(Bundle savedInstanceState) { aB.setDisplayHomeAsUpEnabled(true); aB.setTitle(null); aB.setSubtitle(null); -// aB.setTitle(" "); toolbarElements = (LinearLayout) tB.findViewById(R.id.toolbar_elements); titleToolbar = (TextView) tB.findViewById(R.id.title_toolbar); @@ -1024,7 +1025,7 @@ protected void onCreate(Bundle savedInstanceState) { } } }else{ - log("Incoming individual call"); + log(" onCreate()-Incoming individual call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -1038,7 +1039,7 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("InProgress"); + log("onCreate()- In Progress"); updateScreenStatusInProgress(); }else{ int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); @@ -1069,7 +1070,7 @@ protected void onCreate(Bundle savedInstanceState) { updatePeers(true); }else{ - log("Outgoing individual call"); + log("onCreate()-Outgoing individual call"); relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -1408,26 +1409,34 @@ public void onDestroy(){ } clearHandlers(); - if (localCameraFragment != null) { - localCameraFragment.setVideoFrame(false); + localCameraFragment.removeSurfaceView(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(localCameraFragment); localCameraFragment = null; } + if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); + localCameraFragmentFS.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); localCameraFragmentFS = null; } if (remoteCameraFragmentFS != null) { - remoteCameraFragmentFS.setVideoFrame(false); + remoteCameraFragmentFS.removeSurfaceView(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); remoteCameraFragmentFS = null; } + if (bigCameraGroupCallFragment != null) { + bigCameraGroupCallFragment.removeSurfaceView(); + FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); + ftFS.remove(bigCameraGroupCallFragment); + bigCameraGroupCallFragment = null; + } + + peerSelected = null; isManualMode = false; @@ -1570,10 +1579,11 @@ public void onRequestTemporaryError(MegaChatApiJava api, MegaChatRequest request @Override public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { - log("onChatCallUpdate() "); + log("onChatCallUpdate()"); if(call.getChatid()==chatId){ this.callChat = call; + log("onChatCallUpdate() call.getChatid() = chatId = "+chatId); if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){ log("CHANGE_TYPE_STATUS"); @@ -1612,12 +1622,15 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { updateLocalAudioStatus(); }else{ + log("onChatCallUpdate() - CALL_STATUS_IN_PROGRESS"); + flagMyAvatar = true; setProfileMyAvatar(); flagContactAvatar = false; setProfileContactAvatar(); if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); + log("remove localCameraFragmentFS"); + localCameraFragmentFS.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); localCameraFragmentFS = null; @@ -1650,7 +1663,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { rtcAudioManager.stop(); MegaApplication.activityPaused(); if (bigCameraGroupCallFragment != null) { - bigCameraGroupCallFragment.setVideoFrame(false); + bigCameraGroupCallFragment.removeSurfaceView();; FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -1663,31 +1676,35 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { super.finish(); } }else{ - if (localCameraFragment != null) { - localCameraFragment.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(localCameraFragment); - localCameraFragment = null; - } - if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(localCameraFragmentFS); - localCameraFragmentFS = null; - } - if (remoteCameraFragmentFS != null) { - remoteCameraFragmentFS.setVideoFrame(false); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.remove(remoteCameraFragmentFS); - remoteCameraFragmentFS = null; - } + log("onChatCallUpdate() - CALL_STATUS_TERMINATING_USER_PARTICIPATION"); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - super.finishAndRemoveTask(); - } - else { - super.finish(); - } +// if (localCameraFragment != null) { +// log("CALL_STATUS_TERMINATING_USER_PARTICIPATION localCameraFragment != null"); +// +// localCameraFragment.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(localCameraFragment); +// localCameraFragment = null; +// } +// if (localCameraFragmentFS != null) { +// localCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(localCameraFragmentFS); +// localCameraFragmentFS = null; +// } +// if (remoteCameraFragmentFS != null) { +// remoteCameraFragmentFS.setVideoFrame(false); +// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); +// ft.remove(remoteCameraFragmentFS); +// remoteCameraFragmentFS = null; +// } +// +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// super.finishAndRemoveTask(); +// } +// else { +// super.finish(); +// } } @@ -1701,6 +1718,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ + log("onChatCallUpdate() - CALL_STATUS_DESTROYED"); + log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); //The group call has finished but I can not join again @@ -1719,7 +1738,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ - log("#### CHANGE_TYPE_SESSION_STATUS"); + log("CHANGE_TYPE_SESSION_STATUS"); if(chat.isGroup()){ @@ -1747,7 +1766,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ // } // if(!peerContain){ // InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); -// log("#### SESSION_STATUS_IN_PROGRESS -> "+userPeer.getName()+" added"); // peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); // //// peersOnCall.add(0, userPeer); @@ -1795,7 +1813,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ // // for(int i=0;i "+peersOnCall.get(i).getName()+" removed"); // peersOnCall.remove(i); // if(peersOnCall.size()<7){ // @@ -1840,6 +1857,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateLocalAudioStatus(); } }else{ + log("onChatCallUpdate() - CHANGE_TYPE_SESSION_STATUS"); + if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ updateSubTitle(); } @@ -2020,6 +2039,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } } + } }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_AUDIO_LEVEL)) { log("onChatCallUpdate()-CHANGE_TYPE_SESSION_AUDIO_LEVEL"); @@ -2494,7 +2514,7 @@ public void updateLocalVideoStatus(){ log("is individual"); if (callChat.hasLocalVideo()) { - log("Video local connected"); + log("Video local connected: chatId: "+chatId); videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white)); @@ -2502,8 +2522,8 @@ public void updateLocalVideoStatus(){ log("callStatus: CALL_STATUS_REQUEST_SENT"); if(localCameraFragmentFS == null){ + log("create localCameraFragmentFS"); localCameraFragmentFS = LocalCameraCallFullScreenFragment.newInstance(chatId); - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.replace(R.id.fragment_container_local_cameraFS, localCameraFragmentFS, "localCameraFragmentFS"); ftFS.commitNowAllowingStateLoss(); @@ -2513,15 +2533,15 @@ public void updateLocalVideoStatus(){ fragmentContainerLocalCameraFS.setVisibility(View.VISIBLE); }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log(" callStatus: CALL_STATUS_IN_PROGRESS"); - - log("callStatus: parentLocal.CHILDS: "+parentLocal.getChildCount()); + log("callStatus: CALL_STATUS_IN_PROGRESS"); if(localCameraFragment == null){ + log("create localCameraFragment"); localCameraFragment = LocalCameraCallFragment.newInstance(chatId); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_local_camera, localCameraFragment, "localCameraFragment"); ft.commitNowAllowingStateLoss(); + } myAvatarLayout.setVisibility(GONE); parentLocal.setVisibility(View.VISIBLE); @@ -2529,7 +2549,7 @@ public void updateLocalVideoStatus(){ } }else { - log("Video local NOT connected"); + log("Video local NOT connected: chatId: "+chatId); videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call))); videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off)); @@ -2537,7 +2557,8 @@ public void updateLocalVideoStatus(){ log("callStatus: CALL_STATUS_REQUEST_SENT"); if (localCameraFragmentFS != null) { - localCameraFragmentFS.setVideoFrame(false); + log("remove localCameraFragmentFS"); + localCameraFragmentFS.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(localCameraFragmentFS); localCameraFragmentFS = null; @@ -2546,11 +2567,11 @@ public void updateLocalVideoStatus(){ fragmentContainerLocalCameraFS.setVisibility(View.GONE); contactAvatarLayout.setVisibility(View.VISIBLE); - }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("callStatus: CALL_STATUS_IN_PROGRESS "); if (localCameraFragment != null) { - localCameraFragment.setVideoFrame(false); + log("remove localCameraFragment"); + localCameraFragment.removeSurfaceView(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(localCameraFragment); localCameraFragment = null; @@ -2700,14 +2721,14 @@ public void updateRemoteVideoStatus(long userHandle){ log("is individual"); MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); - if(isRemoteVideo== REMOTE_VIDEO_NOT_INIT){ + if(isRemoteVideo == REMOTE_VIDEO_NOT_INIT){ if(userSession!=null && userSession.hasVideo()){ log("Video remote connected"); isRemoteVideo = REMOTE_VIDEO_ENABLED; if(remoteCameraFragmentFS == null){ - log("CREATE remoteCameraFragmentFS"); + log("create remoteCameraFragmentFS"); remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); @@ -2723,8 +2744,8 @@ public void updateRemoteVideoStatus(long userHandle){ isRemoteVideo = REMOTE_VIDEO_DISABLED; if (remoteCameraFragmentFS != null) { - log("REMOVE remoteCameraFragmentFS"); - remoteCameraFragmentFS.setVideoFrame(false); + log("remove remoteCameraFragmentFS"); + remoteCameraFragmentFS.removeSurfaceView(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); remoteCameraFragmentFS = null; @@ -2739,8 +2760,8 @@ public void updateRemoteVideoStatus(long userHandle){ isRemoteVideo = REMOTE_VIDEO_DISABLED; if (remoteCameraFragmentFS != null) { - log("REMOVE remoteCameraFragmentFS"); - remoteCameraFragmentFS.setVideoFrame(false); + log("remove remoteCameraFragmentFS"); + remoteCameraFragmentFS.removeSurfaceView(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(remoteCameraFragmentFS); remoteCameraFragmentFS = null; @@ -2753,17 +2774,17 @@ public void updateRemoteVideoStatus(long userHandle){ }else if((isRemoteVideo==REMOTE_VIDEO_DISABLED)&&(userSession!=null)&&(userSession.hasVideo())){ isRemoteVideo = REMOTE_VIDEO_ENABLED; - if(remoteCameraFragmentFS == null){ - log("CREATE remoteCameraFragmentFS"); - remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); - ft.commitNowAllowingStateLoss(); - } - contactAvatarLayout.setOnClickListener(null); - contactAvatarLayout.setVisibility(GONE); - parentRemoteFS.setVisibility(View.VISIBLE); - fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); + if(remoteCameraFragmentFS == null){ + log("create remoteCameraFragmentFS"); + remoteCameraFragmentFS = RemoteCameraCallFullScreenFragment.newInstance(chatId, chat.getPeerHandle(0)); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.fragment_container_remote_cameraFS, remoteCameraFragmentFS, "remoteCameraFragmentFS"); + ft.commitNowAllowingStateLoss(); + } + contactAvatarLayout.setOnClickListener(null); + contactAvatarLayout.setVisibility(GONE); + parentRemoteFS.setVisibility(View.VISIBLE); + fragmentContainerRemoteCameraFS.setVisibility(View.VISIBLE); } } @@ -3346,7 +3367,7 @@ public void updateUserSelected(boolean flag){ //First time: //Remove Camera element, because with incoming, avatar is the only showed if (bigCameraGroupCallFragment != null) { - bigCameraGroupCallFragment.setVideoFrame(false); + bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -3373,7 +3394,7 @@ public void createBigFragment(Long handle){ //Remove big Camera if(bigCameraGroupCallFragment != null){ log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.setVideoFrame(false); + bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -3407,7 +3428,7 @@ public void createBigAvatar(Long handle, String fullName){ //Remove big Camera if (bigCameraGroupCallFragment != null) { log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.setVideoFrame(false); + bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java index 3d742298703..6053fc4a85a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java @@ -31,11 +31,11 @@ public class LocalCameraCallFragment extends Fragment implements MegaChatVideoLi Context context; long chatId; - SurfaceView localSurfaceView = null; + public SurfaceView localSurfaceView; MegaSurfaceRenderer localRenderer; public static LocalCameraCallFragment newInstance(long chatId) { - log("#### newInstance: cID: "+chatId); + log("newInstance() chatId: "+chatId); LocalCameraCallFragment f = new LocalCameraCallFragment(); Bundle args = new Bundle(); @@ -46,15 +46,15 @@ public static LocalCameraCallFragment newInstance(long chatId) { @Override public void onCreate (Bundle savedInstanceState){ - log("onCreate cID: "+chatId); + if (megaChatApi == null){ megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); } - this.width = 0; - this.height = 0; - this.localSurfaceView = null; +// this.width = 0; +// this.height = 0; Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); + log("onCreate() chatId: "+this.chatId); super.onCreate(savedInstanceState); log("after onCreate called super"); @@ -68,15 +68,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa } View v = inflater.inflate(R.layout.fragment_local_camera_call, container, false); - this.width = 0; - this.height = 0; - localSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); + localSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); localSurfaceView.setZOrderOnTop(true); SurfaceHolder localSurfaceHolder = localSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); localRenderer = new MegaSurfaceRenderer(localSurfaceView); + log("onCreate() addChatLocalVideoListener chatId: "+chatId); megaChatApi.addChatLocalVideoListener(chatId, this); return v; @@ -84,7 +83,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { - if((width == 0) || (height == 0)){ return; } @@ -121,13 +119,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - context = activity; - } - - @Override public void onAttach(Context context) { super.onAttach(context); @@ -140,32 +131,36 @@ public void onDestroy(){ if(localSurfaceView.getParent()!=null){ if(localSurfaceView.getParent().getParent()!=null){ + log("onDestroy() removeView chatId: "+chatId); ((ViewGroup)localSurfaceView.getParent()).removeView(localSurfaceView); - }else{ - ((ViewGroup)localSurfaceView.getParent()).removeAllViewsInLayout(); } } + + log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+this.chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); super.onDestroy(); } @Override public void onResume() { - log("onResume"); + log("onResume()"); this.width=0; this.height=0; super.onResume(); } - - public void setVideoFrame(boolean visible){ - log("setVideoFrame: "+visible); - if(visible){ - localSurfaceView.setVisibility(View.VISIBLE); - } - else{ - localSurfaceView.setVisibility(View.GONE); + public void removeSurfaceView(){ + log("removeSurfaceView()"); + if(localSurfaceView.getParent()!=null){ + if(localSurfaceView.getParent().getParent()!=null){ + log("removeSurfaceView() removeView chatId: "+this.chatId); + ((ViewGroup)localSurfaceView.getParent()).removeView(localSurfaceView); + } } + + log("emoveSurfaceView() removeChatVideoListener (LOCAL)chatId: "+this.chatId); + megaChatApi.removeChatVideoListener(this.chatId, -1, this); } + private static void log(String log) { Util.log("LocalCameraCallFragment", log); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java index 1b67e4e74f4..6e340f72b2d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java @@ -74,6 +74,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); localRenderer = new MegaSurfaceRenderer(localFullScreenSurfaceView); + log("onCreate() addChatLocalVideoListener chatId: "+this.chatId); megaChatApi.addChatLocalVideoListener(chatId, this); return v; @@ -120,14 +121,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - context = activity; - } - - @Override public void onAttach(Context context) { super.onAttach(context); @@ -139,8 +132,6 @@ public void onDestroy(){ if(localFullScreenSurfaceView.getParent()!=null){ if(localFullScreenSurfaceView.getParent().getParent()!=null){ ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView); - }else{ - ((ViewGroup)localFullScreenSurfaceView.getParent()).removeAllViewsInLayout(); } } megaChatApi.removeChatVideoListener(chatId, -1, this); @@ -153,14 +144,14 @@ public void onResume() { this.height=0; super.onResume(); } - - public void setVideoFrame(boolean visible){ - if(visible){ - localFullScreenSurfaceView.setVisibility(View.VISIBLE); - } - else{ - localFullScreenSurfaceView.setVisibility(View.GONE); + public void removeSurfaceView(){ + log("removeSurfaceView()"); + if(localFullScreenSurfaceView.getParent()!=null){ + if(localFullScreenSurfaceView.getParent().getParent()!=null){ + ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView); + } } + megaChatApi.removeChatVideoListener(chatId, -1, this); } private static void log(String log) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index 97d91fcebfd..acce72ecd2f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -37,7 +37,8 @@ public class RemoteCameraCallFullScreenFragment extends Fragment implements Mega MegaSurfaceRenderer remoteRenderer; public static RemoteCameraCallFullScreenFragment newInstance(long chatId, long userHandle) { - log("newInstance"); + log("newInstance() chatId: "+chatId); + RemoteCameraCallFullScreenFragment f = new RemoteCameraCallFullScreenFragment(); Bundle args = new Bundle(); @@ -57,13 +58,15 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); + log("onCreate() chatId: "+this.chatId); + super.onCreate(savedInstanceState); + log("after onCreate called super"); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - log("onCreateView"); if (!isAdded()) { return null; @@ -77,6 +80,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa SurfaceHolder remoteSurfaceHolder = remoteFullScreenSurfaceView.getHolder(); remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView); + + log("onCreate() addChatRemoteVideoListener chatId: "+this.chatId); megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); return v; @@ -84,7 +89,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer){ - log("onChatVideoData"); + log("onChatVideoData: chatid: "+chatid+" h("+height+"), w("+width+")"); if((width == 0) || (height == 0)){ return; @@ -117,19 +122,15 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app remoteRenderer.DrawBitmap(false); } } - - @Override public void onAttach(Context context) { log("onAttach"); - super.onAttach(context); this.context = context; } @@ -139,11 +140,12 @@ public void onDestroy(){ log("onDestroy"); if(remoteFullScreenSurfaceView.getParent()!=null){ if(remoteFullScreenSurfaceView.getParent().getParent()!=null){ + log("onDestroy() removeView chatId: "+this.chatId); ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); - }else{ - ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeAllViewsInLayout(); } } + + log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+this.chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); } @@ -156,14 +158,16 @@ public void onResume() { super.onResume(); } - public void setVideoFrame(boolean visible){ - log("setVideoFrame"); - if(visible){ - remoteFullScreenSurfaceView.setVisibility(View.VISIBLE); - } - else{ - remoteFullScreenSurfaceView.setVisibility(View.GONE); + public void removeSurfaceView(){ + log("removeSurfaceView()"); + if(remoteFullScreenSurfaceView.getParent()!=null){ + if(remoteFullScreenSurfaceView.getParent().getParent()!=null){ + log("removeSurfaceView() removeView chatId: "+this.chatId); + ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); + } } + log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+this.chatId); + megaChatApi.removeChatVideoListener(chatId, userHandle, this); } private static void log(String log) { From ca9a172eaa4e922f29c81abf9216c850b4058960 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 21 Nov 2018 12:39:16 +0100 Subject: [PATCH 113/247] Group calls UI --- .../megachat/ChatActivityLollipop.java | 17 +- .../megachat/calls/ChatCallActivity.java | 200 +++++++++++------- .../calls/LocalCameraCallFragment.java | 2 +- .../RemoteCameraCallFullScreenFragment.java | 7 +- .../chatAdapters/GroupCallAdapter.java | 187 +++++++--------- app/src/main/res/layout/activity_chat.xml | 5 - 6 files changed, 212 insertions(+), 206 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index b3c1198e4ac..3c841e4313b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -6637,21 +6637,27 @@ protected void onResume(){ MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); if(callInProgress != null){ + log("onResume() callStatus: "+callInProgress.getStatus()); + if((callInProgress.getStatus() >= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){ + log("onResume() CALL_STATUS_REQUEST_SENT - VISIBLE"); callInProgressLayout.setVisibility(View.VISIBLE); callInProgressText.setText(getString(R.string.call_in_progress_layout)); callInProgressLayout.setOnClickListener(this); } else if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); callInProgressLayout.setVisibility(View.VISIBLE); callInProgressText.setText(getString(R.string.join_call_layout)); callInProgressLayout.setOnClickListener(this); } else{ + log("onResume() other case - GONE"); callInProgressLayout.setVisibility(View.GONE); } } else{ + log("onResume() callInProgress != null - GONE"); callInProgressLayout.setVisibility(View.GONE); } @@ -7029,19 +7035,22 @@ public void showJumpMessage(){ @Override public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { - log("onChatCallUpdate()"); + log("onChatCallUpdate() status: "+call.getStatus()); if(call.getChatid()==idChat){ if(call.getStatus()==MegaChatCall.CALL_STATUS_DESTROYED){ + log("callInProgressLayout - CALL_STATUS_DESTROYED"); callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("callInProgressLayout - CALL_STATUS_IN_PROGRESS"); callInProgressLayout.setVisibility(View.VISIBLE); callInProgressLayout.setOnClickListener(this); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ + log("callInProgressLayout - CALL_STATUS_RING_IN "); long openCallChatId = MegaApplication.getOpenCallChatId(); log("openCallId: "+openCallChatId); if(openCallChatId!=-1){ @@ -7051,6 +7060,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { intent.putExtra("chatHandle", idChat); startActivity(intent); } + }else if(call.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + log("callInProgressLayout - CALL_STATUS_USER_NO_PRESENT"); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressLayout.setOnClickListener(this); + invalidateOptionsMenu(); + } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 177d86f30e4..f6858d09709 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -190,7 +190,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque FloatingActionButton microFAB; FloatingActionButton hangFAB; FloatingActionButton answerCallFAB; - boolean isNecesaryCreateAdapter = true; + boolean isNecessaryCreateAdapter = true; AudioManager audioManager; MediaPlayer thePlayer; @@ -467,7 +467,7 @@ public void updateScreenStatusInProgress(){ public void updateSubTitle(){ - log("updateSubTitle"); + log("updateSubTitle()"); int sessionStatus = -1; if(callChat.getStatus()<=MegaChatCall.CALL_STATUS_RING_IN){ @@ -478,6 +478,7 @@ public void updateSubTitle(){ startClock(); int totalParticipants = callChat.getNumParticipants() + 1; log("update subtitle: "+totalParticipants +" of "+chat.getPeerCount()); + updateSubtitleToolbar(); } else{ MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); @@ -966,7 +967,6 @@ protected void onCreate(Bundle savedInstanceState) { // aB.setTitle(chat.getTitle()); titleToolbar.setText(chat.getTitle()); - updateSubTitle(); if(chat.isGroup()){ @@ -998,7 +998,7 @@ protected void onCreate(Bundle savedInstanceState) { } if(chat.isGroup()){ - log("Incoming group call"); + log("onCreate()-Incoming group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -1017,6 +1017,7 @@ protected void onCreate(Bundle savedInstanceState) { for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("onCreate()- Incoming "+userPeer.getHandle()+" added in peersBeforeCall"); peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; } @@ -1025,7 +1026,7 @@ protected void onCreate(Bundle savedInstanceState) { } } }else{ - log(" onCreate()-Incoming individual call"); + log("onCreate()-Incoming individual call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; @@ -1051,8 +1052,9 @@ protected void onCreate(Bundle savedInstanceState) { thePlayer.setLooping(true); thePlayer.start(); } + if(chat.isGroup()){ - log("Outgoing group call"); + log("onCreate()-Outgoing group call"); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -1066,6 +1068,7 @@ protected void onCreate(Bundle savedInstanceState) { } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("onCreate()- Incoming "+myPeer.getHandle()+" added in peersOnCall"); peersOnCall.add(myPeer); updatePeers(true); @@ -1341,7 +1344,6 @@ protected void hideFABs(){ if(answerCallFAB.getVisibility() == View.VISIBLE){ answerCallFAB.hide(); relativeCall.setVisibility(GONE); - } } @@ -1436,8 +1438,6 @@ public void onDestroy(){ bigCameraGroupCallFragment = null; } - - peerSelected = null; isManualMode = false; recyclerView.setAdapter(null); @@ -1454,12 +1454,6 @@ public void onDestroy(){ @Override public void onBackPressed() { log("onBackPressed"); -// if (overflowMenuLayout != null){ -// if (overflowMenuLayout.getVisibility() == View.VISIBLE){ -// overflowMenuLayout.setVisibility(View.GONE); -// return; -// } -// } super.onBackPressed(); super.onBackPressed(); @@ -1593,7 +1587,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ if(chat.isGroup()){ - log("CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS -Group call"); if((peersOnCall != null)&&(peersOnCall.size() != 0)){ boolean peerContain = false; @@ -1605,16 +1599,19 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } if(!peerContain){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("onChatCallUpdate()- CALL_STATUS_IN_PROGRESS "+myPeer.getHandle()+" added in peersOnCall"); peersOnCall.add(myPeer); updatePeers(true); } }else{ if((peersBeforeCall!=null)&&(peersBeforeCall.size()!=0)){ for(InfoPeerGroupCall peerBefore: peersBeforeCall){ + log("onChatCallUpdate()- CALL_STATUS_IN_PROGRESS "+peerBefore.getHandle()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), peerBefore); - } + } } InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("onChatCallUpdate()- CALL_STATUS_IN_PROGRESS "+myPeer.getHandle()+" added in peersOnCall"); peersOnCall.add(myPeer); updatePeers(true); } @@ -1622,7 +1619,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { updateLocalAudioStatus(); }else{ - log("onChatCallUpdate() - CALL_STATUS_IN_PROGRESS"); + log("CALL_STATUS_IN_PROGRESS - Individual call"); flagMyAvatar = true; setProfileMyAvatar(); @@ -1646,7 +1643,9 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { answerCallFAB.setOnTouchListener(null); videoFAB.setOnTouchListener(null); videoFAB.setOnClickListener(this); + updateSubTitle(); + stopAudioSignals(); rtcAudioManager.start(null); showInitialFABConfiguration(); @@ -1676,29 +1675,22 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { super.finish(); } }else{ - log("onChatCallUpdate() - CALL_STATUS_TERMINATING_USER_PARTICIPATION"); -// if (localCameraFragment != null) { -// log("CALL_STATUS_TERMINATING_USER_PARTICIPATION localCameraFragment != null"); -// -// localCameraFragment.setVideoFrame(false); +// if (localCameraFragment != null) {// // FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // ft.remove(localCameraFragment); // localCameraFragment = null; // } // if (localCameraFragmentFS != null) { -// localCameraFragmentFS.setVideoFrame(false); // FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); // ftFS.remove(localCameraFragmentFS); // localCameraFragmentFS = null; // } // if (remoteCameraFragmentFS != null) { -// remoteCameraFragmentFS.setVideoFrame(false); // FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // ft.remove(remoteCameraFragmentFS); // remoteCameraFragmentFS = null; // } -// // if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // super.finishAndRemoveTask(); // } @@ -1718,7 +1710,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { break; } case MegaChatCall.CALL_STATUS_DESTROYED:{ - log("onChatCallUpdate() - CALL_STATUS_DESTROYED"); + log(" CALL_STATUS_DESTROYED"); log("CALL_STATUS_DESTROYED:TERM code of the call: "+call.getTermCode()); //The group call has finished but I can not join again @@ -1751,6 +1743,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession != null){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("SESSION_STATUS_IN_PROGRESS"); + updateSubTitle(); //contact joined the group call @@ -1805,6 +1798,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ log("SESSION_STATUS_DESTROYED "); + updateSubTitle(); //contact left the group call @@ -1915,6 +1909,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+userPeer.getHandle()+" added"); peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; } @@ -1928,6 +1923,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } if(!peerContained){ + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+peersBeforeCall.get(i).getHandle()+" removed"); peersBeforeCall.remove(i); changes = true; } @@ -1954,39 +1950,64 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if (!peerContain) { if (userHandle == megaChatApi.getMyUserHandle()){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+myPeer.getHandle()+" added"); peersOnCall.add(myPeer); updatePeers(true); } else { InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+userPeer.getHandle()+" added"); peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); if (peersOnCall.size() < 7) { if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> "+peersOnCall.size()+")"); + recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); - }else{ - if(peersOnCall.size() == 4) { + adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); + + }else { + if (peersOnCall.size() == 4) { + log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> " + peersOnCall.size() + ")"); + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); - }else{ + recyclerView.setColumnWidth((int) widthScreenPX / 2); + adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); + } else { recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted POS(" + posInserted + "), range(" + (posInserted - 1) + " -> " + peersOnCall.size() + ") "); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); + updateSubtitleToolbar(); + } - recyclerView.setColumnWidth((int) widthScreenPX/2); } - adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubTitle(); - updateSubtitleToolbar(); + }else{ updatePeers(true); } } else { if (adapterList != null) { - adapterList.notifyItemInserted((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1))); - adapterList.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubTitle(); - updateSubtitleToolbar(); + if(peersOnCall.size() == 7){ + log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); + updatePeers(true); + }else{ + int posInserted=(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + log("(7 +)COMPOSITION IN PROGRESS, notifyItemInserted POS("+(posInserted-1)+"), range("+posInserted+" -> "+peersOnCall.size()+") "); + adapterList.notifyItemInserted(posInserted); + adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); + updateSubtitleToolbar(); + } } else { + log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); updatePeers(true); } } @@ -2004,35 +2025,53 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } if (!peerContained) { + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+peersOnCall.get(i).getHandle()+" removed"); peersOnCall.remove(i); if (peersOnCall.size() < 7) { if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); } else { - if (peersOnCall.size() == 4) { - recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); - } else { + if(peersOnCall.size() == 6){ + log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + updateSubtitleToolbar(); + }else{ + log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); + updateSubtitleToolbar(); } - recyclerView.setColumnWidth((int) widthScreenPX/2); } - adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubTitle(); - updateSubtitleToolbar(); + } else { updatePeers(true); } } else { if (adapterList != null) { - adapterList.notifyItemRemoved(i); - adapterList.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubTitle(); - updateSubtitleToolbar(); + if(peersOnCall.size() >= 7){ + log("(7 +)COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); + adapterList.notifyItemRemoved(i); + adapterList.notifyItemRangeChanged(i, peersOnCall.size()); + updateSubtitleToolbar(); + }else{ + log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); + updatePeers(true); + } } else { + log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); updatePeers(true); } } @@ -2222,7 +2261,7 @@ public void onClick(View v) { } public boolean checkPermissions(){ - log("checkPermissions() "); + log("checkPermissions() Camera && Audio"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -2478,8 +2517,6 @@ public void updateLocalVideoStatus(){ log("activate Local Video for "+peersOnCall.get(position).getName()); item.setVideoOn(true); if(peersOnCall.size()<7){ - log("updateLocalVideo "+peersOnCall.get(position).getName()+" Conencted video"); - adapterGrid.notifyItemChanged(position); }else{ adapterList.notifyItemChanged(position); @@ -2499,8 +2536,6 @@ public void updateLocalVideoStatus(){ log("remove Local Video fot "+peersOnCall.get(position).getName()); item.setVideoOn(false); if(peersOnCall.size()<7){ - log("updateLocalVideo "+peersOnCall.get(position).getName()+" Disconnected video"); - adapterGrid.notifyItemChanged(position); }else{ adapterList.notifyItemChanged(position); @@ -2512,7 +2547,6 @@ public void updateLocalVideoStatus(){ } }else{ log("is individual"); - if (callChat.hasLocalVideo()) { log("Video local connected: chatId: "+chatId); videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor))); @@ -2616,7 +2650,6 @@ public void updateLocalAudioStatus(){ if(peersOnCall.size()<7){ adapterGrid.changesInAudio(position,null); }else{ - adapterList.changesInAudio(position,null); } } @@ -2652,9 +2685,8 @@ public void updateRemoteVideoStatus(long userHandle){ if(!peersOnCall.get(i).isVideoOn()){ peersOnCall.get(i).setVideoOn(true); updateSubtitleToolbar(); + log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Connected video"); if(peersOnCall.size()<7){ - log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Connected video"); - adapterGrid.notifyItemChanged(i); }else{ adapterList.notifyItemChanged(i); @@ -2673,7 +2705,6 @@ public void updateRemoteVideoStatus(long userHandle){ } } } - break; } } @@ -2687,10 +2718,8 @@ public void updateRemoteVideoStatus(long userHandle){ if(peersOnCall.get(i).isVideoOn()){ peersOnCall.get(i).setVideoOn(false); updateSubtitleToolbar(); - + log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Disconnected video"); if(peersOnCall.size()<7){ - log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Disconnected video"); - adapterGrid.notifyItemChanged(i); }else{ adapterList.notifyItemChanged(i); @@ -2741,7 +2770,6 @@ public void updateRemoteVideoStatus(long userHandle){ }else{ log("Video remote NOT connected"); - isRemoteVideo = REMOTE_VIDEO_DISABLED; if (remoteCameraFragmentFS != null) { log("remove remoteCameraFragmentFS"); @@ -2803,7 +2831,6 @@ public void updateRemoteAudioStatus(long userHandle){ if(peersOnCall.get(i).getHandle().equals(userHandle)){ if(!peersOnCall.get(i).isAudioOn()){ peersOnCall.get(i).setAudioOn(true); - if(peersOnCall.size()<7){ adapterGrid.changesInAudio(i,null); }else{ @@ -2845,7 +2872,6 @@ public void updateRemoteAudioStatus(long userHandle){ } } } - break; } } @@ -3039,6 +3065,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { } public void answerAudioCall(){ + log("answerAudioCall"); clearHandlers(); if (megaChatApi.isSignalActivityRequired()) { @@ -3065,6 +3092,7 @@ public void animationAlphaArrows(final ImageView arrow){ } public void updateSubtitleToolbar(){ + log("updateSubtitleToolbar() "); int cont = 0; if(peersOnCall!=null){ for(int i=0;i call incoming: peersBeforeCall("+peersBeforeCall.size()+")"); + log("updatePeers() incoming call: peersBeforeCall("+peersBeforeCall.size()+")"); linearParticipants.setVisibility(View.GONE); @@ -3206,9 +3241,11 @@ public void updatePeers(boolean flag){ recyclerView.setColumnWidth((int) widthScreenPX/2); } if(adapterGrid == null){ - adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag); + log("(1-6) incoming call - create adapter"); + adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, true); recyclerView.setAdapter(adapterGrid); }else{ + log("(1-6) incoming call - notifyDataSetChanged"); adapterGrid.notifyDataSetChanged(); } @@ -3241,12 +3278,13 @@ public void updatePeers(boolean flag){ bigRecyclerView.setVisibility(View.VISIBLE); if(adapterList==null){ + log("(7 +) incoming call - create adapter"); bigRecyclerView.setAdapter(null); - adapterList = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag); + adapterList = new GroupCallAdapter(this, bigRecyclerView, peersBeforeCall, chatId, flag, false); bigRecyclerView.setAdapter(adapterList); }else{ + log("(7 +) incoming call - notifyDataSetChanged"); adapterList.notifyDataSetChanged(); - } updateUserSelected(flag); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java index 6053fc4a85a..a78e8a1c4f7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java @@ -75,7 +75,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); localRenderer = new MegaSurfaceRenderer(localSurfaceView); - log("onCreate() addChatLocalVideoListener chatId: "+chatId); + log("addChatLocalVideoListener chatId: "+chatId); megaChatApi.addChatLocalVideoListener(chatId, this); return v; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index acce72ecd2f..61c5a5dfdf6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -61,7 +61,6 @@ public void onCreate (Bundle savedInstanceState){ log("onCreate() chatId: "+this.chatId); super.onCreate(savedInstanceState); - log("after onCreate called super"); } @@ -81,7 +80,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView); - log("onCreate() addChatRemoteVideoListener chatId: "+this.chatId); + log("addChatRemoteVideoListener chatId: "+this.chatId); megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); return v; @@ -89,7 +88,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer){ - log("onChatVideoData: chatid: "+chatid+" h("+height+"), w("+width+")"); if((width == 0) || (height == 0)){ return; @@ -144,7 +142,6 @@ public void onDestroy(){ ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); } } - log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+this.chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); @@ -166,7 +163,7 @@ public void removeSurfaceView(){ ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); } } - log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+this.chatId); + log("**** removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+this.chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 7b4cf93299a..ca1835637c9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -73,9 +73,10 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress) { +public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress, boolean isGrid) { log("GroupCallAdapter(peers: "+peers.size()+")"); @@ -84,6 +85,7 @@ public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList= 4) && (numPeersOnCall < 7)){ - lp.height = maxScreenWidth/2; - lp.width = maxScreenWidth/2; - if((peers.size()==5)&&(peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ - ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); - layoutParamsPeer.width = maxScreenWidth; - layoutParamsPeer.height = maxScreenWidth/2; - holder.rlGeneral.setLayoutParams(layoutParamsPeer); + log("onBindViewHolderGrid() - peer: "+peer.getHandle()+", numPeersOnCall: "+numPeersOnCall); + + if(isGrid){ + CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); + + if(numPeersOnCall < 4){ + lp.height = maxScreenHeight/numPeersOnCall; + lp.width = maxScreenWidth; + + }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ + lp.height = maxScreenWidth/2; + lp.width = maxScreenWidth/2; + if((peers.size()==5)&&(peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = maxScreenWidth/2; + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + }else{ + lp.height = Util.scaleWidthPx(90, outMetrics); + lp.width = Util.scaleWidthPx(90, outMetrics); } + holder.rlGeneral.setLayoutParams(lp); }else{ - lp.height = Util.scaleWidthPx(90, outMetrics); - lp.width = Util.scaleWidthPx(90, outMetrics); + RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); + + if(numPeersOnCall < 4){ + lp.height = maxScreenHeight/numPeersOnCall; + lp.width = maxScreenWidth; + + }else if((numPeersOnCall >= 4) && (numPeersOnCall < 7)){ + lp.height = maxScreenWidth/2; + lp.width = maxScreenWidth/2; + if((peers.size()==5)&&(peer.getHandle().equals(megaChatApi.getMyUserHandle()))){ + ViewGroup.LayoutParams layoutParamsPeer = (ViewGroup.LayoutParams) holder.rlGeneral.getLayoutParams(); + layoutParamsPeer.width = maxScreenWidth; + layoutParamsPeer.height = maxScreenWidth/2; + holder.rlGeneral.setLayoutParams(layoutParamsPeer); + } + }else{ + lp.height = Util.scaleWidthPx(90, outMetrics); + lp.width = Util.scaleWidthPx(90, outMetrics); + } + holder.rlGeneral.setLayoutParams(lp); } - holder.rlGeneral.setLayoutParams(lp); if(isCallInProgress){ holder.rlGeneral.setOnClickListener(new View.OnClickListener() { @@ -223,6 +252,8 @@ public void onClick(View v) { } if(peer.isVideoOn()) { + log("peer: "+peer.getHandle()+", VIDEO ON"); + holder.avatarMicroLayout.setVisibility(GONE); holder.microAvatar.setVisibility(View.GONE); @@ -303,6 +334,8 @@ public void onClick(View v) { //Listener && SurfaceView if(peer.getListener() == null){ + log("peer: "+peer.getHandle()+", VIDEO ON- listener == null"); + SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); surfaceView.setZOrderMediaOverlay(true); @@ -323,8 +356,11 @@ public void onClick(View v) { holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); }else{ + log("peer: "+peer.getHandle()+", VIDEO ON- listener != null"); if(holder.parentSurfaceView.getChildCount() == 0){ + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() == 0"); + if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); @@ -341,8 +377,11 @@ public void onClick(View v) { } } }else{ + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0"); if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it's the same"); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); @@ -351,6 +390,8 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same"); + //Remove items of parent holder.parentSurfaceView.removeAllViews(); //Remove parent of Surface @@ -415,10 +456,13 @@ public void onClick(View v) { } }else{ + log("peer: "+peer.getHandle()+", VIDEO OFF"); //Remove SurfaceView && Listener: holder.surfaceMicroLayout.setVisibility(GONE); if(peer.getListener() != null){ + log("peer: "+peer.getHandle()+", VIDEO OFF - listener != null"); + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); }else{ @@ -426,12 +470,16 @@ public void onClick(View v) { } if(holder.parentSurfaceView.getChildCount() == 0){ + log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() == 0"); + if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); } } }else{ + log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() != 0"); + holder.parentSurfaceView.removeAllViews(); holder.parentSurfaceView.removeAllViewsInLayout(); @@ -535,6 +583,7 @@ public InfoPeerGroupCall getNodeAt(int position) { //My AVATAR public void setProfileMyAvatar(ViewHolderGroupCall holder) { + log("setProfileMyAvatar"); Bitmap myBitmap = null; File avatar = null; if (context != null) { @@ -568,6 +617,8 @@ public void setProfileMyAvatar(ViewHolderGroupCall holder) { } //My Default AVATAR public void createMyDefaultAvatar(ViewHolderGroupCall holder) { + log("createMyDefaultAvatar"); + String myFullName = megaChatApi.getMyFullname(); String myFirstLetter=myFullName.charAt(0) + ""; myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); @@ -601,6 +652,8 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { //CONTACT AVATAR public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ + log("setProfileContactAvatar"); + Bitmap bitmap = null; File avatar = null; String contactMail = megaChatApi.getContactEmail(userHandle); @@ -667,6 +720,8 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde } //CONTACT Default AVATAR public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGroupCall holder) { + log("createDefaultAvatar"); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); @@ -695,10 +750,6 @@ public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGro holder.avatarInitialLetter.setVisibility(View.VISIBLE); } -// public void setAdapterType(int adapterType){ -// this.adapterType = adapterType; -// } - public RecyclerView getListFragment() { return recyclerViewFragment; } @@ -707,95 +758,6 @@ public void setListFragment(RecyclerView recyclerViewFragment) { this.recyclerViewFragment = recyclerViewFragment; } - public void removeSurfacesView(){ - if((peers!=null)&&(peers.size())>0){ - for(int i=0;i addChatLocalVideoListener() "); -// megaChatApi.addChatLocalVideoListener(chatId, peer.getListener()); -// } else { -// log("Video ON-> addChatRemoteVideoListener()"); -// megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener()); -// } -// }else{ -// log("++++ Listener-> height y widht 0"); -// -// peer.getListener().setHeight(0); -// peer.getListener().setWidth(0); -// } -// -// holder.surfaceViewLayout.setVisibility(View.VISIBLE); -// holder.avatarMicroLayout.setVisibility(View.GONE); -// -// }else{ -// log("++++++ changesInVideo() isVideoOff"); -// -// //Remove surface view -// holder.surfaceView.setVisibility(GONE); -// holder.surfaceViewLayout.removeAllViewsInLayout(); -// if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { -// log("Video OFF-> removeChatMyVideoListener()"); -// megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); -// }else{ -// log("Video OFF-> removeChatVideoListener()"); -// megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); -// } -// peer.setListener(null); -// holder.surfaceViewLayout.setVisibility(View.GONE); -// holder.avatarMicroLayout.setVisibility(View.VISIBLE); -// -// } -// }else{ -// log("++++++ changesInVideo() holder == NULL -> notifyItemChanged"); -// -// notifyItemChanged(position); -// } -// } - public void changesInAudio(int position, ViewHolderGroupCall holder){ log("changesInAudio"); @@ -880,7 +842,6 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ log("changesInGreenLayer()"); -// notifyItemChanged(position); if(holder == null){ holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position); } diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index 9eb46a96e93..2096e1373bf 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -15,11 +15,6 @@ android:background="@android:color/transparent" android:id="@+id/activity_chat_content_layout"> - - - - - Date: Wed, 21 Nov 2018 13:57:34 +0100 Subject: [PATCH 114/247] Group calls UI --- .../lollipop/megachat/ChatActivityLollipop.java | 11 +++++++---- .../calls/BigCameraGroupCallFragment.java | 9 +++++++++ .../megachat/calls/ChatCallActivity.java | 15 ++++++++------- .../megachat/calls/LocalCameraCallFragment.java | 17 +++++------------ .../LocalCameraCallFullScreenFragment.java | 10 ++++++---- .../RemoteCameraCallFullScreenFragment.java | 12 ++++++------ 6 files changed, 41 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 3c841e4313b..41f4e80806e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2431,6 +2431,7 @@ public void onClick(View v) { } case R.id.call_in_progress_layout:{ if(checkPermissionsCall()){ + log("call_in_progress_layout clicked"); MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ megaChatApi.startChatCall(idChat, false, null); @@ -7038,19 +7039,20 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("onChatCallUpdate() status: "+call.getStatus()); if(call.getChatid()==idChat){ if(call.getStatus()==MegaChatCall.CALL_STATUS_DESTROYED){ - log("callInProgressLayout - CALL_STATUS_DESTROYED"); + log("onChatCallUpdate - CALL_STATUS_DESTROYED"); callInProgressLayout.setVisibility(View.GONE); callInProgressLayout.setOnClickListener(null); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("callInProgressLayout - CALL_STATUS_IN_PROGRESS"); + log("onChatCallUpdate - CALL_STATUS_IN_PROGRESS"); callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); callInProgressLayout.setOnClickListener(this); invalidateOptionsMenu(); }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ - log("callInProgressLayout - CALL_STATUS_RING_IN "); + log("onChatCallUpdate - CALL_STATUS_RING_IN "); long openCallChatId = MegaApplication.getOpenCallChatId(); log("openCallId: "+openCallChatId); if(openCallChatId!=-1){ @@ -7061,8 +7063,9 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { startActivity(intent); } }else if(call.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ - log("callInProgressLayout - CALL_STATUS_USER_NO_PRESENT"); + log("onChatCallUpdate - CALL_STATUS_USER_NO_PRESENT"); callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); callInProgressLayout.setOnClickListener(this); invalidateOptionsMenu(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index e0f0f27375f..20ab5ce2fa0 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -78,8 +78,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa renderer = new MegaSurfaceRendererGroup(fullScreenSurfaceView, userHandle); if(userHandle.equals(megaChatApi.getMyUserHandle())){ + log("onCreateView() addChatLocalVideoListener chatId: "+chatId); megaChatApi.addChatLocalVideoListener(chatId, this); }else{ + log("onCreateView() addChatRemoteVideoListener chatId: "+chatId); megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); } @@ -135,14 +137,18 @@ public void onAttach(Context context) { @Override public void onDestroy(){ + log("onDestroy"); if(fullScreenSurfaceView.getParent()!=null){ if(fullScreenSurfaceView.getParent().getParent()!=null){ + log("onDestroy() removeView chatId: "+chatId); ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); } } if(userHandle.equals(megaChatApi.getMyUserHandle())){ + log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); }else{ + log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); } super.onDestroy(); @@ -159,12 +165,15 @@ public void removeSurfaceView(){ log("removeSurfaceView()"); if(fullScreenSurfaceView.getParent()!=null){ if(fullScreenSurfaceView.getParent().getParent()!=null){ + log("removeSurfaceView() removeView chatId: "+chatId); ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); } } if(userHandle.equals(megaChatApi.getMyUserHandle())){ + log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); }else{ + log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f6858d09709..31c2103f252 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -644,7 +644,7 @@ protected void onNewIntent(Intent intent) { } }else{ - log(" It is not the same: "+newChatId); + log("It is not the same: "+newChatId); //Check the new call if in progress chatId = newChatId; chat = megaChatApi.getChatRoom(chatId); @@ -964,8 +964,6 @@ protected void onCreate(Bundle savedInstanceState) { int callStatus = callChat.getStatus(); log("The status of the callChat is: " + callStatus); - -// aB.setTitle(chat.getTitle()); titleToolbar.setText(chat.getTitle()); updateSubTitle(); @@ -1963,7 +1961,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if (peersOnCall.size() < 4) { log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> "+peersOnCall.size()+")"); - recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); @@ -1973,7 +1970,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ }else { if (peersOnCall.size() == 4) { log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> " + peersOnCall.size() + ")"); - recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); recyclerView.setColumnWidth((int) widthScreenPX / 2); adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); @@ -2047,9 +2043,14 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); updateSubtitleToolbar(); }else{ + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + }else{ + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX/2); + } log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); - recyclerViewLayout.setPadding(0, 0, 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX/2); adapterGrid.notifyItemRemoved(i); adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); updateSubtitleToolbar(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java index a78e8a1c4f7..3c7aae8e426 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java @@ -37,7 +37,6 @@ public class LocalCameraCallFragment extends Fragment implements MegaChatVideoLi public static LocalCameraCallFragment newInstance(long chatId) { log("newInstance() chatId: "+chatId); LocalCameraCallFragment f = new LocalCameraCallFragment(); - Bundle args = new Bundle(); args.putLong("chatId", chatId); f.setArguments(args); @@ -46,16 +45,12 @@ public static LocalCameraCallFragment newInstance(long chatId) { @Override public void onCreate (Bundle savedInstanceState){ - if (megaChatApi == null){ megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); } -// this.width = 0; -// this.height = 0; Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); - log("onCreate() chatId: "+this.chatId); - + log("onCreate() chatId: "+chatId); super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -75,7 +70,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); localRenderer = new MegaSurfaceRenderer(localSurfaceView); - log("addChatLocalVideoListener chatId: "+chatId); + log("onCreateView() addChatLocalVideoListener chatId: "+chatId); megaChatApi.addChatLocalVideoListener(chatId, this); return v; @@ -128,7 +123,6 @@ public void onAttach(Context context) { @Override public void onDestroy(){ log("onDestroy"); - if(localSurfaceView.getParent()!=null){ if(localSurfaceView.getParent().getParent()!=null){ log("onDestroy() removeView chatId: "+chatId); @@ -136,7 +130,7 @@ public void onDestroy(){ } } - log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+this.chatId); + log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); super.onDestroy(); } @@ -151,12 +145,11 @@ public void removeSurfaceView(){ log("removeSurfaceView()"); if(localSurfaceView.getParent()!=null){ if(localSurfaceView.getParent().getParent()!=null){ - log("removeSurfaceView() removeView chatId: "+this.chatId); + log("removeSurfaceView() removeView chatId: "+chatId); ((ViewGroup)localSurfaceView.getParent()).removeView(localSurfaceView); } } - - log("emoveSurfaceView() removeChatVideoListener (LOCAL)chatId: "+this.chatId); + log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(this.chatId, -1, this); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java index 6e340f72b2d..7b07d95dcf3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFullScreenFragment.java @@ -37,7 +37,6 @@ public class LocalCameraCallFullScreenFragment extends Fragment implements MegaC public static LocalCameraCallFullScreenFragment newInstance(long chatId) { log("newInstance"); LocalCameraCallFullScreenFragment f = new LocalCameraCallFullScreenFragment(); - Bundle args = new Bundle(); args.putLong("chatId", chatId); f.setArguments(args); @@ -53,14 +52,12 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); - super.onCreate(savedInstanceState); log("after onCreate called super"); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - log("onCreateView"); if (!isAdded()) { return null; @@ -74,7 +71,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); localRenderer = new MegaSurfaceRenderer(localFullScreenSurfaceView); - log("onCreate() addChatLocalVideoListener chatId: "+this.chatId); + log("onCreateView() addChatLocalVideoListener chatId: "+chatId); megaChatApi.addChatLocalVideoListener(chatId, this); return v; @@ -129,11 +126,14 @@ public void onAttach(Context context) { @Override public void onDestroy(){ + log("onDestroy()"); if(localFullScreenSurfaceView.getParent()!=null){ if(localFullScreenSurfaceView.getParent().getParent()!=null){ + log("onDestroy() removeView chatId: "+chatId); ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView); } } + log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); super.onDestroy(); } @@ -148,9 +148,11 @@ public void removeSurfaceView(){ log("removeSurfaceView()"); if(localFullScreenSurfaceView.getParent()!=null){ if(localFullScreenSurfaceView.getParent().getParent()!=null){ + log("removeSurfaceView() removeView chatId: "+chatId); ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView); } } + log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index 61c5a5dfdf6..44dfa124b70 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -58,7 +58,7 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); - log("onCreate() chatId: "+this.chatId); + log("onCreate() chatId: "+chatId); super.onCreate(savedInstanceState); log("after onCreate called super"); @@ -80,7 +80,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView); - log("addChatRemoteVideoListener chatId: "+this.chatId); + log("onCreateView() addChatRemoteVideoListener chatId: "+chatId); megaChatApi.addChatRemoteVideoListener(chatId, userHandle, this); return v; @@ -138,11 +138,11 @@ public void onDestroy(){ log("onDestroy"); if(remoteFullScreenSurfaceView.getParent()!=null){ if(remoteFullScreenSurfaceView.getParent().getParent()!=null){ - log("onDestroy() removeView chatId: "+this.chatId); + log("onDestroy() removeView chatId: "+chatId); ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); } } - log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+this.chatId); + log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); } @@ -159,11 +159,11 @@ public void removeSurfaceView(){ log("removeSurfaceView()"); if(remoteFullScreenSurfaceView.getParent()!=null){ if(remoteFullScreenSurfaceView.getParent().getParent()!=null){ - log("removeSurfaceView() removeView chatId: "+this.chatId); + log("removeSurfaceView() removeView chatId: "+chatId); ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); } } - log("**** removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+this.chatId); + log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); } From 80d684706904631e708c558aec490d8b3896f696 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 21 Nov 2018 16:40:23 +0100 Subject: [PATCH 115/247] Group Calls UI --- .../megachat/calls/ChatCallActivity.java | 366 +++++++++++------- 1 file changed, 227 insertions(+), 139 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 31c2103f252..f48e58a812f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -314,6 +314,7 @@ public void updateScreenStatusInProgress(){ // setProfileContactAvatar(); if(chat.isGroup()){ + log("updateScreenStatusInProgress() - group chat - chatId: "+chatId); relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; @@ -343,12 +344,14 @@ public void updateScreenStatusInProgress(){ if(userSession!=null){ if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandler, chat.getPeerFullnameByHandle(userHandler), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); changes = true; } } } else { InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); peersOnCall.add(myPeer); changes = true; } @@ -364,6 +367,7 @@ public void updateScreenStatusInProgress(){ } } if (!peerContained) { + log("updateScreenStatusInProgress() "+peersOnCall.get(i).getName()+" removed of peersOnCall"); peersOnCall.remove(i); changes = true; } @@ -375,18 +379,20 @@ public void updateScreenStatusInProgress(){ }else{ boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ - long userHandle = callChat.getParticipants().get(i); - if(userHandle != megaChatApi.getMyUserHandle()){ - MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + long userHandler = callChat.getParticipants().get(i); + if(userHandler != megaChatApi.getMyUserHandle()){ + MegaChatSession userSession = callChat.getMegaChatSession(userHandler); if(userSession!=null){ if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandler, chat.getPeerFullnameByHandle(userHandler), userSession.hasVideo(), userSession.hasAudio(), false,null); + log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); changes = true; } } }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); peersOnCall.add(myPeer); changes = true; } @@ -398,8 +404,7 @@ public void updateScreenStatusInProgress(){ } }else{ - log("updateScreenStatusInProgress() chatId: "+chatId); - + log("updateScreenStatusInProgress() - individual chat - chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); if (callChat == null){ @@ -511,136 +516,155 @@ protected void onNewIntent(Intent intent) { long newChatId = extras.getLong("chatHandle", -1); log("New chat id: "+newChatId); if(chatId == newChatId){ - log("Its the same call"); - callChat = megaChatApi.getChatCall(chatId); - if(callChat.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ - - boolean isMe = false; - for(int i = 0; i < callChat.getParticipants().size(); i++){ - Long userHandle = callChat.getParticipants().get(i); - if (userHandle.equals(megaChatApi.getMyUserHandle())) { - isMe = true; - break; + if(chat.isGroup()){ + callChat = megaChatApi.getChatCall(chatId); + log("onNewIntent() - group chat - Its the same call -> STATUS: "+callChat.getStatus()); + if(callChat.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ + log("onNewIntent() - group chat - CALL_STATUS_RING_IN"); + + boolean isMe = false; + for(int i = 0; i < callChat.getParticipants().size(); i++){ + Long userHandle = callChat.getParticipants().get(i); + if (userHandle.equals(megaChatApi.getMyUserHandle())) { + isMe = true; + break; + } } - } - if(!isMe){ - if(peersBeforeCall!=null){ - if(peersBeforeCall.size()!=0){ + if(!isMe){ + if(peersBeforeCall!=null){ + if(peersBeforeCall.size()!=0){ + boolean changes = false; + for(int i = 0; i < callChat.getParticipants().size(); i++){ + boolean peerContain = false; + long userHandle = callChat.getParticipants().get(i); + for(InfoPeerGroupCall peerBeforeCall: peersBeforeCall){ + if(peerBeforeCall.getHandle() == userHandle){ + peerContain = true; + break; + } + } + if(!peerContain){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("onNewIntent() "+userPeer.getName()+" added in peersBeforeCall"); + + peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); + changes = true; + } + } + for(int i=0;i participants: "+callChat.getParticipants().size()); + updateSubTitle(); + if(peersOnCall != null){ + if(peersOnCall.size() != 0){ boolean changes = false; - for(int i = 0; i < callChat.getParticipants().size(); i++){ + //Get all participant and check it + for (int i = 0; i < callChat.getParticipants().size(); i++) { boolean peerContain = false; long userHandle = callChat.getParticipants().get(i); - for(InfoPeerGroupCall peerBeforeCall: peersBeforeCall){ - if(peerBeforeCall.getHandle() == userHandle){ + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle() == userHandle) { peerContain = true; break; } } - if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); - peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); - changes = true; + if (!peerContain) { + if (userHandle == megaChatApi.getMyUserHandle()) { + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, null); + log("onNewIntent() "+myPeer.getName()+" added in peersOnCall"); + peersOnCall.add(myPeer); + changes = true; + } else { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); + log("onNewIntent() "+userPeer.getName()+" added in peersOnCall"); + + peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + changes = true; + } } } - for(int i=0;i participants: "+callChat.getParticipants().size()); - if(peersOnCall != null){ - if(peersOnCall.size() != 0){ - boolean changes = false; - //Get all participant and check it - for (int i = 0; i < callChat.getParticipants().size(); i++) { - boolean peerContain = false; - Long userHandle = callChat.getParticipants().get(i); - for (InfoPeerGroupCall peerOnCall : peersOnCall) { - if (peerOnCall.getHandle().equals(userHandle)) { - peerContain = true; - break; - } - } - if (!peerContain) { - if (userHandle.equals(megaChatApi.getMyUserHandle())) { + if (userHandle.equals(megaChatApi.getMyUserHandle())){ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, null); + log("onNewIntent() "+myPeer.getName()+" added in peersOnCall"); peersOnCall.add(myPeer); changes = true; - } else { + }else{ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); + log("onNewIntent() "+userPeer.getName()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); changes = true; } } - } - for (int i = 0; i < peersOnCall.size(); i++) { - boolean peerContained = false; - for (int j = 0; j < callChat.getParticipants().size(); j++) { - long userHandle = callChat.getParticipants().get(j); - if (peersOnCall.get(i).getHandle() == userHandle){ - peerContained = true; - break; - } - } - if (!peerContained) { - peersOnCall.remove(i); - changes = true; - } - } - if(changes){ - updatePeers(true); - } - - }else{ - boolean changes = false; - for(int i=0; i "+peersOnCall.size()+") "); adapterList.notifyItemInserted(posInserted); adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); + updateUserSelected(true); updateSubtitleToolbar(); } } else { @@ -2026,7 +2049,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if (peersOnCall.size() < 7) { if (adapterGrid != null) { - if (peersOnCall.size() < 4) { log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); recyclerViewLayout.setPadding(0, 0, 0, 0); @@ -2066,6 +2088,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("(7 +)COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); adapterList.notifyItemRemoved(i); adapterList.notifyItemRangeChanged(i, peersOnCall.size()); + updateUserSelected(true); updateSubtitleToolbar(); }else{ log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); @@ -3295,16 +3318,19 @@ public void updatePeers(boolean flag){ public void updateUserSelected(boolean flag){ log("updateUserSelected()"); if(flag){ - //Call IN PROGRESS if(peerSelected == null){ //First case: if(!isManualMode){ + log(" is not ManualMode"); + if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ int position = peersOnCall.size()-2; peerSelected = peersOnCall.get(position); + log("updateUserSelected() InProgress - new peerSelected "+peerSelected.getHandle()); + for(int i=0;i Date: Wed, 21 Nov 2018 18:10:32 +0100 Subject: [PATCH 116/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 46 ++++++------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b7b9716777a..0c303b126ec 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -331,25 +331,19 @@ public void updateScreenStatusInProgress(){ //Get all participant and check it for (int i = 0; i < callChat.getParticipants().size(); i++) { boolean peerContain = false; - Long userHandler = callChat.getParticipants().get(i); + Long userHandle = callChat.getParticipants().get(i); for (InfoPeerGroupCall peerOnCall : peersOnCall) { - if (peerOnCall.getHandle() == userHandler) { + if (peerOnCall.getHandle() == userHandle) { peerContain = true; break; } } if (!peerContain) { - if (userHandler != megaChatApi.getMyUserHandle()) { - - MegaChatSession userSession = callChat.getMegaChatSession(userHandler); - if(userSession!=null){ - if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandler, chat.getPeerFullnameByHandle(userHandler), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); - peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); - changes = true; - } - } + if (userHandle != megaChatApi.getMyUserHandle()) { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); + peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); + changes = true; } else { InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); @@ -380,17 +374,13 @@ public void updateScreenStatusInProgress(){ }else{ boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ - long userHandler = callChat.getParticipants().get(i); - if(userHandler != megaChatApi.getMyUserHandle()){ - MegaChatSession userSession = callChat.getMegaChatSession(userHandler); - if(userSession!=null){ - if(userSession.getStatus() == MegaChatSession.SESSION_STATUS_IN_PROGRESS){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandler, chat.getPeerFullnameByHandle(userHandler), userSession.hasVideo(), userSession.hasAudio(), false,null); - log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); - peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); - changes = true; - } - } + long userHandle = callChat.getParticipants().get(i); + if(userHandle != megaChatApi.getMyUserHandle()){ + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); + peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); + changes = true; + }else{ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); @@ -451,15 +441,11 @@ public void updateScreenStatusInProgress(){ myAvatarLayout.setVisibility(View.VISIBLE); } } -// // flagMyAvatar = false; // setProfileMyAvatar(); // flagContactAvatar = true; // setProfileContactAvatar(); - - - } updateLocalVideoStatus(); @@ -549,7 +535,6 @@ protected void onNewIntent(Intent intent) { if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); log("onNewIntent() "+userPeer.getName()+" added in peersBeforeCall"); - peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; } @@ -564,7 +549,6 @@ protected void onNewIntent(Intent intent) { } if(!peerContained){ log("onNewIntent() "+peersBeforeCall.get(i).getName()+" removed of peersBeforeCall"); - peersBeforeCall.remove(i); changes = true; } @@ -1002,7 +986,6 @@ protected void onCreate(Bundle savedInstanceState) { } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ - ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI); ringerTimer = new Timer(); MyRingerTask myRingerTask = new MyRingerTask(); @@ -1017,7 +1000,6 @@ protected void onCreate(Bundle savedInstanceState) { vibrator.vibrate(pattern, 0); } } - if(chat.isGroup()){ log("onCreate()-Incoming group call"); From 717c06e71ac7fd47f0b98695c477103813ca44b4 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 22 Nov 2018 11:00:57 +0100 Subject: [PATCH 117/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 42 ++++++++++++++----- .../chatAdapters/GroupCallAdapter.java | 30 +++++++++++-- .../main/res/drawable/border_green_layer.xml | 10 +++++ .../drawable/border_green_layer_selected.xml | 12 ++++++ .../res/layout/item_camera_group_call.xml | 2 +- 5 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/border_green_layer.xml create mode 100644 app/src/main/res/drawable/border_green_layer_selected.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 0c303b126ec..acd1f94b9b6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -798,6 +798,8 @@ protected void onCreate(Bundle savedInstanceState) { linearFAB.setLayoutParams(layoutCompress); linearFAB.setOrientation(LinearLayout.HORIZONTAL); + isManualMode = false; + relativeCall = (RelativeLayout) findViewById(R.id.relative_answer_call_fab); relativeCall.setVisibility(GONE); @@ -1443,6 +1445,9 @@ public void onDestroy(){ } peerSelected = null; + if(adapterList!=null){ + adapterList.updateMode(false); + } isManualMode = false; recyclerView.setAdapter(null); bigRecyclerView.setAdapter(null); @@ -1459,7 +1464,6 @@ public void onDestroy(){ public void onBackPressed() { log("onBackPressed"); super.onBackPressed(); - super.onBackPressed(); if (megaChatApi != null) { megaChatApi.removeChatCallListener(this); @@ -2987,22 +2991,31 @@ public void remoteCameraClick(){ public void itemClicked(InfoPeerGroupCall peer){ log("itemClicked-> "+peer.getName()+", userSelected: "+peerSelected.getName()); - if(peerSelected.getHandle().equals(peer.getHandle())){ + if(peerSelected.getHandle() == peer.getHandle()){ //I touched the same user that is now in big fragment: if(isManualMode){ isManualMode = false; + if(adapterList!=null){ + adapterList.updateMode(false); + } log("manual mode - False"); }else{ isManualMode = true; + if(adapterList!=null){ + adapterList.updateMode(true); + } log("manual mode - True"); } peerSelected = peer; updateUserSelected(true); }else{ - if(!peer.getHandle().equals(megaChatApi.getMyUserHandle())){ + if(peer.getHandle() != megaChatApi.getMyUserHandle()){ if(!isManualMode) { isManualMode = true; + if(adapterList!=null){ + adapterList.updateMode(true); + } log("manual mode - True"); } peerSelected = peer; @@ -3236,6 +3249,7 @@ public void updatePeers(boolean flag){ adapterList.notifyDataSetChanged(); } } + updateUserSelected(flag); } @@ -3320,6 +3334,7 @@ public void updatePeers(boolean flag){ log("(7 +) incoming call - notifyDataSetChanged"); adapterList.notifyDataSetChanged(); } + updateUserSelected(flag); } } @@ -3330,12 +3345,14 @@ public void updateUserSelected(boolean flag){ if(flag){ //Call IN PROGRESS if(peerSelected == null){ + log("updateUserSelected() peerSelected == null"); + //First case: if(!isManualMode){ - log(" is not ManualMode"); if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - int position = peersOnCall.size()-2; + int position = 0; + peerSelected = peersOnCall.get(position); log("updateUserSelected() InProgress - new peerSelected "+peerSelected.getHandle()); @@ -3384,6 +3401,8 @@ public void updateUserSelected(boolean flag){ } } }else{ + log("updateUserSelected() peerSelected != null"); + //find if peerSelected is removed: if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ boolean peerContained = false; @@ -3396,12 +3415,16 @@ public void updateUserSelected(boolean flag){ if(!peerContained){ //it was removed if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - int position = peersOnCall.size()-2; + int position = 0; peerSelected = peersOnCall.get(position); log("updateUserSelected() InProgress - new peerSelected: "+peerSelected.getHandle()); for(int i=0;i peers, long chatId, boolean isCallInProgress, boolean isGrid) { @@ -447,8 +448,14 @@ public void onClick(View v) { //Green Layer: if(numPeersOnCall < 7){ holder.greenLayer.setVisibility(View.GONE); + peer.setGreenLayer(false); }else{ if(peer.hasGreenLayer()){ + if(isManualMode){ + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer_selected)); + }else { + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer)); + } holder.greenLayer.setVisibility(View.VISIBLE); }else{ holder.greenLayer.setVisibility(View.GONE); @@ -544,15 +551,22 @@ public void onClick(View v) { } //Green Layer: - if(numPeersOnCall >= 7){ + if(numPeersOnCall < 7){ + holder.greenLayer.setVisibility(View.GONE); + peer.setGreenLayer(false); + }else{ if(peer.hasGreenLayer()){ + if(isManualMode){ + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer_selected)); + }else { + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer)); + } holder.greenLayer.setVisibility(View.VISIBLE); }else{ holder.greenLayer.setVisibility(View.GONE); } - }else{ - holder.greenLayer.setVisibility(View.GONE); } + } } @@ -840,6 +854,10 @@ public void changesInAudio(int position, ViewHolderGroupCall holder){ } } + public void updateMode(boolean flag){ + isManualMode = flag; + } + public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ log("changesInGreenLayer()"); if(holder == null){ @@ -851,10 +869,16 @@ public void changesInGreenLayer(int position, ViewHolderGroupCall holder){ return; } if(peer.hasGreenLayer()){ + if(isManualMode){ + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer_selected)); + }else { + holder.greenLayer.setBackground(ContextCompat.getDrawable(context, R.drawable.border_green_layer)); + } holder.greenLayer.setVisibility(View.VISIBLE); }else{ holder.greenLayer.setVisibility(View.GONE); } + }else{ notifyItemChanged(position); } diff --git a/app/src/main/res/drawable/border_green_layer.xml b/app/src/main/res/drawable/border_green_layer.xml new file mode 100644 index 00000000000..ef5b8c20107 --- /dev/null +++ b/app/src/main/res/drawable/border_green_layer.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/border_green_layer_selected.xml b/app/src/main/res/drawable/border_green_layer_selected.xml new file mode 100644 index 00000000000..e9bbae27127 --- /dev/null +++ b/app/src/main/res/drawable/border_green_layer_selected.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index f3c71d4f55d..36957243450 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -98,7 +98,7 @@ android:id="@+id/green_layer" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/user_layer_group_call" + android:background="@drawable/border_green_layer" android:visibility="gone"/> From 0ad3372cf2dc308ab0948a06f946acf088c99380 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 22 Nov 2018 12:19:56 +0100 Subject: [PATCH 118/247] Group Calls UI --- .../megachat/calls/ChatCallActivity.java | 48 ++++++++++--- .../chatAdapters/GroupCallAdapter.java | 70 ++++++++++++++++--- .../main/res/layout/activity_calls_chat.xml | 4 -- 3 files changed, 99 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index acd1f94b9b6..da4d5f11960 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -7,6 +7,7 @@ import android.content.pm.PackageManager; import android.content.res.ColorStateList; +import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -39,6 +40,7 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.Display; import android.view.KeyEvent; import android.view.Menu; @@ -110,6 +112,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque ChatItemPreferences chatPrefs = null; MegaUser myUser; Chronometer myChrono; + int actionBarHeight = 0; public static int REMOTE_VIDEO_NOT_INIT = -1; public static int REMOTE_VIDEO_ENABLED = 1; @@ -253,6 +256,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque InfoPeerGroupCall peerSelected = null; boolean isManualMode = false; + int statusBarHeight = 0; @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -691,14 +695,21 @@ protected void onCreate(Bundle savedInstanceState) { display = getWindowManager().getDefaultDisplay(); outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); - widthScreenPX = outMetrics.widthPixels; - heightScreenPX = outMetrics.heightPixels; density = getResources().getDisplayMetrics().density; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); scaleW = Util.getScaleW(outMetrics, density); scaleH = Util.getScaleH(outMetrics, density); + int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + statusBarHeight = getResources().getDimensionPixelSize(resourceId); + } + + widthScreenPX = outMetrics.widthPixels; + heightScreenPX = outMetrics.heightPixels - statusBarHeight; + + MegaApplication app = (MegaApplication) getApplication(); if (megaApi == null) { megaApi = app.getMegaApi(); @@ -783,6 +794,7 @@ protected void onCreate(Bundle savedInstanceState) { participantText = (TextView) tB.findViewById(R.id.participants_text); linearParticipants.setVisibility(View.GONE); + myChrono = new Chronometer(context); smallElementsIndividualCallLayout = (RelativeLayout) findViewById(R.id.small_elements_individual_call); @@ -920,6 +932,7 @@ protected void onCreate(Bundle savedInstanceState) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(this, R.color.black)); + } if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){ requestWindowFeature(Window.FEATURE_NO_TITLE); @@ -1449,10 +1462,20 @@ public void onDestroy(){ adapterList.updateMode(false); } isManualMode = false; - recyclerView.setAdapter(null); - bigRecyclerView.setAdapter(null); + + if(adapterGrid!=null){ + adapterGrid.onDestroy(); + } + if(adapterList!=null){ + adapterList.onDestroy(); + } + peersOnCall.clear(); peersBeforeCall.clear(); + + recyclerView.setAdapter(null); + bigRecyclerView.setAdapter(null); + stopAudioSignals(); mSensorManager.unregisterListener(this); MegaApplication.activityPaused(); @@ -3169,8 +3192,10 @@ public void updatePeers(boolean flag){ //1-6 if(peersOnCall.size()!=0){ if(adapterList!=null){ - adapterList =null; + adapterList.onDestroy(); + adapterList = null; } + bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); parentBigCameraGroupCall.setOnClickListener(null); @@ -3196,6 +3221,7 @@ public void updatePeers(boolean flag){ }else{ if(isNecessaryCreateAdapter){ log("(1-6) in progress call - create adapter"); + adapterGrid.onDestroy(); recyclerView.setAdapter(null); adapterGrid = new GroupCallAdapter(this, recyclerView, peersOnCall, chatId, flag, true); recyclerView.setAdapter(adapterGrid); @@ -3207,9 +3233,11 @@ public void updatePeers(boolean flag){ }else{ if(adapterGrid != null){ + adapterGrid.onDestroy(); adapterGrid = null; } if(adapterList!=null){ + adapterList.onDestroy(); adapterList =null; } recyclerView.setAdapter(null); @@ -3224,6 +3252,7 @@ public void updatePeers(boolean flag){ //7 + if(adapterGrid != null){ + adapterGrid.onDestroy(); adapterGrid = null; } recyclerView.setAdapter(null); @@ -3241,6 +3270,7 @@ public void updatePeers(boolean flag){ }else{ if(isNecessaryCreateAdapter){ log("(7 +) in progress call - create adapter"); + adapterList.onDestroy(); bigRecyclerView.setAdapter(null); adapterList = new GroupCallAdapter(this, bigRecyclerView, peersOnCall, chatId, flag, false); bigRecyclerView.setAdapter(adapterList); @@ -3249,10 +3279,8 @@ public void updatePeers(boolean flag){ adapterList.notifyDataSetChanged(); } } - updateUserSelected(flag); } - isNecessaryCreateAdapter = false; }else{ @@ -3267,8 +3295,8 @@ public void updatePeers(boolean flag){ if(peersBeforeCall.size() != 0){ //1-6 - if(adapterList != null){ + adapterList.onDestroy(); adapterList = null; } bigRecyclerView.setAdapter(null); @@ -3290,6 +3318,7 @@ public void updatePeers(boolean flag){ } if(adapterGrid == null){ log("(1-6) incoming call - create adapter"); + recyclerView.setAdapter(null); adapterGrid = new GroupCallAdapter(this, recyclerView, peersBeforeCall, chatId, flag, true); recyclerView.setAdapter(adapterGrid); }else{ @@ -3300,9 +3329,11 @@ public void updatePeers(boolean flag){ }else{ if(adapterGrid != null){ + adapterGrid.onDestroy(); adapterGrid = null; } if(adapterList != null){ + adapterList.onDestroy(); adapterList = null; } recyclerView.setAdapter(null); @@ -3317,6 +3348,7 @@ public void updatePeers(boolean flag){ //7 + if(adapterGrid != null){ + adapterGrid.onDestroy(); adapterGrid = null; } recyclerView.setAdapter(null); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index d427dd914da..1a685252cff 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -75,6 +75,7 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, boolean isGrid) { @@ -144,12 +145,13 @@ public ViewHolderGroupCallGrid(View v) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false); - maxScreenHeight = (int)heightScreenPX; + int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + statusBarHeight = context.getResources().getDimensionPixelSize(resourceId); + } + maxScreenHeight = (int)heightScreenPX - statusBarHeight; maxScreenWidth = (int)widthScreenPX; - log("onCreateViewHolder() maxScreenHeight: "+maxScreenHeight+", maxScreenWidth: "+maxScreenWidth); - - holderGrid = new ViewHolderGroupCallGrid(v); holderGrid.rlGeneral = (RelativeLayout) v.findViewById(R.id.general); @@ -475,7 +477,6 @@ public void onClick(View v) { }else{ megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); } - if(holder.parentSurfaceView.getChildCount() == 0){ log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() == 0"); @@ -499,8 +500,6 @@ public void onClick(View v) { } peer.setListener(null); } - - holder.avatarMicroLayout.setVisibility(View.VISIBLE); //Avatar: @@ -595,7 +594,7 @@ public InfoPeerGroupCall getNodeAt(int position) { return null; } - //My AVATAR + //My avatar public void setProfileMyAvatar(ViewHolderGroupCall holder) { log("setProfileMyAvatar"); Bitmap myBitmap = null; @@ -629,7 +628,7 @@ public void setProfileMyAvatar(ViewHolderGroupCall holder) { createMyDefaultAvatar(holder); } } - //My Default AVATAR + //My Default avatar public void createMyDefaultAvatar(ViewHolderGroupCall holder) { log("createMyDefaultAvatar"); @@ -664,7 +663,7 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { holder.avatarInitialLetter.setVisibility(View.VISIBLE); } - //CONTACT AVATAR + //Contact avatar public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ log("setProfileContactAvatar"); @@ -732,7 +731,7 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde createDefaultAvatar(userHandle, fullName, holder); } } - //CONTACT Default AVATAR + //Contact Default avatar public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGroupCall holder) { log("createDefaultAvatar"); @@ -903,6 +902,55 @@ public void resetSize(Long userHandle) { } } + public void onDestroy(){ + log("onDestroy()"); + ViewHolderGroupCall holder = null; + for(int i=0; i getPeers() { return peers; } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index d55ce4f7839..1d4ec5a4975 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -31,10 +31,6 @@ android:id="@+id/rl_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="0dp" - android:paddingBottom="0dp" - android:paddingRight="0dp" - android:paddingLeft="0dp" android:gravity="center" android:orientation="vertical"> From bd6da1a3d4c884dd638f1a106eedf46be9c1b617 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 22 Nov 2018 14:30:36 +0100 Subject: [PATCH 119/247] Feature #10972 - Chat node history --- .../lollipop/ContactInfoActivityLollipop.java | 14 + .../NodeAttachmentHistoryActivity.java | 710 ++++++++++++++ .../NodeAttachmentHistoryAdapter.java | 875 ++++++++++++++++++ .../app/utils/ThumbnailUtilsLollipop.java | 85 +- ...ntent_chat_contact_properties_activity.xml | 41 +- app/src/main/res/values/strings.xml | 1 + 6 files changed, 1696 insertions(+), 30 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index dd977aff710..5c369ef1496 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -164,6 +164,9 @@ public class ContactInfoActivityLollipop extends PinActivityLollipop implements RelativeLayout shareContactLayout; View dividerShareContactLayout; + RelativeLayout sharedFilesLayout; + View dividerSharedFilesLayout; + //Toolbar elements ImageView contactStateIcon; TextView firstLineTextToolbar; @@ -387,6 +390,13 @@ public void run() { dividerShareContactLayout = (View) findViewById(R.id.divider_share_contact_layout); + //Chat Shared Files Layout + + sharedFilesLayout = (RelativeLayout) findViewById(R.id.chat_contact_properties_chat_files_shared_layout); + sharedFilesLayout.setOnClickListener(this); + + dividerSharedFilesLayout = (View) findViewById(R.id.divider_chat_files_shared_layout); + //Clear chat Layout clearChatLayout = (RelativeLayout) findViewById(R.id.chat_contact_properties_clear_layout); clearChatLayout.setOnClickListener(this); @@ -1269,6 +1279,10 @@ public void onClick(View v) { } break; } + case R.id.chat_contact_properties_chat_files_shared_layout:{ + + break; + } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java new file mode 100644 index 00000000000..5e7b7df3cc8 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -0,0 +1,710 @@ +package mega.privacy.android.app.lollipop.megachat; + +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.res.Resources; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.support.design.widget.Snackbar; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.GestureDetectorCompat; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AlertDialog; +import android.support.v7.view.ActionMode; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.util.DisplayMetrics; +import android.view.Display; +import android.view.GestureDetector; +import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.R; +import mega.privacy.android.app.components.PositionDividerItemDecoration; +import mega.privacy.android.app.lollipop.LoginActivityLollipop; +import mega.privacy.android.app.lollipop.ManagerActivityLollipop; +import mega.privacy.android.app.lollipop.PinActivityLollipop; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.NodeAttachmentHistoryAdapter; +import mega.privacy.android.app.utils.Constants; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatApi; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatError; +import nz.mega.sdk.MegaChatListItem; +import nz.mega.sdk.MegaChatListenerInterface; +import nz.mega.sdk.MegaChatMessage; +import nz.mega.sdk.MegaChatNodeHistoryListenerInterface; +import nz.mega.sdk.MegaChatPresenceConfig; +import nz.mega.sdk.MegaChatRequest; +import nz.mega.sdk.MegaChatRequestListenerInterface; +import nz.mega.sdk.MegaChatRoom; +import nz.mega.sdk.MegaNode; + +public class NodeAttachmentHistoryActivity extends PinActivityLollipop implements MegaChatRequestListenerInterface, RecyclerView.OnItemTouchListener, GestureDetector.OnGestureListener, OnClickListener, MegaChatListenerInterface, MegaChatNodeHistoryListenerInterface { + + public static int NUMBER_MESSAGES_TO_LOAD = 20; + public static int NUMBER_MESSAGES_BEFORE_LOAD = 8; + + MegaApiAndroid megaApi; + MegaChatApiAndroid megaChatApi; + ActionBar aB; + Toolbar tB; + NodeAttachmentHistoryActivity nodeAttachmentHistoryActivity = this; + + MegaChatMessage selectedMessage; + + int selectedPosition; + + RelativeLayout container; + RecyclerView listView; + LinearLayoutManager mLayoutManager; + GestureDetectorCompat detector; + ImageView emptyImage; + TextView emptyText; + + ArrayList messages; + + MegaChatRoom chatRoom; + + NodeAttachmentHistoryAdapter adapter; + + private ActionMode actionMode; + + ProgressDialog statusDialog; + + MenuItem selectMenuItem; + MenuItem unSelectMenuItem; + + Handler handler; + int stateHistory; + long chatId = -1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + log("onCreate"); + super.onCreate(savedInstanceState); + + if (megaApi == null){ + megaApi = ((MegaApplication) getApplication()).getMegaApi(); + } + + if(megaApi==null||megaApi.getRootNode()==null){ + log("Refresh session - sdk"); + Intent intent = new Intent(this, LoginActivityLollipop.class); + intent.putExtra("visibleFragment", Constants. LOGIN_FRAGMENT); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + finish(); + return; + } + + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) getApplication()).getMegaChatApi(); + } + + if(megaChatApi==null||megaChatApi.getInitState()==MegaChatApi.INIT_ERROR||megaChatApi.getInitState()==0){ + log("Refresh session - karere"); + Intent intent = new Intent(this, LoginActivityLollipop.class); + intent.putExtra("visibleFragment", Constants. LOGIN_FRAGMENT); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + finish(); + return; + } + + log("addChatListener"); + megaChatApi.addChatListener(this); + megaChatApi.addNodeHistoryListener(chatId,this); + + handler = new Handler(); + + Display display = getWindowManager().getDefaultDisplay(); + DisplayMetrics outMetrics = new DisplayMetrics (); + display.getMetrics(outMetrics); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = this.getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.setStatusBarColor(ContextCompat.getColor(this, R.color.lollipop_dark_primary_color)); + } + + setContentView(R.layout.activity_versions_file); + + //Set toolbar + tB = (Toolbar) findViewById(R.id.toolbar_versions_file); + setSupportActionBar(tB); + aB = getSupportActionBar(); +// aB.setHomeAsUpIndicator(R.drawable.ic_menu_white); + aB.setDisplayHomeAsUpEnabled(true); + aB.setDisplayShowHomeEnabled(true); + aB.setTitle(getString(R.string.title_section_versions)); + + container = (RelativeLayout) findViewById(R.id.versions_main_layout); + + detector = new GestureDetectorCompat(this, new RecyclerViewOnGestureListener()); + + listView = (RecyclerView) findViewById(R.id.recycler_view_versions_file); + listView.setPadding(0, 0, 0, Util.scaleHeightPx(85, outMetrics)); + listView.setClipToPadding(false); + listView.addItemDecoration(new PositionDividerItemDecoration(this, outMetrics)); + mLayoutManager = new LinearLayoutManager(this); + listView.setLayoutManager(mLayoutManager); + listView.addOnItemTouchListener(this); + listView.setItemAnimator(new DefaultItemAnimator()); + + emptyImage = (ImageView) findViewById(R.id.versions_file_empty_image); + emptyText = (TextView) findViewById(R.id.versions_file_empty_text); + emptyImage.setImageResource(R.drawable.ic_empty_contacts); + emptyText.setText(R.string.contacts_list_empty_text); + + if (savedInstanceState != null){ + chatId = savedInstanceState.getLong("chatId", -1); + } + + Bundle extras = getIntent().getExtras(); + if (extras != null){ + if(chatId==-1){ + chatId = extras.getLong("chatId"); + } + + chatRoom=megaChatApi.getChatRoom(chatId); + + if(chatRoom!=null){ + messages = new ArrayList<>(); + + if (messages.size() != 0){ + emptyImage.setVisibility(View.GONE); + emptyText.setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); + } + else{ + emptyImage.setVisibility(View.VISIBLE); + emptyText.setVisibility(View.VISIBLE); + listView.setVisibility(View.GONE); + } + + boolean result = megaChatApi.openNodeHistory(chatId, this); + if(result){ + log("Node history opened correctly"); + + messages = new ArrayList(); + + if (adapter == null){ + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + } + + listView.setAdapter(adapter); + adapter.setMultipleSelect(false); + + stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); + } + } + else{ + log("ERROR: node is NULL"); + } + + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + } + } + + public void showOptionsPanel(MegaChatMessage sMessage, int sPosition){ + log("showOptionsPanel"); + if(sMessage!=null){ + this.selectedMessage = sMessage; + this.selectedPosition = sPosition; + //VersionBottomSheetDialogFragment bottomSheetDialogFragment = new VersionBottomSheetDialogFragment(); + //bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag()); + } + } + + @Override + protected void onDestroy(){ + log("onDestroy"); + super.onDestroy(); + + megaChatApi.removeChatListener(this); + megaChatApi.removeNodeHistoryListener(chatId,this); + megaChatApi.closeNodeHistory(chatId, null); + handler.removeCallbacksAndMessages(null); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + + // Inflate the menu items for use in the action bar + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.activity_folder_contact_list, menu); + + selectMenuItem = menu.findItem(R.id.action_select); + unSelectMenuItem = menu.findItem(R.id.action_unselect); + + menu.findItem(R.id.action_folder_contacts_list_share_folder).setVisible(false); + + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + selectMenuItem.setVisible(true); + unSelectMenuItem.setVisible(false); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + // Handle presses on the action bar items + switch (item.getItemId()) { + case android.R.id.home:{ + onBackPressed(); + return true; + } + case R.id.action_select:{ + + selectAll(); + return true; + } + default:{ + return super.onOptionsItemSelected(item); + } + } + } + + // Clear all selected items + private void clearSelections() { + if(adapter.isMultipleSelect()){ + adapter.clearSelections(); + } + } + + public void selectAll(){ + log("selectAll"); + if (adapter != null){ + if(adapter.isMultipleSelect()){ + adapter.selectAll(); + } + else{ + adapter.setMultipleSelect(true); + adapter.selectAll(); + + actionMode = startSupportActionMode(new ActionBarCallBack()); + } + updateActionModeTitle(); + } + } + + public boolean showSelectMenuItem(){ + if (adapter != null){ + return adapter.isMultipleSelect(); + } + + return false; + } + + public static void log(String log) { + Util.log("VersionsFileActivity", log); + } + + public void itemClick(int position) { + log("itemClick"); + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + if (adapter.isMultipleSelect()){ + adapter.toggleSelection(position); + updateActionModeTitle(); + } + else{ + MegaChatMessage m = messages.get(position); + //showOptionsPanel(m, position); + } + } + + @Override + public void onBackPressed() { + log("onBackPressed"); + super.onBackPressed(); + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + } + + private void updateActionModeTitle() { + log("updateActionModeTitle"); + if (actionMode == null) { + return; + } + List msgs = adapter.getSelectedMessages(); + + Resources res = getResources(); + String format = "%d %s"; + + actionMode.setTitle(String.format(format, msgs.size(),res.getQuantityString(R.plurals.general_num_files, msgs.size()))); + try { + actionMode.invalidate(); + } catch (NullPointerException e) { + e.printStackTrace(); + log("oninvalidate error"); + } + } + + /* + * Disable selection + */ + public void hideMultipleSelect() { + adapter.setMultipleSelect(false); + if (actionMode != null) { + actionMode.finish(); + } + } + + @Override + public void onClick(View v) { + ((MegaApplication) getApplication()).sendSignalPresenceActivity(); + switch (v.getId()){ + case R.id.file_contact_list_layout:{ + Intent i = new Intent(this, ManagerActivityLollipop.class); + i.setAction(Constants.ACTION_REFRESH_PARENTHANDLE_BROWSER); + //i.putExtra("parentHandle", node.getHandle()); + startActivity(i); + finish(); + break; + } + } + } + + public void notifyDataSetChanged(){ + if (adapter != null){ + adapter.notifyDataSetChanged(); + } + } + + @Override + public boolean onDown(MotionEvent e) { + return false; + } + + @Override + public void onShowPress(MotionEvent e) { + + } + + @Override + public boolean onSingleTapUp(MotionEvent e) { + return false; + } + + @Override + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, + float distanceY) { + return false; + } + + @Override + public void onLongPress(MotionEvent e) { + } + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + return false; + } + + @Override + public boolean onInterceptTouchEvent(RecyclerView rV, MotionEvent e) { + detector.onTouchEvent(e); + return false; + } + + @Override + public void onRequestDisallowInterceptTouchEvent(boolean arg0) { + } + + @Override + public void onTouchEvent(RecyclerView arg0, MotionEvent arg1) { + } + + public MegaChatMessage getSelectedMessage() { + return selectedMessage; + } + + public void showSnackbar(String s){ + log("showSnackbar"); + Snackbar snackbar = Snackbar.make(container, s, Snackbar.LENGTH_LONG); + TextView snackbarTextView = (TextView)snackbar.getView().findViewById(android.support.design.R.id.snackbar_text); + snackbarTextView.setMaxLines(5); + snackbar.show(); + } + + public int getSelectedPosition() { + return selectedPosition; + } + + public void setSelectedPosition(int selectedPosition) { + this.selectedPosition = selectedPosition; + } + + public void showConfirmationRemoveVersion(){ + log("showConfirmationRemoveContact"); + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + break; + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getResources().getQuantityString(R.plurals.title_dialog_delete_version, 1)); + builder.setMessage(getString(R.string.content_dialog_delete_version)).setPositiveButton(R.string.context_delete, dialogClickListener) + .setNegativeButton(R.string.general_cancel, dialogClickListener).show(); + + } + + public void showConfirmationRemoveVersions(final List removeNodes){ + log("showConfirmationRemoveContactRequests"); + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + break; + } + } + }; + + String message=""; + String title=""; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + if(removeNodes.size()==1){ + + title = getResources().getQuantityString(R.plurals.title_dialog_delete_version, 1); + + message= getResources().getString(R.string.content_dialog_delete_version); + }else{ + title = getResources().getQuantityString(R.plurals.title_dialog_delete_version, removeNodes.size()); + message= getResources().getString(R.string.content_dialog_delete_multiple_version,removeNodes.size()); + } + builder.setTitle(title); + builder.setMessage(message).setPositiveButton(R.string.context_delete, dialogClickListener) + .setNegativeButton(R.string.general_cancel, dialogClickListener).show(); + + } + + @Override + public void onSaveInstanceState(Bundle outState) { + log("onSaveInstanceState"); + super.onSaveInstanceState(outState); + outState.putLong("chatId", chatRoom.getChatId()); + } + + //Multiselection + + public class RecyclerViewOnGestureListener extends SimpleOnGestureListener{ + + public void onLongPress(MotionEvent e) { + log("onLongPress -- RecyclerViewOnGestureListener"); + + View view = listView.findChildViewUnder(e.getX(), e.getY()); + int position = listView.getChildLayoutPosition(view); + + if (!adapter.isMultipleSelect()){ + + if(position<0){ + log("Position not valid: "+position); + } + else{ + adapter.setMultipleSelect(true); + + actionMode = startSupportActionMode(new ActionBarCallBack()); + + itemClick(position); + } + } + + super.onLongPress(e); + } + } + + private class ActionBarCallBack implements ActionMode.Callback { + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + log("onActionItemClicked"); + final List nodes = adapter.getSelectedMessages(); + + switch(item.getItemId()){ + case R.id.cab_menu_select_all:{ + selectAll(); + actionMode.invalidate(); + break; + } + case R.id.cab_menu_unselect_all:{ + clearSelections(); + actionMode.invalidate(); + break; + } + case R.id.action_download_versions:{ + + break; + } + case R.id.action_delete_versions:{ + //showConfirmationRemoveVersions(nodes); + break; + } + } + return false; + } + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + log("onCreateActionMode"); + MenuInflater inflater = mode.getMenuInflater(); + inflater.inflate(R.menu.versions_files_action, menu); + menu.findItem(R.id.cab_menu_select_all).setVisible(true); + menu.findItem(R.id.action_download_versions).setVisible(false); + menu.findItem(R.id.action_delete_versions).setVisible(false); + Util.changeStatusBarColorActionMode(getApplicationContext(), getWindow(), handler, 1); + return true; + } + + @Override + public void onDestroyActionMode(ActionMode arg0) { + log("onDestroyActionMode"); + adapter.clearSelections(); + adapter.setMultipleSelect(false); + Util.changeStatusBarColorActionMode(getApplicationContext(), getWindow(), handler, 0); + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + log("onPrepareActionMode"); + List selected = adapter.getSelectedMessages(); + + if (selected.size() != 0) { + + MenuItem unselect = menu.findItem(R.id.cab_menu_unselect_all); + if(selected.size()==adapter.getItemCount()){ + menu.findItem(R.id.cab_menu_select_all).setVisible(false); + unselect.setTitle(getString(R.string.action_unselect_all)); + unselect.setVisible(true); + } + else{ + menu.findItem(R.id.cab_menu_select_all).setVisible(true); + unselect.setTitle(getString(R.string.action_unselect_all)); + unselect.setVisible(true); + } + menu.findItem(R.id.action_download_versions).setVisible(false); + menu.findItem(R.id.action_delete_versions).setVisible(true); + } + else{ + menu.findItem(R.id.cab_menu_select_all).setVisible(true); + menu.findItem(R.id.cab_menu_unselect_all).setVisible(false); + menu.findItem(R.id.action_download_versions).setVisible(false); + menu.findItem(R.id.action_delete_versions).setVisible(false); + } + + return false; + } + } + + @Override + public void onChatListItemUpdate(MegaChatApiJava api, MegaChatListItem item) { + + } + + @Override + public void onChatInitStateUpdate(MegaChatApiJava api, int newState) { + + } + + @Override + public void onChatOnlineStatusUpdate(MegaChatApiJava api, long userhandle, int status, boolean inProgress) { + + } + + @Override + public void onChatPresenceConfigUpdate(MegaChatApiJava api, MegaChatPresenceConfig config) { + + } + + @Override + public void onChatConnectionStateUpdate(MegaChatApiJava api, long chatid, int newState) { + + } + + @Override + public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int lastGreen) { + + } + + @Override + public void onRequestStart(MegaChatApiJava api, MegaChatRequest request) { + + } + + @Override + public void onRequestUpdate(MegaChatApiJava api, MegaChatRequest request) { + + } + + @Override + public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaChatError e) { + + } + + @Override + public void onRequestTemporaryError(MegaChatApiJava api, MegaChatRequest request, MegaChatError e) { + + } + + @Override + public void onAttachmentLoaded(MegaChatApiJava api, MegaChatMessage msg) { + log("onAttachmentLoaded"); + } + + @Override + public void onAttachmentReceived(MegaChatApiJava api, MegaChatMessage msg) { + log("onAttachmentReceived"); + } + + @Override + public void onAttachmentDeleted(MegaChatApiJava api, long msgid) { + log("onAttachmentDeleted"); + } + + @Override + public void onTruncate(MegaChatApiJava api, long msgid) { + log("onTruncate"); + } +} + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java new file mode 100644 index 00000000000..b3c1e39c53f --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -0,0 +1,875 @@ +package mega.privacy.android.app.lollipop.megachat.chatAdapters; + +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.RecyclerView; +import android.util.DisplayMetrics; +import android.util.SparseBooleanArray; +import android.util.TypedValue; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import mega.privacy.android.app.DatabaseHandler; +import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.MimeTypeList; +import mega.privacy.android.app.MimeTypeThumbnail; +import mega.privacy.android.app.R; +import mega.privacy.android.app.lollipop.ManagerActivityLollipop; +import mega.privacy.android.app.lollipop.managerSections.FileBrowserFragmentLollipop; +import mega.privacy.android.app.utils.ThumbnailUtils; +import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; +import mega.privacy.android.app.utils.Util; +import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatMessage; +import nz.mega.sdk.MegaNode; + +public class NodeAttachmentHistoryAdapter extends RecyclerView.Adapter implements OnClickListener, View.OnLongClickListener { + + public static final int ITEM_VIEW_TYPE_LIST = 0; + public static final int ITEM_VIEW_TYPE_GRID = 1; + + Context context; + MegaApiAndroid megaApi; + + // int positionClicked; + ArrayList messages; + + Object fragment; + long parentHandle = -1; + DisplayMetrics outMetrics; + + private SparseBooleanArray selectedItems; + + RecyclerView listFragment; + + DatabaseHandler dbH = null; + boolean multipleSelect; + + int adapterType; + + public static class ViewHolderBrowser extends RecyclerView.ViewHolder { + + public ViewHolderBrowser(View v) { + super(v); + } + + public TextView textViewFileName; + public TextView textViewFileSize; + public long document; + public RelativeLayout itemLayout; + } + + public static class ViewHolderBrowserList extends NodeAttachmentHistoryAdapter.ViewHolderBrowser { + + public ViewHolderBrowserList(View v) { + super(v); + } + public ImageView imageView; + public RelativeLayout threeDotsLayout; + } + + public static class ViewHolderBrowserGrid extends NodeAttachmentHistoryAdapter.ViewHolderBrowser { + + public ViewHolderBrowserGrid(View v) { + super(v); + } + + public ImageView imageViewThumb; + public ImageView imageViewIcon; + public RelativeLayout thumbLayout; + public View separator; + public ImageView imageViewVideoIcon; + public TextView videoDuration; + public RelativeLayout videoInfoLayout; + public ImageButton imageButtonThreeDots; + + public View fileLayout; + public RelativeLayout thumbLayoutForFile; + public ImageView fileGridIconForFile; + public ImageButton imageButtonThreeDotsForFile; + public TextView textViewFileNameForFile; + public ImageView fileGridSelected; + } + + public void toggleAllSelection(int pos) { + log("toggleAllSelection: " + pos); + final int positionToflip = pos; + + if (selectedItems.get(pos,false)) { + log("delete pos: " + pos); + selectedItems.delete(pos); + + } else { + log("PUT pos: " + pos); + selectedItems.put(pos,true); + } + + if (adapterType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST) { + log("adapter type is LIST"); + NodeAttachmentHistoryAdapter.ViewHolderBrowserList view = (NodeAttachmentHistoryAdapter.ViewHolderBrowserList)listFragment.findViewHolderForLayoutPosition(pos); + if (view != null) { + log("Start animation: " + pos + " multiselection state: " + isMultipleSelect()); + Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); + flipAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + log("onAnimationEnd: " + selectedItems.size()); + if (selectedItems.size() <= 0) { + log("toggleAllSelection: hideMultipleSelect"); + + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); + } + log("toggleAllSelection: notified item changed"); + notifyItemChanged(positionToflip); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + view.imageView.startAnimation(flipAnimation); + } else { + log("NULL view pos: " + positionToflip); + notifyItemChanged(pos); + } + } else { + log("adapter type is GRID"); + if (selectedItems.size() <= 0) { + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); + } + notifyItemChanged(positionToflip); + } + } + + public void toggleSelection(int pos) { + log("toggleSelection: " + pos); + + if (selectedItems.get(pos,false)) { + log("delete pos: " + pos); + selectedItems.delete(pos); + } else { + log("PUT pos: " + pos); + selectedItems.put(pos,true); + } + notifyItemChanged(pos); + if (adapterType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST) { + log("adapter type is LIST"); + NodeAttachmentHistoryAdapter.ViewHolderBrowserList view = (NodeAttachmentHistoryAdapter.ViewHolderBrowserList)listFragment.findViewHolderForLayoutPosition(pos); + if (view != null) { + log("Start animation: " + pos); + Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); + flipAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + if (selectedItems.size() <= 0) { + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); + } + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + + view.imageView.startAnimation(flipAnimation); + + } else { + log("view is null - not animation"); + if (selectedItems.size() <= 0) { + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); + } + } + } else { + log("adapter type is GRID"); + + if (selectedItems.size() <= 0) { + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); + } + } + } + + public void selectAll() { + for (int i = 0;i < messages.size();i++) { + if (!isItemChecked(i)) { + //Exlude placeholder. + if (messages.get(i) != null) { + toggleAllSelection(i); + } + } + } + } + + public void clearSelections() { + log("clearSelections"); + for (int i = 0;i < messages.size();i++) { + if (isItemChecked(i)) { + //Exlude placeholder. + if (messages.get(i) != null) { + toggleAllSelection(i); + } + } + } + } + + // public void clearSelections() { +// if(selectedItems!=null){ +// selectedItems.clear(); +// for (int i= 0; i getSelectedItems() { + List items = new ArrayList(selectedItems.size()); + for (int i = 0;i < selectedItems.size();i++) { + items.add(selectedItems.keyAt(i)); + } + return items; + } + + /* + * Get list of all selected messages + */ + public List getSelectedMessages() { + ArrayList messages = new ArrayList(); + + for (int i = 0;i < selectedItems.size();i++) { + if (selectedItems.valueAt(i) == true) { + MegaChatMessage message = getMessageAt(selectedItems.keyAt(i)); + if (message != null) { + messages.add(message); + } + } + } + return messages; + } + + public NodeAttachmentHistoryAdapter(Context _context, ArrayList _messages, RecyclerView recyclerView, int adapterType) { + + this.context = _context; + this.messages = _messages; + this.adapterType = adapterType; + + + dbH = DatabaseHandler.getDbHandler(context); + + this.listFragment = recyclerView; + + if (megaApi == null) { + megaApi = ((MegaApplication)((Activity)context).getApplication()).getMegaApi(); + } + } + + public void setNodes(ArrayList messages) { + log("setNodes"); +// contentTextFragment.setText(getInfoFolder(node)); + notifyDataSetChanged(); + } + + public void setAdapterType(int adapterType) { + this.adapterType = adapterType; + } + + public int getAdapterType() { + return adapterType; + } + + public NodeAttachmentHistoryAdapter.ViewHolderBrowser onCreateViewHolder(ViewGroup parent, int viewType) { + log("onCreateViewHolder"); + Display display = ((Activity)context).getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics(); + display.getMetrics(outMetrics); + + if (viewType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST) { + log("onCreateViewHolder -> type: ITEM_VIEW_TYPE_LIST"); + + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_file_list,parent,false); + ViewHolderBrowserList holderList = new ViewHolderBrowserList(v); + holderList.itemLayout = (RelativeLayout)v.findViewById(R.id.file_list_item_layout); + holderList.imageView = (ImageView)v.findViewById(R.id.file_list_thumbnail); + + holderList.textViewFileName = (TextView)v.findViewById(R.id.file_list_filename); + + holderList.textViewFileSize = (TextView)v.findViewById(R.id.file_list_filesize); + + holderList.threeDotsLayout = (RelativeLayout)v.findViewById(R.id.file_list_three_dots_layout); + + holderList.textViewFileSize.setVisibility(View.VISIBLE); + + holderList.itemLayout.setTag(holderList); + holderList.itemLayout.setOnClickListener(this); + holderList.itemLayout.setOnLongClickListener(this); + + holderList.threeDotsLayout.setTag(holderList); + holderList.threeDotsLayout.setOnClickListener(this); + + v.setTag(holderList); + return holderList; + } else if (viewType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_GRID) { + log("onCreateViewHolder -> type: ITEM_VIEW_TYPE_GRID"); + + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_file_grid_new,parent,false); + NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid holderGrid = new NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid(v); + + holderGrid.fileLayout = v.findViewById(R.id.item_file_grid_file); + holderGrid.itemLayout = (RelativeLayout)v.findViewById(R.id.file_grid_item_layout); + holderGrid.imageViewThumb = (ImageView)v.findViewById(R.id.file_grid_thumbnail); + holderGrid.imageViewIcon = (ImageView)v.findViewById(R.id.file_grid_icon); + holderGrid.fileGridIconForFile = (ImageView)v.findViewById(R.id.file_grid_icon_for_file); + holderGrid.thumbLayout = (RelativeLayout)v.findViewById(R.id.file_grid_thumbnail_layout); + holderGrid.thumbLayoutForFile = (RelativeLayout)v.findViewById(R.id.file_grid_thumbnail_layout_for_file); + holderGrid.textViewFileName = (TextView)v.findViewById(R.id.file_grid_filename); + holderGrid.textViewFileNameForFile = (TextView)v.findViewById(R.id.file_grid_filename_for_file); + holderGrid.imageButtonThreeDotsForFile = (ImageButton)v.findViewById(R.id.file_grid_three_dots_for_file); + holderGrid.textViewFileSize = (TextView)v.findViewById(R.id.file_grid_filesize); + holderGrid.imageButtonThreeDots = (ImageButton)v.findViewById(R.id.file_grid_three_dots); + + holderGrid.separator = (View)v.findViewById(R.id.file_grid_separator); + + holderGrid.imageViewVideoIcon = (ImageView)v.findViewById(R.id.file_grid_video_icon); + holderGrid.videoDuration = (TextView)v.findViewById(R.id.file_grid_title_video_duration); + holderGrid.videoInfoLayout = (RelativeLayout)v.findViewById(R.id.item_file_videoinfo_layout); + holderGrid.fileGridSelected = (ImageView)v.findViewById(R.id.file_grid_selected); + + if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + holderGrid.textViewFileSize.setMaxWidth(Util.scaleWidthPx(70,outMetrics)); + } else { + holderGrid.textViewFileSize.setMaxWidth(Util.scaleWidthPx(130,outMetrics)); + } + if (holderGrid.textViewFileSize != null) { + holderGrid.textViewFileSize.setVisibility(View.VISIBLE); + } else { + log("textViewFileSize is NULL"); + } + + holderGrid.itemLayout.setTag(holderGrid); + holderGrid.itemLayout.setOnClickListener(this); + holderGrid.itemLayout.setOnLongClickListener(this); + + holderGrid.imageButtonThreeDots.setTag(holderGrid); + holderGrid.imageButtonThreeDots.setOnClickListener(this); + holderGrid.imageButtonThreeDotsForFile.setTag(holderGrid); + holderGrid.imageButtonThreeDotsForFile.setOnClickListener(this); + v.setTag(holderGrid); + + return holderGrid; + } else { + return null; + } + } + + public void onBindViewHolder(NodeAttachmentHistoryAdapter.ViewHolderBrowser holder, int position) { + log("onBindViewHolder"); + + if (adapterType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST) { + NodeAttachmentHistoryAdapter.ViewHolderBrowserList holderList = (NodeAttachmentHistoryAdapter.ViewHolderBrowserList)holder; + onBindViewHolderList(holderList,position); + } else if (adapterType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_GRID) { + NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid holderGrid = (NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder; + onBindViewHolderGrid(holderGrid,position); + } + } + + public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { + log("onBindViewHolderGrid"); + MegaChatMessage m = (MegaChatMessage)getItem(position); + MegaNode node = m.getMegaNodeList().get(0); + + holder.document = node.getHandle(); + Bitmap thumb = null; + + log("Node : " + position + " " + node.getName()); + + holder.textViewFileName.setText(node.getName()); + holder.textViewFileSize.setText(""); + holder.videoInfoLayout.setVisibility(View.GONE); + + holder.itemLayout.setVisibility(View.VISIBLE); + + holder.imageViewThumb.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); + holder.imageViewThumb.setVisibility(View.GONE); + holder.fileLayout.setVisibility(View.VISIBLE); + holder.textViewFileName.setVisibility(View.VISIBLE); + holder.textViewFileSize.setVisibility(View.GONE); + + holder.textViewFileNameForFile.setText(node.getName()); + long nodeSize = node.getSize(); + holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); + + holder.fileGridIconForFile.setVisibility(View.VISIBLE); + holder.fileGridIconForFile.setImageResource(MimeTypeThumbnail.typeForName(node.getName()).getIconResourceId()); + holder.thumbLayoutForFile.setBackgroundColor(Color.TRANSPARENT); + + if (multipleSelect && isItemChecked(position)) { +// holder.itemLayout.setForeground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); + holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); + holder.fileGridSelected.setVisibility(View.VISIBLE); + + } else { +// holder.itemLayout.setForeground(new ColorDrawable()); + holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); + holder.fileGridSelected.setVisibility(View.GONE); + } + + if (Util.isVideoFile(node.getName())) { + holder.videoInfoLayout.setVisibility(View.VISIBLE); + holder.videoDuration.setVisibility(View.GONE); + log(node.getName() + " DURATION: " + node.getDuration()); + int duration = node.getDuration(); + if (duration > 0) { + int hours = duration / 3600; + int minutes = (duration % 3600) / 60; + int seconds = duration % 60; + + String timeString; + if (hours > 0) { + timeString = String.format("%d:%d:%02d",hours,minutes,seconds); + } else { + timeString = String.format("%d:%02d",minutes,seconds); + } + + log("The duration is: " + hours + " " + minutes + " " + seconds); + + holder.videoDuration.setText(timeString); + holder.videoDuration.setVisibility(View.VISIBLE); + } + } + + if (node.hasThumbnail()) { + +// DisplayMetrics dm = new DisplayMetrics(); +// float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, dm); +// +// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.imageView.getLayoutParams(); +// params.width = ViewGroup.LayoutParams.MATCH_PARENT; +// params.height = ViewGroup.LayoutParams.MATCH_PARENT; +// holder.imageView.setLayoutParams(params); + + Bitmap temp = ThumbnailUtils.getThumbnailFromCache(node); + + if (temp != null) { + thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.fileGridIconForFile.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + + } else { + temp = ThumbnailUtils.getThumbnailFromFolder(node,context); + + if (temp != null) { + thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.fileGridIconForFile.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + + } else { + try { + temp = ThumbnailUtilsLollipop.getThumbnailFromMegaGrid(node,context,holder,megaApi,this); + + } catch (Exception e) { + } // Too many AsyncTasks + + if (temp != null) { + thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.imageViewIcon.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + } + } + } + } else { + Bitmap temp = ThumbnailUtils.getThumbnailFromCache(node); + +// thumb = ThumbnailUtils.getThumbnailFromCache(node); + if (temp != null) { + thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.fileGridIconForFile.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + } else { + temp = ThumbnailUtils.getThumbnailFromFolder(node,context); + + if (temp != null) { + thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.fileGridIconForFile.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + } else { + try { + ThumbnailUtilsLollipop.createThumbnailGrid(context,node,holder,megaApi,this); + } catch (Exception e) { + } // Too many AsyncTasks + } + } + } + } + + public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { + log("onBindViewHolderList: " + position); + MegaChatMessage m = (MegaChatMessage)getItem(position); + MegaNode node = m.getMegaNodeList().get(0); + + holder.document = node.getHandle(); + Bitmap thumb = null; + + holder.textViewFileName.setText(node.getName()); + holder.textViewFileSize.setText(""); + + long nodeSize = node.getSize(); + holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); + + if (!multipleSelect) { + log("Not multiselect"); + holder.itemLayout.setBackgroundColor(Color.WHITE); + holder.imageView.setImageResource(MimeTypeList.typeForName(node.getName()).getIconResourceId()); + + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + params.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + params.setMargins(0,0,0,0); + holder.imageView.setLayoutParams(params); + + log("Check the thumb"); + + if (node.hasThumbnail()) { + log("Node has thumbnail"); + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + + thumb = ThumbnailUtils.getThumbnailFromCache(node); + if (thumb != null) { + + holder.imageView.setImageBitmap(thumb); + + } else { + thumb = ThumbnailUtils + .getThumbnailFromFolder(node,context); + if (thumb != null) { + holder.imageView.setImageBitmap(thumb); + + } else { + try { + thumb = ThumbnailUtilsLollipop.getThumbnailFromMegaList(node,context,holder,megaApi,this); + } catch (Exception e) { + } // Too many AsyncTasks + + if (thumb != null) { + holder.imageView.setImageBitmap(thumb); + } + } + } + } else { + log("Node NOT thumbnail"); + thumb = ThumbnailUtils.getThumbnailFromCache(node); + if (thumb != null) { + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + holder.imageView.setImageBitmap(thumb); + + + } else { + thumb = ThumbnailUtils.getThumbnailFromFolder(node,context); + if (thumb != null) { + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + holder.imageView.setImageBitmap(thumb); + + } else { + try { + ThumbnailUtilsLollipop.createThumbnailList(context,node,holder,megaApi,this); + } catch (Exception e) { + } // Too many AsyncTasks + } + } + } + } else { + log("Multiselection ON"); + if (this.isItemChecked(position)) { + holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); + RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + paramsMultiselect.setMargins(0,0,0,0); + holder.imageView.setLayoutParams(paramsMultiselect); + holder.imageView.setImageResource(R.drawable.ic_select_folder); + } else { + holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.white)); + + log("Check the thumb"); + + if (node.hasThumbnail()) { + log("Node has thumbnail"); + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + + thumb = ThumbnailUtils.getThumbnailFromCache(node); + if (thumb != null) { + + holder.imageView.setImageBitmap(thumb); + + } else { + thumb = ThumbnailUtils + .getThumbnailFromFolder(node,context); + if (thumb != null) { + holder.imageView.setImageBitmap(thumb); + + } else { + try { + thumb = ThumbnailUtilsLollipop.getThumbnailFromMegaList(node,context,holder,megaApi,this); + } catch (Exception e) { + } // Too many AsyncTasks + + if (thumb != null) { + holder.imageView.setImageBitmap(thumb); + } + } + } + } else { + log("Node NOT thumbnail"); + + thumb = ThumbnailUtils.getThumbnailFromCache(node); + if (thumb != null) { + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + holder.imageView.setImageBitmap(thumb); + + + } else { + thumb = ThumbnailUtils.getThumbnailFromFolder(node,context); + if (thumb != null) { + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + params1.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + params1.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,context.getResources().getDisplayMetrics()); + int left = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,6,context.getResources().getDisplayMetrics()); + params1.setMargins(left,0,0,0); + + holder.imageView.setLayoutParams(params1); + holder.imageView.setImageBitmap(thumb); + + } else { + log("NOT thumbnail"); + holder.imageView.setImageResource(MimeTypeList.typeForName(node.getName()).getIconResourceId()); + try { + ThumbnailUtilsLollipop.createThumbnailList(context,node,holder,megaApi,this); + } catch (Exception e) { + } // Too many AsyncTasks + } + } + } + } + } + + } + + @Override + public int getItemCount() { + if (messages != null) { + return messages.size(); + } else { + return 0; + } + } + + @Override + public int getItemViewType(int position) { + return adapterType; + } + + public Object getItem(int position) { + if (messages != null) { + return messages.get(position); + } + + return null; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public void onClick(View v) { + log("onClick"); + ((MegaApplication)((Activity)context).getApplication()).sendSignalPresenceActivity(); + + ViewHolderBrowser holder = (ViewHolderBrowser)v.getTag(); + int currentPosition = holder.getAdapterPosition(); + + log("onClick -> Current position: " + currentPosition); + + if (currentPosition < 0) { + log("Current position error - not valid value"); + return; + } + + final MegaChatMessage m = (MegaChatMessage)getItem(currentPosition); + if (m == null) { + return; + } + switch (v.getId()) { + case R.id.file_list_three_dots_layout: + case R.id.file_grid_three_dots: { + //threeDotsClicked(currentPosition,n); + break; + } + case R.id.file_grid_three_dots_for_file: { + //threeDotsClicked(currentPosition,n); + break; + } + case R.id.file_list_item_layout: + case R.id.file_grid_item_layout: { + int[] screenPosition = new int[2]; + ImageView imageView; + if (adapterType == NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST) { + imageView = (ImageView)v.findViewById(R.id.file_list_thumbnail); + } else { + imageView = (ImageView)v.findViewById(R.id.file_grid_thumbnail); + } + imageView.getLocationOnScreen(screenPosition); + + int[] dimens = new int[4]; + dimens[0] = screenPosition[0]; + dimens[1] = screenPosition[1]; + dimens[2] = imageView.getWidth(); + dimens[3] = imageView.getHeight(); + + ((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,dimens,imageView); + break; + } + } + } + + + private void threeDotsClicked(int currentPosition,MegaChatMessage m) { + log("onClick: file_list_three_dots: " + currentPosition); + if (!Util.isOnline(context)) { + if (context instanceof ManagerActivityLollipop) { + ((ManagerActivityLollipop)context).showSnackbar(context.getString(R.string.error_server_connection_problem)); + } + return; + } + + if (multipleSelect) { + ((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,null,null); + } + else { + //Show panel option + //((ManagerActivityLollipop)context).showNodeOptionsPanel(m); + } + } + + @Override + public boolean onLongClick(View view) { + log("OnLongCLick"); + ((MegaApplication)((Activity)context).getApplication()).sendSignalPresenceActivity(); + + ViewHolderBrowser holder = (ViewHolderBrowser)view.getTag(); + int currentPosition = holder.getAdapterPosition(); +// Toast.makeText(context,"pos:" + currentPosition ,Toast.LENGTH_SHORT ).show(); + + ((FileBrowserFragmentLollipop)fragment).activateActionMode(); + ((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,null,null); + + return true; + } + + public MegaChatMessage getMessageAt(int position) { + try { + if (messages != null) { + return messages.get(position); + } + } catch (IndexOutOfBoundsException e) { + } + return null; + } + + public boolean isMultipleSelect() { + return multipleSelect; + } + + public void setMultipleSelect(boolean multipleSelect) { + log("setMultipleSelect: " + multipleSelect); + if (this.multipleSelect != multipleSelect) { + this.multipleSelect = multipleSelect; + } + if (this.multipleSelect) { + selectedItems = new SparseBooleanArray(); + } + } + + private static void log(String log) { + Util.log("NodeAttachmentHistoryAdapter",log); + } +} \ No newline at end of file diff --git a/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java b/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java index 68fe7fb1350..51ea6a40c3e 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java @@ -51,6 +51,7 @@ import mega.privacy.android.app.lollipop.adapters.MegaTransfersLollipopAdapter; import mega.privacy.android.app.lollipop.adapters.MegaTransfersLollipopAdapter.ViewHolderTransfer; import mega.privacy.android.app.lollipop.adapters.VersionsFileAdapter; +import mega.privacy.android.app.lollipop.megachat.chatAdapters.NodeAttachmentHistoryAdapter; import mega.privacy.android.app.lollipop.providers.MegaProviderLollipopAdapter; import mega.privacy.android.app.lollipop.providers.MegaProviderLollipopAdapter.ViewHolderLollipopProvider; import nz.mega.sdk.MegaApiAndroid; @@ -436,10 +437,10 @@ public void onRequestUpdate(MegaApiJava api, MegaRequest request) { static class ThumbnailDownloadListenerGridBrowser implements MegaRequestListenerInterface { Context context; - MegaNodeAdapter.ViewHolderBrowserGrid holder; - MegaNodeAdapter adapter; + RecyclerView.ViewHolder holder; + RecyclerView.Adapter adapter; - ThumbnailDownloadListenerGridBrowser(Context context, MegaNodeAdapter.ViewHolderBrowserGrid holder, MegaNodeAdapter adapter) { + ThumbnailDownloadListenerGridBrowser(Context context, RecyclerView.ViewHolder holder, RecyclerView.Adapter adapter) { this.context = context; this.holder = holder; this.adapter = adapter; @@ -472,15 +473,29 @@ public void onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e) { final Bitmap bitmap = getBitmapForCache(thumb, context); if (bitmap != null) { thumbnailCache.put(handle, bitmap); - if ((holder.document == handle)) { - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewIcon.setVisibility(View.GONE); - holder.imageViewThumb.setImageBitmap(bitmap); - holder.thumbLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.new_background_fragment)); - Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in); - holder.imageViewThumb.startAnimation(fadeInAnimation); - adapter.notifyDataSetChanged(); - log("Thumbnail update"); + if(holder instanceof MegaNodeAdapter.ViewHolderBrowserGrid){ + if ((((MegaNodeAdapter.ViewHolderBrowserGrid)holder).document == handle)) { + ((MegaNodeAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.setVisibility(View.VISIBLE); + ((MegaNodeAdapter.ViewHolderBrowserGrid)holder).imageViewIcon.setVisibility(View.GONE); + ((MegaNodeAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.setImageBitmap(bitmap); + ((MegaNodeAdapter.ViewHolderBrowserGrid)holder).thumbLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.new_background_fragment)); + Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in); + ((MegaNodeAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.startAnimation(fadeInAnimation); + adapter.notifyDataSetChanged(); + log("Thumbnail update"); + } + } + else if(holder instanceof NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid){ + if ((((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).document == handle)) { + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.setVisibility(View.VISIBLE); + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).imageViewIcon.setVisibility(View.GONE); + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.setImageBitmap(bitmap); + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).thumbLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.new_background_fragment)); + Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in); + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserGrid)holder).imageViewThumb.startAnimation(fadeInAnimation); + adapter.notifyDataSetChanged(); + log("Thumbnail update"); + } } } } @@ -858,7 +873,7 @@ public static Bitmap getThumbnailFromMegaList(MegaNode document, Context context } - public static Bitmap getThumbnailFromMegaGrid(MegaNode document, Context context, MegaNodeAdapter.ViewHolderBrowserGrid viewHolder, MegaApiAndroid megaApi, MegaNodeAdapter adapter){ + public static Bitmap getThumbnailFromMegaGrid(MegaNode document, Context context, RecyclerView.ViewHolder viewHolder, MegaApiAndroid megaApi, RecyclerView.Adapter adapter){ // if (pendingThumbnails.contains(document.getHandle()) || !document.hasThumbnail()){ // log("the thumbnail is already downloaded or added to the list"); @@ -1231,10 +1246,10 @@ static class AttachThumbnailTaskGrid extends AsyncTask - + - + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e7b617f235c..f906df92230 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2257,4 +2257,5 @@ [B]No [/B][A]Notifications[/A][B].[/B] + Shared files From 515a05e217bdfe4169bba5ee8057084701e15c0b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 22 Nov 2018 14:44:44 +0100 Subject: [PATCH 120/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 29 ++++++++++--- .../chatAdapters/GroupCallAdapter.java | 43 ++++++++++++++----- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index da4d5f11960..15a39e879e0 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -516,8 +516,8 @@ protected void onNewIntent(Intent intent) { boolean isMe = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ - Long userHandle = callChat.getParticipants().get(i); - if (userHandle.equals(megaChatApi.getMyUserHandle())) { + long userHandle = callChat.getParticipants().get(i); + if (userHandle == megaChatApi.getMyUserHandle()) { isMe = true; break; } @@ -565,7 +565,7 @@ protected void onNewIntent(Intent intent) { }else{ boolean changes = false; for(int i=0; i Date: Thu, 22 Nov 2018 22:07:05 +0100 Subject: [PATCH 121/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 174 +++++------------- .../chatAdapters/GroupCallAdapter.java | 21 +-- 2 files changed, 57 insertions(+), 138 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 15a39e879e0..450a07045a7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -311,12 +311,6 @@ public boolean onOptionsItemSelected(MenuItem item) { public void updateScreenStatusInProgress(){ log("updateScreenStatusInProgress() chatId: "+chatId); -// relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; -// relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; -// flagMyAvatar = true; -// setProfileMyAvatar(); -// flagContactAvatar = false; -// setProfileContactAvatar(); if(chat.isGroup()){ log("updateScreenStatusInProgress() - group chat - chatId: "+chatId); @@ -354,7 +348,9 @@ public void updateScreenStatusInProgress(){ peersOnCall.add(myPeer); changes = true; } + } + } for (int i = 0; i < peersOnCall.size(); i++) { boolean peerContained = false; @@ -391,19 +387,22 @@ public void updateScreenStatusInProgress(){ peersOnCall.add(myPeer); changes = true; } + + } if(changes){ updatePeers(true); } } } + updateLocalVideoStatus(); + updateLocalAudioStatus(); + }else{ log("updateScreenStatusInProgress() - individual chat - chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); - if (callChat == null){ - - }else{ + if (callChat != null){ int callStatus = callChat.getStatus(); if(callStatus == MegaChatCall.CALL_STATUS_RING_IN){ log("updateScreenStatusInProgress() - CALL_STATUS_RING_IN"); @@ -445,18 +444,13 @@ public void updateScreenStatusInProgress(){ myAvatarLayout.setVisibility(View.VISIBLE); } } -// flagMyAvatar = false; -// setProfileMyAvatar(); -// flagContactAvatar = true; -// setProfileContactAvatar(); + updateLocalVideoStatus(); + updateLocalAudioStatus(); + updateRemoteVideoStatus(-1); + updateRemoteAudioStatus(-1); } - updateLocalVideoStatus(); - updateLocalAudioStatus(); - updateRemoteAudioStatus(-1); - updateRemoteVideoStatus(-1); - stopAudioSignals(); startClock(); } @@ -603,7 +597,6 @@ protected void onNewIntent(Intent intent) { } else { InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, null); log("onNewIntent() "+userPeer.getName()+" added in peersOnCall"); - peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); changes = true; } @@ -666,8 +659,6 @@ protected void onNewIntent(Intent intent) { updateSubTitle(); updateScreenStatusInProgress(); -// updateLocalAudioStatus(); -// updateLocalVideoStatus(); log("Start call Service"); Intent intentService = new Intent(this, CallService.class); @@ -1556,8 +1547,8 @@ else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ log("Ok answer with NO video - "); // updateLocalVideoStatus(); } - updateLocalVideoStatus(); + updateLocalAudioStatus(); } else{ log("Error call: "+e.getErrorString()); @@ -1654,8 +1645,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { peersOnCall.add(myPeer); updatePeers(true); } - updateLocalVideoStatus(); - updateLocalAudioStatus(); + + }else{ log("CALL_STATUS_IN_PROGRESS - Individual call"); @@ -1674,8 +1665,13 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { parentLocalFS.setVisibility(View.GONE); fragmentContainerLocalCameraFS.setVisibility(View.GONE); } + updateLocalVideoStatus(); + updateLocalAudioStatus(); + updateRemoteVideoStatus(-1); + updateRemoteAudioStatus(-1); + } videoFAB.setOnClickListener(null); @@ -1784,106 +1780,17 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("SESSION_STATUS_IN_PROGRESS"); updateSubTitle(); - //contact joined the group call log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); -// if((peersOnCall != null)&&(peersOnCall.size() != 0)){ -// -// boolean peerContain = false; -// for(InfoPeerGroupCall peer : peersOnCall) { -// if (peer.getHandle().equals(userHandle)) { -// peerContain = true; -// break; -// } -// } -// if(!peerContain){ -// InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), userSession.hasVideo(), userSession.hasAudio(), false,null); -// peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); -// -//// peersOnCall.add(0, userPeer); -// -// if(peersOnCall.size()<7){ -// if(adapterGrid != null){ -// if(peersOnCall.size()< 4){ -// recyclerView.setColumnWidth((int) widthScreenPX); -// recyclerViewLayout.setPadding(0,0,0,0); -// -// }else{ -// recyclerView.setColumnWidth((int) widthScreenPX/2); -// if(peersOnCall.size() == 4){ -// recyclerViewLayout.setPadding(0,Util.scaleWidthPx(136, outMetrics),0,0); -// }else{ -// recyclerViewLayout.setPadding(0,0,0,0); -// } -// } -// adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); -// -// updateSubtitleToolbar(); -// }else{ -// updatePeers(true); -// } -// }else{ -// if(adapterList != null){ -// adapterList.notifyItemInserted((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1))); -// adapterList.notifyItemRangeChanged(0, peersOnCall.size()); -// updateSubtitleToolbar(); -// }else{ -// updatePeers(true); -// } -// } -// } -// } }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ log("SESSION_STATUS_DESTROYED "); updateSubTitle(); - //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); -// if((peersOnCall != null)&&(peersOnCall.size() != 0)){ -// -// for(int i=0;i Date: Fri, 23 Nov 2018 09:26:11 +0100 Subject: [PATCH 122/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 13 ++-- .../chatAdapters/GroupCallAdapter.java | 71 ++++++++++++++++--- 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 450a07045a7..dc7abd7035f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1914,8 +1914,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> "+peersOnCall.size()+")"); recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); - adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyDataSetChanged(); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); updateSubtitleToolbar(); }else { @@ -1924,7 +1926,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); recyclerView.setColumnWidth((int) widthScreenPX / 2); adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); } else { recyclerViewLayout.setPadding(0, 0, 0, 0); @@ -1984,7 +1986,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); } else { if(peersOnCall.size() == 6){ @@ -1992,7 +1994,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX/2); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); }else{ if(peersOnCall.size() == 4){ @@ -2654,6 +2656,7 @@ public void updateRemoteVideoStatus(long userHandle){ log("userHandle: "+userHandle+" VS i: "+peersOnCall.get(i).getHandle()+" ("+peersOnCall.get(i).getName()+")"); if(peersOnCall.get(i).getHandle() == userHandle){ if(!peersOnCall.get(i).isVideoOn()){ + log("B "+peersOnCall.get(i).getName()); peersOnCall.get(i).setVideoOn(true); updateSubtitleToolbar(); log("updateRemoteVideo "+peersOnCall.get(i).getName()+" Connected video"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 27a354d0d60..6d6adf0c222 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -159,8 +159,6 @@ public ViewHolderGroupCallGrid(View v) { holderGrid.surfaceMicroLayout = (RelativeLayout) v.findViewById(R.id.rl_surface_and_micro); holderGrid.parentSurfaceView = (RelativeLayout) v.findViewById(R.id.parent_surface_view); - holderGrid.parentSurfaceView.removeAllViews(); - holderGrid.parentSurfaceView.removeAllViewsInLayout(); holderGrid.avatarMicroLayout = (RelativeLayout) v.findViewById(R.id.layout_avatar_micro); holderGrid.avatarLayout = (RelativeLayout) v.findViewById(R.id.avatar_rl); @@ -192,8 +190,15 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in return; } + //Avatar: + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + setProfileMyAvatar(holder); + }else{ + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); + } + int numPeersOnCall = getItemCount(); - log("onBindViewHolderGrid() - peer: "+peer.getHandle()+", numPeersOnCall: "+numPeersOnCall); + log("onBindViewHolderGrid() - peer: "+peer.getName()+", numPeersOnCall: "+numPeersOnCall); if(isGrid){ CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); @@ -337,7 +342,7 @@ public void onClick(View v) { //Listener && SurfaceView if(peer.getListener() == null){ - log("peer: "+peer.getName()+", VIDEO ON- listener == null"); + log("peer: "+peer.getName()+", VIDEO ON- listener == null ---> removeAllViews && removeAllViewsInLayout && addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.removeAllViews(); holder.parentSurfaceView.removeAllViewsInLayout(); @@ -358,6 +363,7 @@ public void onClick(View v) { }else{ peer.getListener().getLocalRenderer().addListener(this); } + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); @@ -369,13 +375,14 @@ public void onClick(View v) { } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- listener != null"); + log("peer: "+peer.getName()+", VIDEO ON- listener != null"); if(holder.parentSurfaceView.getChildCount() == 0){ log("peer: "+peer.getName()+", VIDEO ON- getChildCount() == 0"); if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + log("peer: "+peer.getName()+", VIDEO ON- getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0)"); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); @@ -388,16 +395,37 @@ public void onClick(View v) { if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } + + }else{ + log("peer: "+peer.getName()+", VIDEO ON- getParent 1 ---> addView && setSizeFromLayout && h(0)w(0)"); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + } + }else{ + log("peer: "+peer.getName()+", VIDEO ON- getParent 0 ---> nothing"); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0"); + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0"); if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ - log("*peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it's the same"); + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it's the same -> setSizeFromLayout && h(0)w(0)"); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ @@ -407,13 +435,17 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same"); + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same ---->removeAllViews && removeAllViewsInLayout"); //Remove items of parent holder.parentSurfaceView.removeAllViews(); + holder.parentSurfaceView.removeAllViewsInLayout(); + //Remove parent of Surface if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0"); + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); @@ -425,6 +457,29 @@ public void onClick(View v) { if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } + }else{ + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1"); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } + + } + }else{ + log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0"); + holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); } } } From b9cae5c1fe831ec6342100275c4110a21ae65046 Mon Sep 17 00:00:00 2001 From: Javier Gomez Date: Fri, 23 Nov 2018 11:53:15 +0100 Subject: [PATCH 123/247] Add new overquota storage management support in all upload services --- .../android/app/CameraSyncService.java | 35 +- .../privacy/android/app/UploadService.java | 223 +++++----- .../app/jobservices/CameraUploadsService.java | 72 +++- .../app/lollipop/ManagerActivityLollipop.java | 1 - .../SettingsFragmentLollipop.java | 10 +- .../megachat/ChatActivityLollipop.java | 1 - .../lollipop/megachat/ChatUploadService.java | 394 ++++++++++-------- app/src/main/res/values/strings.xml | 1 + 8 files changed, 418 insertions(+), 319 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java index 88a77625371..e5953a9eb4a 100644 --- a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java +++ b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java @@ -700,6 +700,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { if (megaApi != null){ megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); dbH.setCamSyncEnabled(false); + dbH.setSecondaryUploadEnabled(false); return START_NOT_STICKY; } else{ @@ -714,6 +715,7 @@ else if (intent.getAction().equals(ACTION_STOP)){ if (megaApi != null){ megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); dbH.setCamSyncEnabled(false); + dbH.setSecondaryUploadEnabled(false); return START_NOT_STICKY; } else{ @@ -2218,7 +2220,7 @@ else if (request.getType() == MegaRequest.TYPE_RENAME || request.getType() == Me } } else{ - log("Error: "+request.getType()+" : "+request.getRequestString()); + log("Error ("+e.getErrorCode()+"): "+request.getType()+" : "+request.getRequestString()); if(request.getNodeHandle()!=-1){ MegaNode nodeError = megaApi.getNodeByHandle(request.getNodeHandle()); if(nodeError!=null){ @@ -2226,7 +2228,10 @@ else if (request.getType() == MegaRequest.TYPE_RENAME || request.getType() == Me } } - megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); + if (e.getErrorCode() == MegaError.API_EOVERQUOTA) + isOverquota = true; + + finish(); } } else if (request.getType() == MegaRequest.TYPE_CANCEL_TRANSFERS){ @@ -2320,12 +2325,13 @@ public void onTransferFinish(MegaApiJava api, MegaTransfer transfer, CameraSyncService.this.cancel(); } else{ + if (e.getErrorCode() == MegaError.API_OK) { - if(isOverquota){ - return; - } + if(isOverquota){ + log("After overquota error"); + isOverquota = false; + } - if (e.getErrorCode() == MegaError.API_OK) { log("Image Sync OK: " + transfer.getFileName()); totalSizeUploaded += transfer.getTransferredBytes(); log("IMAGESYNCFILE: " + transfer.getPath()); @@ -2481,7 +2487,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { } if(isOverquota){ - return; + log("After overquota error"); + isOverquota = false; } final long bytes = transfer.getTransferredBytes(); @@ -2501,7 +2508,7 @@ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, Meg isOverquota = true; - CameraSyncService.this.cancel(); + updateProgressNotification(totalSizeToUpload); } } @@ -2533,10 +2540,14 @@ private void updateProgressNotification(final long progress) { } } + String status = isOverquota ? getString(R.string.overquota_alert_title) : + getString(R.string.settings_camera_notif_title); + Intent intent = null; intent = new Intent(CameraSyncService.this, ManagerActivityLollipop.class); - intent.setAction(Constants.ACTION_CANCEL_CAM_SYNC); + intent.setAction(isOverquota ? Constants.ACTION_OVERQUOTA_STORAGE : + Constants.ACTION_CANCEL_CAM_SYNC); String info = Util.getProgressSize(CameraSyncService.this, progress, totalSizeToUpload); @@ -2558,7 +2569,7 @@ private void updateProgressNotification(final long progress) { .setOngoing(true) .setContentTitle(message) .setSubText(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilderCompat.build(); @@ -2571,7 +2582,7 @@ else if (currentapiVersion >= android.os.Build.VERSION_CODES.N) { .setOngoing(true) .setContentTitle(message) .setSubText(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilder.getNotification(); } @@ -2584,7 +2595,7 @@ else if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) .setOngoing(true) .setContentTitle(message) .setContentInfo(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilder.getNotification(); // notification = mBuilder.build(); diff --git a/app/src/main/java/mega/privacy/android/app/UploadService.java b/app/src/main/java/mega/privacy/android/app/UploadService.java index 50a000c328b..4ed00078f6a 100644 --- a/app/src/main/java/mega/privacy/android/app/UploadService.java +++ b/app/src/main/java/mega/privacy/android/app/UploadService.java @@ -505,123 +505,138 @@ else if(errorCount>0){ @SuppressLint("NewApi") private void updateProgressNotification() { - if(isOverquota==0){ - long progressPercent = 0; + long progressPercent = 0; - Collection transfers= mapProgressTransfers.values(); + Collection transfers= mapProgressTransfers.values(); - long total = 0; - long inProgress = 0; + long total = 0; + long inProgress = 0; - for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { - MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); - if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ - total = total + currentTransfer.getTotalBytes(); - inProgress = inProgress + currentTransfer.getTotalBytes(); - } - else{ - total = total + currentTransfer.getTotalBytes(); - inProgress = inProgress + currentTransfer.getTransferredBytes(); - } - } - - long inProgressTemp = 0; - if(total>0){ - inProgressTemp = inProgress *100; - progressPercent = inProgressTemp/total; - } - - String message = ""; - if (inProgress == 0){ - message = getString(R.string.download_preparing_files); + for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { + MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); + if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ + total = total + currentTransfer.getTotalBytes(); + inProgress = inProgress + currentTransfer.getTotalBytes(); } else{ - int filesProgress = totalUploadsCompleted+1; - message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, filesProgress, totalUploads); + total = total + currentTransfer.getTotalBytes(); + inProgress = inProgress + currentTransfer.getTransferredBytes(); } + } - log("****updateProgressNotification: "+ progressPercent+" "+message); + long inProgressTemp = 0; + if(total>0){ + inProgressTemp = inProgress *100; + progressPercent = inProgressTemp/total; + } - String info = Util.getProgressSize(UploadService.this, inProgress, total); + String message = ""; + if (isOverquota != 0){ + message = getString(R.string.overquota_alert_title); + } + else if (inProgress == 0){ + message = getString(R.string.download_preparing_files); + } + else{ + int filesProgress = totalUploadsCompleted+1; + message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, filesProgress, totalUploads); + } - Intent intent; - intent = new Intent(UploadService.this, ManagerActivityLollipop.class); - intent.setAction(Constants.ACTION_SHOW_TRANSFERS); + String actionString = isOverquota == 0 ? getString(R.string.download_touch_to_show) : + getString(R.string.general_show_info); + + log("****updateProgressNotification: "+ progressPercent+" "+message); + + String info = Util.getProgressSize(UploadService.this, inProgress, total); + + Intent intent; + intent = new Intent(UploadService.this, ManagerActivityLollipop.class); + switch (isOverquota) { + case 0: + default: + intent.setAction(Constants.ACTION_SHOW_TRANSFERS); + break; + case 1: + intent.setAction(Constants.ACTION_OVERQUOTA_STORAGE); + break; + case 2: + intent.setAction(Constants.ACTION_PRE_OVERQUOTA_STORAGE); + break; + } - PendingIntent pendingIntent = PendingIntent.getActivity(UploadService.this, 0, intent, 0); - Notification notification = null; + PendingIntent pendingIntent = PendingIntent.getActivity(UploadService.this, 0, intent, 0); + Notification notification = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); - channel.setShowBadge(true); - channel.setSound(null, null); - mNotificationManager.createNotificationChannel(channel); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); + channel.setShowBadge(true); + channel.setSound(null, null); + mNotificationManager.createNotificationChannel(channel); - NotificationCompat.Builder mBuilderCompat = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); + NotificationCompat.Builder mBuilderCompat = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); - mBuilderCompat - .setSmallIcon(R.drawable.ic_stat_notify) - .setColor(ContextCompat.getColor(this, R.color.mega)) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message).setSubText(info) - .setContentText(getString(R.string.download_touch_to_show)) - .setOnlyAlertOnce(true); - - notification = mBuilderCompat.build(); - } - else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - mBuilder - .setSmallIcon(R.drawable.ic_stat_notify) - .setColor(ContextCompat.getColor(this, R.color.mega)) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message).setSubText(info) - .setContentText(getString(R.string.download_touch_to_show)) - .setOnlyAlertOnce(true); - notification = mBuilder.build(); + mBuilderCompat + .setSmallIcon(R.drawable.ic_stat_notify) + .setColor(ContextCompat.getColor(this, R.color.mega)) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message).setSubText(info) + .setContentText(actionString) + .setOnlyAlertOnce(true); + + notification = mBuilderCompat.build(); + } + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + mBuilder + .setSmallIcon(R.drawable.ic_stat_notify) + .setColor(ContextCompat.getColor(this, R.color.mega)) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message).setSubText(info) + .setContentText(actionString) + .setOnlyAlertOnce(true); + notification = mBuilder.build(); + } + else if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + + mBuilder + .setSmallIcon(R.drawable.ic_stat_notify) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message).setContentInfo(info) + .setContentText(actionString) + .setOnlyAlertOnce(true); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); } - else if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - mBuilder - .setSmallIcon(R.drawable.ic_stat_notify) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message).setContentInfo(info) - .setContentText(getString(R.string.download_touch_to_show)) - .setOnlyAlertOnce(true); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); - } + notification = mBuilder.getNotification(); + } + else + { + notification = new Notification(R.drawable.ic_stat_notify, null, 1); + notification.flags |= Notification.FLAG_ONGOING_EVENT; + notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_progress); + notification.contentIntent = pendingIntent; + notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ic_stat_notify); + notification.contentView.setTextViewText(R.id.status_text, message); + notification.contentView.setTextViewText(R.id.progress_text, info); + notification.contentView.setProgressBar(R.id.status_progress, 100, (int)progressPercent, false); + } - notification = mBuilder.getNotification(); + if (!isForeground) { + log("starting foreground"); + try { + startForeground(notificationId, notification); + isForeground = true; } - else - { - notification = new Notification(R.drawable.ic_stat_notify, null, 1); - notification.flags |= Notification.FLAG_ONGOING_EVENT; - notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_progress); - notification.contentIntent = pendingIntent; - notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ic_stat_notify); - notification.contentView.setTextViewText(R.id.status_text, message); - notification.contentView.setTextViewText(R.id.progress_text, info); - notification.contentView.setProgressBar(R.id.status_progress, 100, (int)progressPercent, false); - } - - if (!isForeground) { - log("starting foreground"); - try { - startForeground(notificationId, notification); - isForeground = true; - } - catch (Exception e){ - log("startforeground exception: " + e.getMessage()); - isForeground = false; - } - } else { - mNotificationManager.notify(notificationId, notification); + catch (Exception e){ + log("startforeground exception: " + e.getMessage()); + isForeground = false; } + } else { + mNotificationManager.notify(notificationId, notification); } } @@ -866,10 +881,6 @@ public void onTransferFinish(MegaApiJava api, MegaTransfer transfer, MegaError e } } - if (isOverquota!=0) { - megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); - } - log("IN Finish: " + transfer.getFileName() + "path? " + transfer.getPath()); String pathSelfie = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Util.temporalPicDIR; if (transfer.getPath() != null) { @@ -917,8 +928,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { } if(isOverquota!=0){ - log("after overquota alert"); - return; + log("After overquota error"); + isOverquota = 0; } mapProgressTransfers.put(transfer.getTag(), transfer); @@ -949,7 +960,7 @@ else if (e.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) { } else { log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); - showStorageOverquotaNotification(); + updateProgressNotification(); } break; } diff --git a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java index f79ee20028d..fe2cd0029cb 100644 --- a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java +++ b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java @@ -22,7 +22,6 @@ import android.support.v4.app.NotificationCompat; import android.support.v4.provider.DocumentFile; import android.text.format.Time; -import android.util.Log; import android.widget.RemoteViews; import java.io.File; @@ -1493,8 +1492,7 @@ private void cancel() { try{ wl.release(); } catch(Exception ex) {} if(isOverquota){ - //TODO Uncomment this -// showStorageOverquotaNotification(); + showStorageOverquotaNotification(); } canceled = true; @@ -1507,6 +1505,34 @@ private void cancel() { jobFinished(globalParams, true); } + private void showStorageOverquotaNotification(){ + log("showStorageOverquotaNotification"); + + String contentText = getString(R.string.download_show_info); + String message = getString(R.string.overquota_alert_title); + + Intent intent = new Intent(this, ManagerActivityLollipop.class); + intent.setAction(Constants.ACTION_OVERQUOTA_STORAGE); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); + channel.setShowBadge(true); + channel.setSound(null, null); + mNotificationManager.createNotificationChannel(channel); + + NotificationCompat.Builder mBuilderCompatO = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); + + mBuilderCompatO + .setSmallIcon(R.drawable.ic_stat_camera_sync) + .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, intent, 0)) + .setAutoCancel(true).setTicker(contentText) + .setContentTitle(message).setContentText(contentText) + .setOngoing(false); + + mNotificationManager.notify(Constants.NOTIFICATION_STORAGE_OVERQUOTA, mBuilderCompatO.build()); + } + } + @Override public boolean onStopJob(JobParameters params) { @@ -1701,6 +1727,20 @@ else if (request.getType() == MegaRequest.TYPE_RENAME || request.getType() == Me } } } + else { + log("Error ("+e.getErrorCode()+"): "+request.getType()+" : "+request.getRequestString()); + if(request.getNodeHandle()!=-1){ + MegaNode nodeError = megaApi.getNodeByHandle(request.getNodeHandle()); + if(nodeError!=null){ + log("Node: "+nodeError.getName()); + } + } + + if (e.getErrorCode() == MegaError.API_EOVERQUOTA) + isOverquota = true; + + finish(); + } } } @@ -1730,7 +1770,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { } if(isOverquota){ - return; + log("After overquota error"); + isOverquota = false; } final long bytes = transfer.getTransferredBytes(); @@ -1750,7 +1791,7 @@ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, Meg isOverquota = true; - cancel(); + updateProgressNotification(totalSizeUploaded); } } @@ -1779,12 +1820,13 @@ public void onTransferFinish(MegaApiJava api, MegaTransfer transfer, MegaError e cancel(); } else{ + if (e.getErrorCode() == MegaError.API_OK) { - if(isOverquota){ - return; - } + if(isOverquota){ + log("After overquota error"); + isOverquota = false; + } - if (e.getErrorCode() == MegaError.API_OK) { log("Image Sync OK: " + transfer.getFileName()); totalSizeUploaded += transfer.getTransferredBytes(); log("IMAGESYNCFILE: " + transfer.getPath()); @@ -1952,10 +1994,14 @@ private void updateProgressNotification(final long progress) { } } + String status = isOverquota ? getString(R.string.overquota_alert_title) : + getString(R.string.settings_camera_notif_title); + Intent intent = null; intent = new Intent(this, ManagerActivityLollipop.class); - intent.setAction(Constants.ACTION_CANCEL_CAM_SYNC); + intent.setAction(isOverquota ? Constants.ACTION_OVERQUOTA_STORAGE : + Constants.ACTION_CANCEL_CAM_SYNC); String info = Util.getProgressSize(this, progress, totalSizeToUpload); @@ -1977,7 +2023,7 @@ private void updateProgressNotification(final long progress) { .setOngoing(true) .setContentTitle(message) .setSubText(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilderCompat.build(); @@ -1990,7 +2036,7 @@ else if (currentapiVersion >= android.os.Build.VERSION_CODES.N) { .setOngoing(true) .setContentTitle(message) .setSubText(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilder.getNotification(); } @@ -2003,7 +2049,7 @@ else if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) .setOngoing(true) .setContentTitle(message) .setContentInfo(info) - .setContentText(getString(R.string.settings_camera_notif_title)) + .setContentText(status) .setOnlyAlertOnce(true); notification = mBuilder.getNotification(); // notification = mBuilder.build(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index 80a7cb9f6d1..1735bc2823e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -12847,7 +12847,6 @@ private void showOverquotaAlert(boolean prewarning){ } else{ builder.setMessage(getString(R.string.overquota_alert_text)); - dbH.setCamSyncEnabled(false); } if(overquotaDialog==null){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/SettingsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/SettingsFragmentLollipop.java index c984c3e1315..a543f15c32d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/SettingsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/SettingsFragmentLollipop.java @@ -68,6 +68,7 @@ import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaChatPresenceConfig; import nz.mega.sdk.MegaNode; +import nz.mega.sdk.MegaTransfer; //import android.support.v4.preference.PreferenceFragment; @@ -2460,8 +2461,6 @@ public void run() { } else{ log("Camera OFF"); - dbH.setCamSyncEnabled(false); - dbH.setSecondaryUploadEnabled(false); secondaryUpload = false; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { Intent stopIntent = null; @@ -2469,6 +2468,13 @@ public void run() { stopIntent.setAction(CameraSyncService.ACTION_STOP); context.startService(stopIntent); } + else { + dbH.setCamSyncEnabled(false); + dbH.setSecondaryUploadEnabled(false); + if (megaApi != null) { + megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD); + } + } cameraUploadOn.setTitle(getString(R.string.settings_camera_upload_on)); secondaryMediaFolderOn.setTitle(getString(R.string.settings_secondary_upload_on)); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 2888ae4618b..daaf1211846 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -7028,7 +7028,6 @@ private void showOverquotaAlert(boolean prewarning){ } else{ builder.setMessage(getString(R.string.overquota_alert_text)); - dbH.setCamSyncEnabled(false); } if(overquotaDialog==null){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java index f94c55e908e..af53373a170 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java @@ -467,188 +467,199 @@ public void finishDownsampling(String returnedFile, boolean success){ @SuppressLint("NewApi") private void updateProgressNotification() { - if(isOverquota==0){ - - long progressPercent = 0; - Collection transfers= mapProgressTransfers.values(); - if(sendOriginalAttachments){ - - - long total = 0; - long inProgress = 0; - - for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { - MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); - if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ - total = total + currentTransfer.getTotalBytes(); - inProgress = inProgress + currentTransfer.getTotalBytes(); - } - else{ - total = total + currentTransfer.getTotalBytes(); - inProgress = inProgress + currentTransfer.getTransferredBytes(); - } - } - - long inProgressTemp = 0; - if(total>0){ - inProgressTemp = inProgress *100; - progressPercent = inProgressTemp/total; - } - } - else{ + long progressPercent = 0; + Collection transfers= mapProgressTransfers.values(); + + if(sendOriginalAttachments){ + + long total = 0; + long inProgress = 0; + + for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { + MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); + if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ + total = total + currentTransfer.getTotalBytes(); + inProgress = inProgress + currentTransfer.getTotalBytes(); + } + else{ + total = total + currentTransfer.getTotalBytes(); + inProgress = inProgress + currentTransfer.getTransferredBytes(); + } + } + + long inProgressTemp = 0; + if(total>0){ + inProgressTemp = inProgress *100; + progressPercent = inProgressTemp/total; + } + } + else{ + if(totalVideos>0){ + + for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { + MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); + + long individualInProgress = currentTransfer.getTransferredBytes(); + long individualTotalBytes = currentTransfer.getTotalBytes(); + long individualProgressPercent = 0; + + if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ + if(MimeTypeList.typeForName(currentTransfer.getFileName()).isMp4Video()){ + individualProgressPercent = 50; + } + else{ + individualProgressPercent = 100; + } + } + else{ + if(MimeTypeList.typeForName(currentTransfer.getFileName()).isMp4Video()){ + individualProgressPercent = individualInProgress*50 / individualTotalBytes; + } + else{ + individualProgressPercent = individualInProgress*100 / individualTotalBytes; + } + } + + progressPercent = progressPercent + individualProgressPercent/totalUploads; + } + + Collection values= mapVideoDownsampling.values(); + int simplePercentage = 50/totalUploads; + for (Iterator iterator2 = values.iterator(); iterator2.hasNext();) { + Integer value = (Integer) iterator2.next(); + int downsamplingPercent = simplePercentage*value/100; + progressPercent = progressPercent + downsamplingPercent; + } + } + else{ + long total = 0; + long inProgress = 0; + + for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { + MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); + total = total + currentTransfer.getTotalBytes(); + inProgress = inProgress + currentTransfer.getTransferredBytes(); + } + inProgress = inProgress *100; + if(total<=0){ + progressPercent = 0; + } + else{ + progressPercent = inProgress/total; + } + } + } - if(totalVideos>0){ + log("updateProgressNotification: progress: "+progressPercent); - for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { - MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); + String message = ""; + if (isOverquota != 0){ + message = getString(R.string.overquota_alert_title); + } + else if(totalUploadsCompleted==totalUploads){ + message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, totalUploadsCompleted, totalUploads); + } + else{ + int inProgress = totalUploadsCompleted+1; + message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, inProgress, totalUploads); + } - long individualInProgress = currentTransfer.getTransferredBytes(); - long individualTotalBytes = currentTransfer.getTotalBytes(); - long individualProgressPercent = 0; + Intent intent; + intent = new Intent(ChatUploadService.this, ManagerActivityLollipop.class); + switch (isOverquota) { + case 0: + default: + intent.setAction(Constants.ACTION_SHOW_TRANSFERS); + break; + case 1: + intent.setAction(Constants.ACTION_OVERQUOTA_STORAGE); + break; + case 2: + intent.setAction(Constants.ACTION_PRE_OVERQUOTA_STORAGE); + break; + } - if(currentTransfer.getState()==MegaTransfer.STATE_COMPLETED){ - if(MimeTypeList.typeForName(currentTransfer.getFileName()).isMp4Video()){ - individualProgressPercent = 50; - } - else{ - individualProgressPercent = 100; - } - } - else{ - if(MimeTypeList.typeForName(currentTransfer.getFileName()).isMp4Video()){ - individualProgressPercent = individualInProgress*50 / individualTotalBytes; - } - else{ + String actionString = isOverquota == 0 ? getString(R.string.chat_upload_title_notification) : + getString(R.string.general_show_info); - individualProgressPercent = individualInProgress*100 / individualTotalBytes; - } - } + PendingIntent pendingIntent = PendingIntent.getActivity(ChatUploadService.this, 0, intent, 0); + Notification notification = null; + int currentapiVersion = Build.VERSION.SDK_INT; - progressPercent = progressPercent + individualProgressPercent/totalUploads; - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); + channel.setShowBadge(true); + channel.setSound(null, null); + mNotificationManager.createNotificationChannel(channel); - Collection values= mapVideoDownsampling.values(); - int simplePercentage = 50/totalUploads; - for (Iterator iterator2 = values.iterator(); iterator2.hasNext();) { - Integer value = (Integer) iterator2.next(); - int downsamplingPercent = simplePercentage*value/100; - progressPercent = progressPercent + downsamplingPercent; - } - } - else{ + NotificationCompat.Builder mBuilderCompat = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); - long total = 0; - long inProgress = 0; + mBuilderCompat + .setSmallIcon(R.drawable.ic_stat_notify) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message) + .setContentText(actionString) + .setOnlyAlertOnce(true) + .setColor(ContextCompat.getColor(this,R.color.mega)); - for (Iterator iterator = transfers.iterator(); iterator.hasNext();) { - MegaTransfer currentTransfer = (MegaTransfer) iterator.next(); - total = total + currentTransfer.getTotalBytes(); - inProgress = inProgress + currentTransfer.getTransferredBytes(); - } - inProgress = inProgress *100; - if(total<=0){ - progressPercent = 0; - } - else{ - progressPercent = inProgress/total; - } - } - } - - log("updateProgressNotification: progress: "+progressPercent); - - String message = ""; - if(totalUploadsCompleted==totalUploads){ - message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, totalUploadsCompleted, totalUploads); - } - else{ - int inProgress = totalUploadsCompleted+1; - message = getResources().getQuantityString(R.plurals.upload_service_notification, totalUploads, inProgress, totalUploads); - } + notification = mBuilderCompat.build(); + } + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + mBuilder + .setSmallIcon(R.drawable.ic_stat_notify) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message) + .setContentText(actionString) + .setOnlyAlertOnce(true); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); + } + + notification = mBuilder.build(); + } + else if (currentapiVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - Intent intent; - intent = new Intent(ChatUploadService.this, ManagerActivityLollipop.class); - intent.setAction(Constants.ACTION_SHOW_TRANSFERS); - - PendingIntent pendingIntent = PendingIntent.getActivity(ChatUploadService.this, 0, intent, 0); - Notification notification = null; - int currentapiVersion = Build.VERSION.SDK_INT; - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); - channel.setShowBadge(true); - channel.setSound(null, null); - mNotificationManager.createNotificationChannel(channel); - - NotificationCompat.Builder mBuilderCompat = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); - - mBuilderCompat - .setSmallIcon(R.drawable.ic_stat_notify) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message) - .setContentText(getString(R.string.chat_upload_title_notification)) - .setOnlyAlertOnce(true) - .setColor(ContextCompat.getColor(this,R.color.mega)); - - notification = mBuilderCompat.build(); - } - else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - mBuilder - .setSmallIcon(R.drawable.ic_stat_notify) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message) - .setContentText(getString(R.string.chat_upload_title_notification)) - .setOnlyAlertOnce(true); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); - } + mBuilder + .setSmallIcon(R.drawable.ic_stat_notify) + .setProgress(100, (int)progressPercent, false) + .setContentIntent(pendingIntent) + .setOngoing(true).setContentTitle(message) + .setContentText(getString(R.string.chat_upload_title_notification)) + .setOnlyAlertOnce(true); - notification = mBuilder.build(); - } - else if (currentapiVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - - mBuilder - .setSmallIcon(R.drawable.ic_stat_notify) - .setProgress(100, (int)progressPercent, false) - .setContentIntent(pendingIntent) - .setOngoing(true).setContentTitle(message) - .setContentText(getString(R.string.chat_upload_title_notification)) - .setOnlyAlertOnce(true); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + mBuilder.setColor(ContextCompat.getColor(this,R.color.mega)); + } - notification = mBuilder.getNotification(); + notification = mBuilder.getNotification(); - } - else - { - notification.flags |= Notification.FLAG_ONGOING_EVENT; - notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_progress); - notification.contentIntent = pendingIntent; - notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ic_stat_notify); - notification.contentView.setTextViewText(R.id.status_text, message); - notification.contentView.setProgressBar(R.id.status_progress, 100, (int)progressPercent, false); - } + } + else + { + notification.flags |= Notification.FLAG_ONGOING_EVENT; + notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_progress); + notification.contentIntent = pendingIntent; + notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ic_stat_notify); + notification.contentView.setTextViewText(R.id.status_text, message); + notification.contentView.setProgressBar(R.id.status_progress, 100, (int)progressPercent, false); + } - if (!isForeground) { - log("starting foreground"); - try { - startForeground(notificationId, notification); - isForeground = true; - } - catch (Exception e){ - log("startforeground exception: " + e.getMessage()); - isForeground = false; - } - } else { - mNotificationManager.notify(notificationId, notification); - } - } + if (!isForeground) { + log("starting foreground"); + try { + startForeground(notificationId, notification); + isForeground = true; + } + catch (Exception e){ + log("startforeground exception: " + e.getMessage()); + isForeground = false; + } + } else { + mNotificationManager.notify(notificationId, notification); + } } public static void log(String log) { @@ -961,10 +972,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isPdf()) { } } - if (isOverquota!=0) { - megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this); - } - log("IN Finish: "+transfer.getFileName()+" path: "+transfer.getPath()); String pathSelfie = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Util.temporalPicDIR; if (transfer.getPath() != null) { @@ -1125,8 +1132,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) { } if(isOverquota!=0){ - log("after overquota alert"); - return; + log("After overquota error"); + isOverquota = 0; } mapProgressTransfers.put(transfer.getTag(), transfer); @@ -1158,7 +1165,7 @@ else if (e.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) { } else { log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode()); - showStorageOverquotaNotification(); + updateProgressNotification(); } break; } @@ -1327,17 +1334,36 @@ private void showStorageOverquotaNotification(){ intent.setAction(Constants.ACTION_PRE_OVERQUOTA_STORAGE); } - mBuilderCompat - .setSmallIcon(R.drawable.ic_stat_notify) - .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, intent, 0)) - .setAutoCancel(true).setTicker(contentText) - .setContentTitle(message).setContentText(contentText) - .setOngoing(false); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(notificationChannelId, notificationChannelName, NotificationManager.IMPORTANCE_DEFAULT); + channel.setShowBadge(true); + channel.setSound(null, null); + mNotificationManager.createNotificationChannel(channel); + + NotificationCompat.Builder mBuilderCompatO = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - mBuilderCompat.setColor(ContextCompat.getColor(this,R.color.mega)); + mBuilderCompatO + .setSmallIcon(R.drawable.ic_stat_notify) + .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, intent, 0)) + .setAutoCancel(true).setTicker(contentText) + .setContentTitle(message).setContentText(contentText) + .setOngoing(false); + + mNotificationManager.notify(Constants.NOTIFICATION_STORAGE_OVERQUOTA, mBuilderCompatO.build()); } + else { + mBuilderCompat + .setSmallIcon(R.drawable.ic_stat_notify) + .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, intent, 0)) + .setAutoCancel(true).setTicker(contentText) + .setContentTitle(message).setContentText(contentText) + .setOngoing(false); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ + mBuilderCompat.setColor(ContextCompat.getColor(this,R.color.mega)); + } - mNotificationManager.notify(Constants.NOTIFICATION_STORAGE_OVERQUOTA, mBuilderCompat.build()); + mNotificationManager.notify(Constants.NOTIFICATION_STORAGE_OVERQUOTA, mBuilderCompat.build()); + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba807082efd..7718d8d14a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -68,6 +68,7 @@ + Show info Error. Please, try again. From 86762b4d385997e96ebe95623c83dd2a119fc709 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sat, 24 Nov 2018 16:29:05 +0100 Subject: [PATCH 124/247] Group Calls UI --- .../megachat/calls/ChatCallActivity.java | 293 +++++++++++++----- .../chatAdapters/GroupCallAdapter.java | 65 ++-- .../main/res/layout/activity_calls_chat.xml | 82 ++--- .../res/layout/item_camera_group_call.xml | 2 +- 4 files changed, 288 insertions(+), 154 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index dc7abd7035f..fc80896c651 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -164,6 +164,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque RelativeLayout recyclerViewLayout; CustomizedGridCallRecyclerView recyclerView; + RelativeLayout bigRecyclerViewLayout; LinearLayoutManager layoutManager; RecyclerView bigRecyclerView; @@ -315,9 +316,7 @@ public void updateScreenStatusInProgress(){ if(chat.isGroup()){ log("updateScreenStatusInProgress() - group chat - chatId: "+chatId); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.requestLayout(); + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); @@ -407,9 +406,14 @@ public void updateScreenStatusInProgress(){ if(callStatus == MegaChatCall.CALL_STATUS_RING_IN){ log("updateScreenStatusInProgress() - CALL_STATUS_RING_IN"); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - relativeVideo.requestLayout(); + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + + myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; @@ -420,9 +424,12 @@ public void updateScreenStatusInProgress(){ }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("updateScreenStatusInProgress() - CALL_STATUS_IN_PROGRESS"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.requestLayout(); + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); @@ -434,9 +441,14 @@ public void updateScreenStatusInProgress(){ }else{ log("updateScreenStatusInProgress() - OUTGOING"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.requestLayout(); + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + + flagMyAvatar = false; setProfileMyAvatar(); flagContactAvatar = true; @@ -508,6 +520,14 @@ protected void onNewIntent(Intent intent) { if(callChat.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ log("onNewIntent() - group chat - CALL_STATUS_RING_IN"); + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + + boolean isMe = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); @@ -574,6 +594,14 @@ protected void onNewIntent(Intent intent) { } }else if(callChat.getStatus() == MegaChatCall.CALL_STATUS_IN_PROGRESS){ log("onNewIntent() CALL_STATUS_IN_PROGRESS -> participants: "+callChat.getParticipants().size()); + + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + updateSubTitle(); if(peersOnCall != null){ if(peersOnCall.size() != 0){ @@ -799,23 +827,33 @@ protected void onCreate(Bundle savedInstanceState) { layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); linearFAB.setLayoutParams(layoutCompress); + linearFAB.requestLayout(); linearFAB.setOrientation(LinearLayout.HORIZONTAL); isManualMode = false; relativeCall = (RelativeLayout) findViewById(R.id.relative_answer_call_fab); + relativeCall.getLayoutParams().width = Util.scaleWidthPx(48, outMetrics) ; + relativeCall.getLayoutParams().height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeCall.requestLayout(); relativeCall.setVisibility(GONE); linearArrowCall = (LinearLayout) findViewById(R.id.linear_arrow_call); + linearArrowCall.setVisibility(GONE); firstArrowCall = (ImageView) findViewById(R.id.first_arrow_call); secondArrowCall = (ImageView) findViewById(R.id.second_arrow_call); thirdArrowCall = (ImageView) findViewById(R.id.third_arrow_call); fourArrowCall = (ImageView) findViewById(R.id.four_arrow_call); relativeVideo = (RelativeLayout) findViewById(R.id.relative_video_fab); + relativeVideo.getLayoutParams().width = Util.scaleWidthPx(48, outMetrics) ; + relativeVideo.getLayoutParams().height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeVideo.requestLayout(); relativeVideo.setVisibility(GONE); + linearArrowVideo = (LinearLayout) findViewById(R.id.linear_arrow_video); + linearArrowVideo.setVisibility(GONE); firstArrowVideo = (ImageView) findViewById(R.id.first_arrow_video); secondArrowVideo = (ImageView) findViewById(R.id.second_arrow_video); thirdArrowVideo = (ImageView) findViewById(R.id.third_arrow_video); @@ -845,6 +883,7 @@ protected void onCreate(Bundle savedInstanceState) { //Recycler View for 1-6 peers recyclerViewLayout = (RelativeLayout) findViewById(R.id.rl_recycler_view); + recyclerViewLayout.setVisibility(GONE); recyclerView = (CustomizedGridCallRecyclerView) findViewById(R.id.recycler_view_cameras); recyclerView.setPadding(0, 0, 0, 0); // recyclerView.setClipToPadding(false); @@ -853,12 +892,6 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setVisibility(GONE); - //Recycler View for 7-8 peers (because 9-10 without video) - layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); - bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); - bigRecyclerView.setLayoutManager(layoutManager); - bigRecyclerView.setVisibility(GONE); - //Big elements group calls parentBigCameraGroupCall = (ViewGroup) findViewById(R.id.parent_layout_big_camera_group_call); ViewGroup.LayoutParams paramsBigCameraGroupCall = (ViewGroup.LayoutParams) parentBigCameraGroupCall.getLayoutParams(); @@ -883,6 +916,20 @@ protected void onCreate(Bundle savedInstanceState) { avatarBigCameraGroupCallLayout.setVisibility(View.GONE); parentBigCameraGroupCall.setVisibility(View.GONE); + //Recycler View for 7-8 peers (because 9-10 without video) + bigRecyclerViewLayout = (RelativeLayout) findViewById(R.id.rl_big_recycler_view); + layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); + bigRecyclerView = (RecyclerView) findViewById(R.id.big_recycler_view_cameras); + bigRecyclerView.setLayoutManager(layoutManager); + RelativeLayout.LayoutParams bigRecyclerViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.parent_layout_big_camera_group_call); + bigRecyclerViewParams.addRule(RelativeLayout.BELOW, 0); + bigRecyclerViewLayout.setLayoutParams(bigRecyclerViewParams); + bigRecyclerViewLayout.requestLayout(); + bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); + //Local camera small parentLocal = (ViewGroup) findViewById(R.id.parent_layout_local_camera); fragmentContainerLocalCamera = (FrameLayout) findViewById(R.id.fragment_container_local_camera); @@ -985,10 +1032,13 @@ protected void onCreate(Bundle savedInstanceState) { bigElementsIndividualCallLayout.setVisibility(View.GONE); bigElementsGroupCallLayout.setVisibility(View.VISIBLE); + }else{ smallElementsIndividualCallLayout.setVisibility(View.VISIBLE); bigElementsIndividualCallLayout.setVisibility(View.VISIBLE); bigElementsGroupCallLayout.setVisibility(View.GONE); + bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); } if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){ @@ -1009,10 +1059,6 @@ protected void onCreate(Bundle savedInstanceState) { if(chat.isGroup()){ log("onCreate()-Incoming group call"); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - relativeVideo.requestLayout(); - //Get all the participants, add them to peersBeforeCall array and show only the avatars if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); @@ -1037,9 +1083,6 @@ protected void onCreate(Bundle savedInstanceState) { }else{ log("onCreate()-Incoming individual call"); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.MATCH_PARENT; - relativeVideo.requestLayout(); myAvatarLayout.setVisibility(View.VISIBLE); contactAvatarLayout.setVisibility(View.VISIBLE); flagMyAvatar = true; @@ -1049,6 +1092,7 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ + log("onCreate()- In Progress"); updateScreenStatusInProgress(); }else if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ @@ -1066,10 +1110,6 @@ protected void onCreate(Bundle savedInstanceState) { log("onCreate()-Outgoing group call"); - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.requestLayout(); - if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } @@ -1085,10 +1125,6 @@ protected void onCreate(Bundle savedInstanceState) { }else{ log("onCreate()-Outgoing individual call"); - relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT; - relativeVideo.requestLayout(); - flagMyAvatar = false; setProfileMyAvatar(); flagContactAvatar = true; @@ -1363,6 +1399,15 @@ protected void hideFABs(){ answerCallFAB.hide(); relativeCall.setVisibility(GONE); } + + if((bigRecyclerViewLayout!=null)&&(bigRecyclerView!=null)&&(parentBigCameraGroupCall!=null)){ + RelativeLayout.LayoutParams bigRecyclerViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); + bigRecyclerViewParams.addRule(RelativeLayout.BELOW, R.id.parent_layout_big_camera_group_call); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_BOTTOM, 0); + bigRecyclerViewLayout.setLayoutParams(bigRecyclerViewParams); + bigRecyclerViewLayout.requestLayout(); + } } @Override @@ -1696,12 +1741,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { stopAudioSignals(); rtcAudioManager.stop(); MegaApplication.activityPaused(); - if (bigCameraGroupCallFragment != null) { - bigCameraGroupCallFragment.removeSurfaceView();; - FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); - ftFS.remove(bigCameraGroupCallFragment); - bigCameraGroupCallFragment = null; - } +// if (bigCameraGroupCallFragment != null) { +// bigCameraGroupCallFragment.removeSurfaceView();; +// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); +// ftFS.remove(bigCameraGroupCallFragment); +// bigCameraGroupCallFragment = null; +// } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); @@ -1726,12 +1771,12 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { // ft.remove(remoteCameraFragmentFS); // remoteCameraFragmentFS = null; // } -// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { -// super.finishAndRemoveTask(); -// } -// else { -// super.finish(); -// } + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + super.finishAndRemoveTask(); + } + else { + super.finish(); + } } @@ -1916,8 +1961,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerView.setColumnWidth((int) widthScreenPX); int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); adapterGrid.notifyItemInserted(posInserted); - adapterGrid.notifyDataSetChanged(); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); +// adapterGrid.notifyDataSetChanged(); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); updateSubtitleToolbar(); }else { @@ -1926,7 +1971,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); recyclerView.setColumnWidth((int) widthScreenPX / 2); adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyDataSetChanged(); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); +// adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); } else { recyclerViewLayout.setPadding(0, 0, 0, 0); @@ -1934,6 +1980,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted POS(" + posInserted + "), range(" + (posInserted - 1) + " -> " + peersOnCall.size() + ") "); adapterGrid.notifyItemInserted(posInserted); +// adapterGrid.notifyDataSetChanged(); adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); updateSubtitleToolbar(); @@ -1952,6 +1999,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ int posInserted=(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); log("(7 +)COMPOSITION IN PROGRESS, notifyItemInserted POS("+(posInserted-1)+"), range("+posInserted+" -> "+peersOnCall.size()+") "); adapterList.notifyItemInserted(posInserted); +// adapterList.notifyDataSetChanged(); adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); updateUserSelected(true); updateSubtitleToolbar(); @@ -1986,7 +2034,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyDataSetChanged(); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + +// adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); } else { if(peersOnCall.size() == 6){ @@ -1994,7 +2044,9 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX/2); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyDataSetChanged(); + adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + +// adapterGrid.notifyDataSetChanged(); updateSubtitleToolbar(); }else{ if(peersOnCall.size() == 4){ @@ -2006,6 +2058,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); adapterGrid.notifyItemRemoved(i); +// adapterGrid.notifyDataSetChanged(); adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); updateSubtitleToolbar(); } @@ -2019,6 +2072,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ if(peersOnCall.size() >= 7){ log("(7 +)COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); adapterList.notifyItemRemoved(i); +// adapterList.notifyDataSetChanged(); adapterList.notifyItemRangeChanged(i, peersOnCall.size()); updateUserSelected(true); updateSubtitleToolbar(); @@ -2065,6 +2119,50 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } + }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_NETWORK_QUALITY)){ + log("onChatCallUpdate()-CHANGE_TYPE_SESSION_NETWORK_QUALITY"); + + if(chat.isGroup()){ + + if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ + peersBeforeCall.clear(); + } + long userHandle = call.getPeerSessionStatusChange(); + + MegaChatSession userSession = callChat.getMegaChatSession(userHandle); + if(userSession != null){ + if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ + log("SESSION_STATUS_IN_PROGRESS"); + + int qualityLevel = userSession.getNetworkQuality(); + log("quealityLevel: "+qualityLevel); + +// updateSubTitle(); +// //contact joined the group call +// log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); + + }else{ + log("other "); + + } + +// updateRemoteVideoStatus(userHandle); +// updateRemoteAudioStatus(userHandle); +// updateLocalVideoStatus(); +// updateLocalAudioStatus(); + } + }else{ +// log("onChatCallUpdate() - CHANGE_TYPE_SESSION_STATUS"); +// +// if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ +// updateSubTitle(); +// } +// updateRemoteVideoStatus(-1); +// updateRemoteAudioStatus(-1); +// +// updateLocalVideoStatus(); +// updateLocalAudioStatus(); + } }else{ log("other: "+call.getChanges()); } @@ -2153,6 +2251,14 @@ public void onClick(View v) { case R.id.video_fab:{ log("onClick video FAB"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ + linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); + RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutCompress); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + megaChatApi.answerChatCall(chatId, true, this); clearHandlers(); @@ -2174,11 +2280,9 @@ public void onClick(View v) { break; } case R.id.micro_fab: { - if(callChat.hasLocalAudio()){ megaChatApi.disableAudio(chatId, this); - } - else{ + }else{ megaChatApi.enableAudio(chatId, this); } if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){ @@ -2198,6 +2302,13 @@ public void onClick(View v) { case R.id.answer_call_fab:{ log("Click on answer fab"); if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ + linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); + RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutCompress); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); megaChatApi.answerChatCall(chatId, false, this); clearHandlers(); @@ -2273,6 +2384,12 @@ public void showInitialFABConfiguration(){ microFAB.setVisibility(GONE); if (callChat.hasVideoInitialCall()) { + RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); + layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); + layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); answerCallFAB.setOnClickListener(this); videoFAB.setOnClickListener(null); @@ -2280,11 +2397,8 @@ public void showInitialFABConfiguration(){ linearArrowVideo.setVisibility(View.VISIBLE); videoFAB.startAnimation(shake); - RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); - layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); - layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); - linearFAB.setLayoutParams(layoutExtend); - linearFAB.setOrientation(LinearLayout.HORIZONTAL); + + animationAlphaArrows(fourArrowVideo); handlerArrow1 = new Handler(); @@ -2348,12 +2462,12 @@ public void onAnimationRepeat(Animation animation) { @Override public void onAnimationEnd(Animation animation) { - RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); + linearFAB.setOrientation(LinearLayout.HORIZONTAL); + RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); linearFAB.setLayoutParams(layoutCompress); - linearFAB.setOrientation(LinearLayout.HORIZONTAL); - + linearFAB.requestLayout(); answerVideoCall(); } }); @@ -2367,14 +2481,15 @@ public void onSwipeBottom() {} }else{ - answerCallFAB.startAnimation(shake); - RelativeLayout.LayoutParams layoutExtend = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); layoutExtend.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutExtend.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); linearFAB.setLayoutParams(layoutExtend); + linearFAB.requestLayout(); linearFAB.setOrientation(LinearLayout.HORIZONTAL); + answerCallFAB.startAnimation(shake); + linearArrowCall.setVisibility(View.VISIBLE); animationAlphaArrows(fourArrowCall); handlerArrow4 = new Handler(); @@ -2435,11 +2550,11 @@ public void onAnimationRepeat(Animation animation) { @Override public void onAnimationEnd(Animation animation) { - - RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); + RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutCompress.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); linearFAB.setLayoutParams(layoutCompress); + linearFAB.requestLayout(); linearFAB.setOrientation(LinearLayout.HORIZONTAL); answerAudioCall(); @@ -2468,6 +2583,16 @@ public void onSwipeBottom() {} hangFAB.show(); hangFAB.setVisibility(View.VISIBLE); } + + if((bigRecyclerViewLayout!=null)&&(bigRecyclerView!=null)&&(parentBigCameraGroupCall!=null)){ + RelativeLayout.LayoutParams bigRecyclerViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); + bigRecyclerViewParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.parent_layout_big_camera_group_call); + bigRecyclerViewParams.addRule(RelativeLayout.BELOW, 0); + bigRecyclerViewLayout.setLayoutParams(bigRecyclerViewParams); + bigRecyclerViewLayout.requestLayout(); + } + } public void updateLocalVideoStatus(){ @@ -3132,9 +3257,11 @@ public void updatePeers(boolean flag){ avatarBigCameraGroupCallLayout.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); - + recyclerViewLayout.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE); if(peersOnCall.size()< 4){ recyclerViewLayout.setPadding(0,0,0,0); @@ -3176,8 +3303,11 @@ public void updatePeers(boolean flag){ } recyclerView.setAdapter(null); recyclerView.setVisibility(View.GONE); + recyclerViewLayout.setVisibility(View.GONE); bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); } @@ -3191,9 +3321,11 @@ public void updatePeers(boolean flag){ } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + recyclerViewLayout.setVisibility(View.GONE); parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); + bigRecyclerViewLayout.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); if(adapterList == null){ @@ -3247,9 +3379,12 @@ public void updatePeers(boolean flag){ bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); + recyclerViewLayout.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE); if(peersBeforeCall.size()< 4){ recyclerViewLayout.setPadding(0,0,0,0); @@ -3284,8 +3419,12 @@ public void updatePeers(boolean flag){ } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + recyclerViewLayout.setVisibility(View.GONE); + bigRecyclerView.setAdapter(null); bigRecyclerView.setVisibility(GONE); + bigRecyclerViewLayout.setVisibility(GONE); + parentBigCameraGroupCall.setOnClickListener(null); parentBigCameraGroupCall.setVisibility(View.GONE); } @@ -3299,9 +3438,12 @@ public void updatePeers(boolean flag){ } recyclerView.setAdapter(null); recyclerView.setVisibility(GONE); + recyclerViewLayout.setVisibility(View.GONE); + parentBigCameraGroupCall.setOnClickListener(this); parentBigCameraGroupCall.setVisibility(View.VISIBLE); + bigRecyclerViewLayout.setVisibility(View.VISIBLE); bigRecyclerView.setVisibility(View.VISIBLE); if(adapterList==null){ log("(7 +) incoming call - create adapter"); @@ -3526,7 +3668,6 @@ public void updateUserSelected(boolean flag){ public void createBigFragment(Long handle){ log("createBigFragment()"); - parentBigCameraGroupCall.setVisibility(View.VISIBLE); //Remove big Camera if(bigCameraGroupCallFragment != null){ @@ -3546,22 +3687,13 @@ public void createBigFragment(Long handle){ ftFS.commitNowAllowingStateLoss(); } fragmentBigCameraGroupCall.setVisibility(View.VISIBLE); - + parentBigCameraGroupCall.setVisibility(View.VISIBLE); //Remove Avatar avatarBigCameraGroupCallLayout.setVisibility(View.GONE); } public void createBigAvatar(Long handle, String fullName){ log("createBigAvatar()"); - - parentBigCameraGroupCall.setVisibility(View.VISIBLE); - - //Create Avatar - avatarBigCameraGroupCallLayout.setVisibility(View.VISIBLE); - if(!handle.equals(megaChatApi.getMyUserHandle())){ - setProfileContactAvatarGroupCall(handle,fullName); - } - //Remove big Camera if (bigCameraGroupCallFragment != null) { log("REMOVE bigCameraGroupCallFragment"); @@ -3570,7 +3702,14 @@ public void createBigAvatar(Long handle, String fullName){ ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; } + fragmentBigCameraGroupCall.setVisibility(View.GONE); + + //Create Avatar + avatarBigCameraGroupCallImage.setImageBitmap(null); + setProfileContactAvatarGroupCall(handle,fullName); + parentBigCameraGroupCall.setVisibility(View.VISIBLE); + avatarBigCameraGroupCallLayout.setVisibility(View.VISIBLE); } public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 6d6adf0c222..7d8798697f9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -190,13 +190,6 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in return; } - //Avatar: - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - setProfileMyAvatar(holder); - }else{ - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); - } - int numPeersOnCall = getItemCount(); log("onBindViewHolderGrid() - peer: "+peer.getName()+", numPeersOnCall: "+numPeersOnCall); @@ -537,6 +530,13 @@ public void onClick(View v) { }else{ log("peer: "+peer.getHandle()+", VIDEO OFF"); + holder.avatarImage.setImageBitmap(null); + //Avatar: + if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { + setProfileMyAvatar(holder); + }else{ + setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); + } //Remove SurfaceView && Listener: holder.surfaceMicroLayout.setVisibility(GONE); @@ -573,12 +573,6 @@ public void onClick(View v) { } holder.avatarMicroLayout.setVisibility(View.VISIBLE); - //Avatar: - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { - setProfileMyAvatar(holder); - }else{ - setProfileContactAvatar(peer.getHandle(), peer.getName(), holder); - } //Micro icon: if(numPeersOnCall < 7){ @@ -667,7 +661,7 @@ public InfoPeerGroupCall getNodeAt(int position) { //My avatar public void setProfileMyAvatar(ViewHolderGroupCall holder) { - log("setProfileMyAvatar"); + log("setProfileMyAvatar()"); Bitmap myBitmap = null; File avatar = null; if (context != null) { @@ -687,35 +681,32 @@ public void setProfileMyAvatar(ViewHolderGroupCall holder) { if (myBitmap != null) { holder.avatarImage.setImageBitmap(myBitmap); holder.avatarInitialLetter.setVisibility(GONE); - } - else{ + }else{ createMyDefaultAvatar(holder); } - } - else { + }else { createMyDefaultAvatar(holder); } - } else { + }else { createMyDefaultAvatar(holder); } } //My Default avatar public void createMyDefaultAvatar(ViewHolderGroupCall holder) { - log("createMyDefaultAvatar"); + log("createMyDefaultAvatar()"); String myFullName = megaChatApi.getMyFullname(); String myFirstLetter=myFullName.charAt(0) + ""; myFirstLetter = myFirstLetter.toUpperCase(Locale.getDefault()); long userHandle = megaChatApi.getMyUserHandle(); - Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels,outMetrics.widthPixels, Bitmap.Config.ARGB_8888); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); p.setAntiAlias(true); p.setColor(Color.TRANSPARENT); String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); - if(color!=null){ p.setColor(Color.parseColor(color)); }else{ @@ -723,11 +714,11 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { } int radius; - if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) - radius = defaultAvatar.getWidth()/2; - else - radius = defaultAvatar.getHeight()/2; - + if (defaultAvatar.getWidth() < defaultAvatar.getHeight()) { + radius = defaultAvatar.getWidth() / 2; + }else { + radius = defaultAvatar.getHeight() / 2; + } c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); holder.avatarImage.setImageBitmap(defaultAvatar); holder.avatarInitialLetter.setText(myFirstLetter); @@ -736,7 +727,7 @@ public void createMyDefaultAvatar(ViewHolderGroupCall holder) { //Contact avatar public void setProfileContactAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){ - log("setProfileContactAvatar"); + log("setProfileContactAvatar()"); Bitmap bitmap = null; File avatar = null; @@ -788,7 +779,6 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde } }else{ UserAvatarListener listener = new UserAvatarListener(context); - if(!avatarRequested){ avatarRequested = true; if (context.getExternalCacheDir() != null){ @@ -798,7 +788,6 @@ public void setProfileContactAvatar(long userHandle, String fullName, ViewHolde megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } } - createDefaultAvatar(userHandle, fullName, holder); } } @@ -959,14 +948,14 @@ public void resetSize(Long userHandle) { log("resetSize"); if(getItemCount()!=0){ for(InfoPeerGroupCall peer:peers){ - if(peer.getHandle() == userHandle){ - if(peer.getListener()!=null){ - if(peer.getListener().getWidth()!=0){ - peer.getListener().setWidth(0); - } - if(peer.getListener().getHeight()!=0){ - peer.getListener().setHeight(0); - } + if(peer.getListener()!=null){ + peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); + + if(peer.getListener().getWidth()!=0){ + peer.getListener().setWidth(0); + } + if(peer.getListener().getHeight()!=0){ + peer.getListener().setHeight(0); } } } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 1d4ec5a4975..bf52dcb32a5 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -8,6 +8,7 @@ android:id="@+id/file_info_fragment_container" android:fitsSystemWindows="true" android:keepScreenOn="true" + android:background="@color/black" tools:context=".lollipop.megachat.calls.ChatCallActivity"> + @@ -124,21 +124,26 @@ android:background="@android:color/transparent" android:visibility="gone" android:src="@drawable/ic_mic_off_contact"/> - - - + + + + + + @@ -271,7 +276,6 @@ - + + android:background="@color/transparent_black"> Date: Sat, 24 Nov 2018 16:58:16 +0100 Subject: [PATCH 125/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 22 ++++++++++++------- .../main/res/layout/activity_calls_chat.xml | 19 +++++++++++++--- app/src/main/res/values/strings.xml | 3 +++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index fc80896c651..1b76db27573 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -146,6 +146,7 @@ public class ChatCallActivity extends AppCompatActivity implements MegaChatReque TextView subtitleToobar; LinearLayout linearParticipants; TextView participantText; + TextView infoUsersBar; ActionBar aB; boolean avatarRequested = false; @@ -814,6 +815,7 @@ protected void onCreate(Bundle savedInstanceState) { linearParticipants.setVisibility(View.GONE); + myChrono = new Chronometer(context); smallElementsIndividualCallLayout = (RelativeLayout) findViewById(R.id.small_elements_individual_call); @@ -830,11 +832,12 @@ protected void onCreate(Bundle savedInstanceState) { linearFAB.requestLayout(); linearFAB.setOrientation(LinearLayout.HORIZONTAL); + infoUsersBar = (TextView) findViewById(R.id.info_users_bar); + infoUsersBar.setVisibility(GONE); + isManualMode = false; relativeCall = (RelativeLayout) findViewById(R.id.relative_answer_call_fab); - relativeCall.getLayoutParams().width = Util.scaleWidthPx(48, outMetrics) ; - relativeCall.getLayoutParams().height = RelativeLayout.LayoutParams.MATCH_PARENT; relativeCall.requestLayout(); relativeCall.setVisibility(GONE); @@ -846,12 +849,9 @@ protected void onCreate(Bundle savedInstanceState) { fourArrowCall = (ImageView) findViewById(R.id.four_arrow_call); relativeVideo = (RelativeLayout) findViewById(R.id.relative_video_fab); - relativeVideo.getLayoutParams().width = Util.scaleWidthPx(48, outMetrics) ; - relativeVideo.getLayoutParams().height = RelativeLayout.LayoutParams.MATCH_PARENT; relativeVideo.requestLayout(); relativeVideo.setVisibility(GONE); - linearArrowVideo = (LinearLayout) findViewById(R.id.linear_arrow_video); linearArrowVideo.setVisibility(GONE); firstArrowVideo = (ImageView) findViewById(R.id.first_arrow_video); @@ -1951,6 +1951,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+userPeer.getHandle()+" added"); updateSubTitle(); peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); + infoUsersBar.setAlpha(1); + infoUsersBar.setVisibility(View.VISIBLE); + infoUsersBar.animate().alpha(0).setDuration(3000); if (peersOnCall.size() < 7) { if (adapterGrid != null) { @@ -2025,7 +2029,12 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if (!peerContained) { log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+peersOnCall.get(i).getHandle()+" removed"); + infoUsersBar.setText(peersOnCall.get(i).getName()+" "+getString(R.string.contact_left_the_call)); + infoUsersBar.setAlpha(1); + infoUsersBar.setVisibility(View.VISIBLE); + infoUsersBar.animate().alpha(0).setDuration(3000); peersOnCall.remove(i); + if (peersOnCall.size() < 7) { if (adapterGrid != null) { @@ -2397,9 +2406,6 @@ public void showInitialFABConfiguration(){ linearArrowVideo.setVisibility(View.VISIBLE); videoFAB.startAnimation(shake); - - - animationAlphaArrows(fourArrowVideo); handlerArrow1 = new Handler(); handlerArrow1.postDelayed(new Runnable() { diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index bf52dcb32a5..ebb5723caa1 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -53,7 +53,6 @@ android:stretchMode="columnWidth"/> - + + + [B]No [/B][A]Notifications[/A][B].[/B] + joined the call + left the call + From 3f4d393591baa14e208b59effba02ce64a0232df Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sat, 24 Nov 2018 17:02:22 +0100 Subject: [PATCH 126/247] Group calls UI --- .../android/app/lollipop/megachat/calls/ChatCallActivity.java | 4 ++-- app/src/main/res/layout/activity_calls_chat.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1b76db27573..ec75b89ab86 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1954,7 +1954,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); infoUsersBar.setAlpha(1); infoUsersBar.setVisibility(View.VISIBLE); - infoUsersBar.animate().alpha(0).setDuration(3000); + infoUsersBar.animate().alpha(0).setDuration(4000); if (peersOnCall.size() < 7) { if (adapterGrid != null) { @@ -2032,7 +2032,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ infoUsersBar.setText(peersOnCall.get(i).getName()+" "+getString(R.string.contact_left_the_call)); infoUsersBar.setAlpha(1); infoUsersBar.setVisibility(View.VISIBLE); - infoUsersBar.animate().alpha(0).setDuration(3000); + infoUsersBar.animate().alpha(0).setDuration(4000); peersOnCall.remove(i); if (peersOnCall.size() < 7) { diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index ebb5723caa1..eb86d35aa48 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -279,8 +279,8 @@ android:id="@+id/info_users_bar" android:layout_width="match_parent" android:layout_height="36dp" - android:layout_below="@+id/call_toolbar" android:textAlignment="center" + android:layout_alignParentTop="true" android:gravity="center" android:textColor="@color/white" android:textSize="14sp" From 57c764f8a4d2a3ca5da9643186ff20a154b7471f Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sat, 24 Nov 2018 19:23:29 +0100 Subject: [PATCH 127/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 324 +++++++++++++----- .../megachat/calls/InfoPeerGroupCall.java | 12 +- .../chatAdapters/GroupCallAdapter.java | 116 ++++++- app/src/main/res/drawable/icon_quality.xml | 9 + app/src/main/res/drawable/rl_icon_quality.xml | 9 + .../main/res/layout/activity_calls_chat.xml | 24 +- .../res/layout/item_camera_group_call.xml | 24 +- 7 files changed, 414 insertions(+), 104 deletions(-) create mode 100644 app/src/main/res/drawable/icon_quality.xml create mode 100644 app/src/main/res/drawable/rl_icon_quality.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index ec75b89ab86..33b7cbb3788 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -338,12 +338,12 @@ public void updateScreenStatusInProgress(){ } if (!peerContain) { if (userHandle != megaChatApi.getMyUserHandle()) { - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); changes = true; } else { - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, true, null); log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); peersOnCall.add(myPeer); changes = true; @@ -376,13 +376,13 @@ public void updateScreenStatusInProgress(){ for(int i = 0; i < callChat.getParticipants().size(); i++){ long userHandle = callChat.getParticipants().get(i); if(userHandle != megaChatApi.getMyUserHandle()){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); log("updateScreenStatusInProgress() "+userPeer.getName()+" added in peersOnCall"); peersOnCall.add((peersOnCall.size() == 0 ? 0:(peersOnCall.size()-1)), userPeer); changes = true; }else{ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,null); + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,true,null); log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall"); peersOnCall.add(myPeer); changes = true; @@ -552,7 +552,7 @@ protected void onNewIntent(Intent intent) { } } if(!peerContain){ - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,null); + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,true,null); log("onNewIntent() "+userPeer.getName()+" added in peersBeforeCall"); peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; @@ -581,7 +581,7 @@ protected void onNewIntent(Intent intent) { boolean changes = false; for(int i=0; i + + + + + diff --git a/app/src/main/res/drawable/rl_icon_quality.xml b/app/src/main/res/drawable/rl_icon_quality.xml new file mode 100644 index 00000000000..3eceba94fab --- /dev/null +++ b/app/src/main/res/drawable/rl_icon_quality.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index eb86d35aa48..d27922dc915 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -356,7 +356,7 @@ + + + + - + + + Date: Sun, 25 Nov 2018 16:15:16 +0100 Subject: [PATCH 128/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 56 ++++++++----------- .../chatAdapters/GroupCallAdapter.java | 24 ++++---- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 33b7cbb3788..b9b79838043 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -317,8 +317,6 @@ public void updateScreenStatusInProgress(){ if(chat.isGroup()){ log("updateScreenStatusInProgress() - group chat - chatId: "+chatId); - - if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){ peersBeforeCall.clear(); } @@ -395,8 +393,17 @@ public void updateScreenStatusInProgress(){ } } } - updateLocalVideoStatus(); - updateLocalAudioStatus(); + + for(int i=0; i removeAllViews && removeAllViewsInLayout && addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- listener == null ---> removeAllViews && removeAllViewsInLayout && addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.removeAllViews(); holder.parentSurfaceView.removeAllViewsInLayout(); @@ -413,14 +413,14 @@ public void onClick(View v) { } }else{ - log("peer: "+peer.getName()+", VIDEO ON- listener != null"); + log("peer: "+peer.getHandle()+", VIDEO ON - listener != null"); if(holder.parentSurfaceView.getChildCount() == 0){ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() == 0"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() == 0"); if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getName()+", VIDEO ON- getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0)"); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); @@ -436,7 +436,7 @@ public void onClick(View v) { }else{ - log("peer: "+peer.getName()+", VIDEO ON- getParent 1 ---> addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 ---> addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); @@ -448,7 +448,7 @@ public void onClick(View v) { } } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getParent 0 ---> nothing"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 ---> addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ @@ -460,10 +460,10 @@ public void onClick(View v) { } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0"); if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it's the same -> setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it's the same -> setSizeFromLayout && h(0)w(0)"); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ @@ -473,7 +473,7 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same ---->removeAllViews && removeAllViewsInLayout"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same ---->removeAllViews && removeAllViewsInLayout"); //Remove items of parent holder.parentSurfaceView.removeAllViews(); @@ -482,7 +482,7 @@ public void onClick(View v) { //Remove parent of Surface if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0"); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); @@ -496,7 +496,7 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 -> addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); @@ -509,7 +509,7 @@ public void onClick(View v) { } }else{ - log("peer: "+peer.getName()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 ->addView && setSizeFromLayout && h(0)w(0)"); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); From 066a42eab09481a3c32285e158fc2c526bb49eec Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 25 Nov 2018 17:11:42 +0100 Subject: [PATCH 129/247] Group call UI --- .../calls/BigCameraGroupCallFragment.java | 4 ++++ .../megachat/calls/ChatCallActivity.java | 18 +++++++----------- .../calls/LocalCameraCallFragment.java | 5 ++++- .../LocalCameraCallFullScreenFragment.java | 4 ++++ .../calls/MegaSurfaceRendererGroup.java | 4 ++-- .../RemoteCameraCallFullScreenFragment.java | 4 ++++ .../chatAdapters/GroupCallAdapter.java | 8 ++++++++ 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 20ab5ce2fa0..36f18bac907 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -144,6 +144,7 @@ public void onDestroy(){ ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); } } + fullScreenSurfaceView.setVisibility(View.GONE); if(userHandle.equals(megaChatApi.getMyUserHandle())){ log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); @@ -158,6 +159,8 @@ public void onResume() { log("onResume"); this.width=0; this.height=0; + fullScreenSurfaceView.setVisibility(View.VISIBLE); + super.onResume(); } @@ -169,6 +172,7 @@ public void removeSurfaceView(){ ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); } } + fullScreenSurfaceView.setVisibility(View.GONE); if(userHandle.equals(megaChatApi.getMyUserHandle())){ log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index b9b79838043..4cc3058c083 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -28,6 +28,10 @@ import android.os.PowerManager; import android.os.SystemClock; import android.os.Vibrator; +import android.renderscript.Allocation; +import android.renderscript.Element; +import android.renderscript.RenderScript; +import android.renderscript.ScriptIntrinsicBlur; import android.support.design.widget.AppBarLayout; import android.support.design.widget.FloatingActionButton; import android.support.v4.app.ActivityCompat; @@ -299,7 +303,6 @@ public boolean onOptionsItemSelected(MenuItem item) { log("onOptionsItemSelected"); ((MegaApplication) getApplication()).sendSignalPresenceActivity(); - int id = item.getItemId(); switch (id) { case android.R.id.home: { @@ -346,9 +349,7 @@ public void updateScreenStatusInProgress(){ peersOnCall.add(myPeer); changes = true; } - } - } for (int i = 0; i < peersOnCall.size(); i++) { boolean peerContained = false; @@ -368,7 +369,6 @@ public void updateScreenStatusInProgress(){ if(changes){ updatePeers(true); } - }else{ boolean changes = false; for(int i = 0; i < callChat.getParticipants().size(); i++){ @@ -385,8 +385,6 @@ public void updateScreenStatusInProgress(){ peersOnCall.add(myPeer); changes = true; } - - } if(changes){ updatePeers(true); @@ -402,10 +400,7 @@ public void updateScreenStatusInProgress(){ updateRemoteVideoStatus(peersOnCall.get(i).getHandle()); updateRemoteAudioStatus(peersOnCall.get(i).getHandle()); } - } - - }else{ log("updateScreenStatusInProgress() - individual chat - chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); @@ -1421,6 +1416,7 @@ protected void hideFABs(){ public void onPause(){ log("onPause"); mSensorManager.unregisterListener(this); + super.onPause(); } @@ -2151,7 +2147,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ int qualityLevel = userSession.getNetworkQuality(); if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - if(qualityLevel < 3){ + if(qualityLevel < 2){ //bad quality for(int i=0; i surfaceWidth = 0 && surfaceHeight = 0"); + log("************* surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java index 44dfa124b70..00e36e5272b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java @@ -143,6 +143,7 @@ public void onDestroy(){ } } log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+chatId); + remoteFullScreenSurfaceView.setVisibility(View.GONE); megaChatApi.removeChatVideoListener(chatId, userHandle, this); super.onDestroy(); } @@ -152,6 +153,8 @@ public void onResume() { log("onResume"); this.width=0; this.height=0; + remoteFullScreenSurfaceView.setVisibility(View.VISIBLE); + super.onResume(); } @@ -163,6 +166,7 @@ public void removeSurfaceView(){ ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView); } } + remoteFullScreenSurfaceView.setVisibility(View.GONE); log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, userHandle, this); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 8130a3c1021..ea79fd66c6e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -8,6 +8,10 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; +import android.renderscript.Allocation; +import android.renderscript.Element; +import android.renderscript.RenderScript; +import android.renderscript.ScriptIntrinsicBlur; import android.support.v4.content.ContextCompat; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; @@ -1112,6 +1116,7 @@ public void onDestroy(){ } } } + peer.getListener().getSurfaceView().setVisibility(GONE); peer.setListener(null); } @@ -1125,6 +1130,9 @@ public void onDestroy(){ } + + + public ArrayList getPeers() { return peers; } From c729a44ecda09b370d1b93a3bb79213f33ee6ad6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Sun, 25 Nov 2018 17:12:21 +0100 Subject: [PATCH 130/247] Group call UI --- .../app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index 371aaa12a58..a98055f4096 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -113,7 +113,7 @@ private void changeDestRect(int dstWidth, int dstHeight) { } public void surfaceCreated(SurfaceHolder holder) { - log("****+ surfaceCreated()"); + log("surfaceCreated()"); Canvas canvas = holder.lockCanvas(); if(canvas != null) { Rect dst = holder.getSurfaceFrame(); @@ -157,7 +157,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - log("************* surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); + log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; byteBuffer = null; From 33afe3b44d93341fd0bc7b86be8a80bd95c81a6d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 08:25:54 +0100 Subject: [PATCH 131/247] Group call UI --- app/build.gradle | 2 -- .../megachat/calls/ChatCallActivity.java | 2 +- .../chatAdapters/GroupCallAdapter.java | 12 ++++++- .../res/layout/item_camera_group_call.xml | 32 +++++++++---------- app/src/main/res/values/colors.xml | 1 + 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e423d4e79b7..22b0db22751 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,8 +80,6 @@ dependencies { implementation "com.android.support:support-emoji:27.1.1" implementation 'com.android.support:support-emoji-appcompat:27.1.1' implementation 'com.android.support:support-emoji-bundled:27.1.1' - - } apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 4cc3058c083..63fee7174a2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2147,7 +2147,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ int qualityLevel = userSession.getNetworkQuality(); if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - if(qualityLevel < 2){ + if(qualityLevel < 3){ //bad quality for(int i=0; i - - - - + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ba1a9d0b874..ab7a604e487 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -182,4 +182,5 @@ #FF333333 #FF666666 + \ No newline at end of file From 80d78c55b8ba34c3b5c3bac45b80ad705034c576 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 09:11:21 +0100 Subject: [PATCH 132/247] Group call UI --- .../lollipop/megachat/chatAdapters/GroupCallAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 0e2288f3518..e55180771e6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -401,7 +401,13 @@ public void onClick(View v) { SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - surfaceView.setZOrderOnTop(true); + + if(numPeersOnCall<7){ + surfaceView.setZOrderMediaOverlay(true); + }else{ + surfaceView.setZOrderOnTop(true); + } + GroupCallListener listenerPeer = new GroupCallListener(context, surfaceView, peer.getHandle()); peer.setListener(listenerPeer); From 8850a3e48a15e93d58eaa92a67ee3f5ffa3d892d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 09:40:25 +0100 Subject: [PATCH 133/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 44 +++++++++--------- .../main/res/drawable-hdpi/ic_w_end_call.png | Bin 0 -> 718 bytes .../main/res/drawable-mdpi/ic_w_end_call.png | Bin 0 -> 474 bytes .../main/res/drawable-xhdpi/ic_w_end_call.png | Bin 0 -> 962 bytes .../res/drawable-xxhdpi/ic_w_end_call.png | Bin 0 -> 1458 bytes .../res/drawable-xxxhdpi/ic_w_end_call.png | Bin 0 -> 1978 bytes .../main/res/layout/activity_calls_chat.xml | 2 +- 7 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_w_end_call.png create mode 100644 app/src/main/res/drawable-mdpi/ic_w_end_call.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_w_end_call.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_w_end_call.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_w_end_call.png diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 63fee7174a2..d13399ff141 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -401,6 +401,8 @@ public void updateScreenStatusInProgress(){ updateRemoteAudioStatus(peersOnCall.get(i).getHandle()); } } + + updateSubTitleClock(); }else{ log("updateScreenStatusInProgress() - individual chat - chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); @@ -464,6 +466,8 @@ public void updateScreenStatusInProgress(){ updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); + updateSubTitleClock(); + } stopAudioSignals(); @@ -471,8 +475,8 @@ public void updateScreenStatusInProgress(){ } - public void updateSubTitle(){ - log("updateSubTitle()"); + public void updateSubTitleClock(){ + log("updateSubTitleClock()"); int sessionStatus = -1; if(callChat.getStatus()<=MegaChatCall.CALL_STATUS_RING_IN){ @@ -484,8 +488,8 @@ public void updateSubTitle(){ int totalParticipants = callChat.getNumParticipants() + 1; log("update subtitle: "+totalParticipants +" of "+chat.getPeerCount()); updateSubtitleToolbar(); - } - else{ + } else{ + linearParticipants.setVisibility(GONE); MegaChatSession userSession = callChat.getMegaChatSession(chat.getPeerHandle(0)); if(userSession!=null){ sessionStatus = userSession.getStatus(); @@ -605,7 +609,6 @@ protected void onNewIntent(Intent intent) { linearFAB.requestLayout(); linearFAB.setOrientation(LinearLayout.HORIZONTAL); - updateSubTitle(); if(peersOnCall != null){ if(peersOnCall.size() != 0){ boolean changes = false; @@ -688,7 +691,6 @@ protected void onNewIntent(Intent intent) { callChat = megaChatApi.getChatCall(chatId); titleToolbar.setText(chat.getTitle()); - updateSubTitle(); updateScreenStatusInProgress(); log("Start call Service"); @@ -1027,7 +1029,7 @@ protected void onCreate(Bundle savedInstanceState) { int callStatus = callChat.getStatus(); log("The status of the callChat is: " + callStatus); titleToolbar.setText(chat.getTitle()); - updateSubTitle(); + updateSubTitleClock(); if(chat.isGroup()){ smallElementsIndividualCallLayout.setVisibility(View.GONE); @@ -1723,8 +1725,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { videoFAB.setOnTouchListener(null); videoFAB.setOnClickListener(this); - updateSubTitle(); - + updateSubTitleClock(); stopAudioSignals(); rtcAudioManager.start(null); showInitialFABConfiguration(); @@ -1826,14 +1827,14 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); - updateSubTitle(); + updateSubtitleToolbar(); //contact joined the group call log(chat.getPeerFullnameByHandle(userHandle)+" joined in the group call"); }else if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_DESTROYED){ log("SESSION_STATUS_DESTROYED "); - updateSubTitle(); + updateSubtitleToolbar(); //contact left the group call log(chat.getPeerFullnameByHandle(userHandle)+" left the group call"); } @@ -1842,7 +1843,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("onChatCallUpdate() - CHANGE_TYPE_SESSION_STATUS"); if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ - updateSubTitle(); +// updateSubTitle(); } updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); @@ -1946,7 +1947,6 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } else { InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+userPeer.getHandle()+" added"); - updateSubTitle(); peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); @@ -1965,7 +1965,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemInserted(posInserted); // adapterGrid.notifyDataSetChanged(); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); }else { if (peersOnCall.size() == 4) { @@ -1975,7 +1975,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); // adapterGrid.notifyDataSetChanged(); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); } else { recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX / 2); @@ -1984,7 +1984,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemInserted(posInserted); // adapterGrid.notifyDataSetChanged(); adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); } } @@ -2005,7 +2005,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ // adapterList.notifyDataSetChanged(); adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); updateUserSelected(true); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); } } else { @@ -2047,7 +2047,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); // adapterGrid.notifyDataSetChanged(); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); } else { if(peersOnCall.size() == 6){ log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); @@ -2057,7 +2057,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); // adapterGrid.notifyDataSetChanged(); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); }else{ if(peersOnCall.size() == 4){ recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); @@ -2070,7 +2070,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ adapterGrid.notifyItemRemoved(i); // adapterGrid.notifyDataSetChanged(); adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); } } @@ -2085,7 +2085,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ // adapterList.notifyDataSetChanged(); adapterList.notifyItemRangeChanged(i, peersOnCall.size()); updateUserSelected(true); - updateSubtitleToolbar(); +// updateSubtitleToolbar(); }else{ log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); updatePeers(true); @@ -3382,8 +3382,6 @@ public void updatePeers(boolean flag){ } //Call IN PROGRESS - updateSubTitle(); - updateSubtitleToolbar(); if(peersOnCall.size() < 7){ //1-6 if(peersOnCall.size()!=0){ diff --git a/app/src/main/res/drawable-hdpi/ic_w_end_call.png b/app/src/main/res/drawable-hdpi/ic_w_end_call.png new file mode 100644 index 0000000000000000000000000000000000000000..d399674bed9b7a1b11f44d60a994b4580550baf5 GIT binary patch literal 718 zcmV;<0x|uGP)Px%h)G02R9Fe^l}$)hK@`XD4L>q1#V^##s7S*sH!fO4(Ly3HZ0|y9*``g4Kw5+w zkrr-(wr<@^K})ekf*Mj729Z&wsAy{12fcp(@y=tq@A14BTC|u0zc=TeIdeR7=FAub zUVH_71$+g31^({}glW>tWHJZvKLst&3Jq{L;wR%KY`}Y%hq*8eR~Qq^z6p`US)$#5 z%Ww&*AdS4kc>>1aDG7c~v)K5OL^C{qS@@Uon_!dB4|Vwx`>R4Y)#LOCdO^pNPrhJ$ z18?C2d<7jzR z;5qz&xGZ7luwhJvFdV`#4ce8J7bwFp#tyWb0KaC2ZaAUum}H!9tE*q0v0e?X^+y=4 z!yQmhTKR}_9zR_OrZS;9d}`t1@~v zB;CXv+f(;`iCd1g1|^ZbUP+XKO=dTqOyub9?j=4$k-gx+A3TnOO{g~ROdM726ZVtQ zT&1q|F6fn&9K=D_HZIkUVcF65Q`a2_Jqh_luf3J+BC`BN5_(hGBWn-e`lGs0ji6n2 zftA-*NiZs|m50RD(Z2%SszuPNZ{Mj6a*@s4vO%1ah;CV>S(M-h-!e#g8Ah@pS#%T@ zp^)eSyOLd$P+`plm@gEVxiv6vpuG)xwDe#6KAZ#fl^!#dP)#=lvy{~K8lUNe_=Px$lu1NER7ef&lT9l`VHC&joh%Gx#KK$Nnw_mICJITiun=W|@+o|P*(v1%uocOI zQ8v?HLl$ZhE2WUUESQ?eMy}ug&U2?5cT6_2xc~aybMASb^SqpUu4RP^EAXcka2%%= zs(!Pn9WzsRtXaikSiWE%oS!cXGl2XN}&tW0eSsT>& z!g9TCdea6sX0V5ZBz_yHh6xkT8XIKJOmLRmR{RUN2er7QHs;GY&LIS8*`4sigQP{! zH~gwBfrwjE9CgVYs4Q2YpXij*sH@6~{CXz!K_@gq4pzv2!iEYf@ZT%&2`AiO>)EOQ QW&i*H07*qoM6N<$f=|QC8UO$Q literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_w_end_call.png b/app/src/main/res/drawable-xhdpi/ic_w_end_call.png new file mode 100644 index 0000000000000000000000000000000000000000..fc09ad5841e78397af7990ee0b3456db470169f1 GIT binary patch literal 962 zcmV;z13mnSP)Px&d`Uz>RA>e5md{I7Q4q&{66Rfv;6t`e4pOqaeUYAvsVzDfzLZL=ggTockbMK zUqL~TP=Qc^P=Qc^P=Qc^P=Qc^|F#0De4jj>P8Sh#mB%RhHyG5IN~I!z)lcCysHZzg@`W+05PKO5+aP*o zlR|}tq@RUGI0|}*^CHCB4i}&qh9OQySvch`KrBtyYO79Vv{yuIb2DoKDai=%*GW#9Yo$4=3R)_;E1{ zMqnR%I%GIu;{&jwYL_`DPhq|my6lDp*nR9d;e~c8^CfT-Cc&3>=Ol%daA)F!dsc6%yDE$rM;UEZIFZ zxL!*06~PsQ=!Y#R}QnvJDIh zx(PN;>$bf*m|v*8WTW2sku;FA8si11MS7v1=VFp^7x*%BW;Rus{?co0(9Fe|r~Rn8 z=mfNVoh`>0lf5u*7SGMf#bUQ{NMg3(6t&^3cu5WR-%gUq_zYm{i#;Pu)IcsDr=~eU zX2K=bh>?Qpph_o^37p)QJ9;N)60)HFy9PC&H-i2ScY_{OJ?K5~9NOv2uZ(#Ua_b*y z9q5~+e%G^C0{$CO&)ZdUw=l*F!BmxE_@nlS&yakDGZaE8*w<+CAi*M*9bvha>VtQZqa916gziaB~xbKovrz{!i>(qJkrtcfz zAT0mXn4{|#eEVJ>_>=Hz>b}+9o#e+si%tiYx_{0Jg>srIBamiu8~)|q<16JuF?{ho7)z6{A!7cHF)cyk`kIB_XJBls>`5fRzM zq&*_I+HqANyNqK~cpgao=1O+E1Wi<567(ye^WMJ<53i8^d>4vyT>kCxtVxq{%X-n1 zh8&&i%=Bt3CxXT8C##D0LZvO698=!=IUHDy)c__;2PaoN>VihZa)v4OeQR3t$`JDm z6W?13IO`Nu~O`Bw2UTcWV)M<#~ zMAOuhdO=1BAHF|4GMyxL5lC4;@JW7$(5HIm3%D`^(9IhE{2Nn!3L$&dY6v!eR>IJd zuc_MgKixfKfoGDJ)CPiNZL~3P6JgIn@2=tsTt>81rEsebtWKO)#{@35I1AxQ8#NKR zhG{Vhokuykd$`BC6<5Drem)tryY4evX(lg^eh(y9W-#RhYD_@0!mng7))O}pAM@3M z=aK?v%vPW5!>xSARk@8m#q`i$&7rgwb5IClQEt4%6#{A1qq$Um;=SIw_Z$`KBgr6= zet-rQE6b?NV_D?A13r0IfTc&yqS|>OesxkiXR<3J>)R23 z^)D~KBQM`hEU&2PrB9F_ml@IvtRH5keBdYZCc9G=%89)Eg+j|pd`f>PE@5OhdVt`f z{dzkzoNN6xrmB2W)ye|N8W7<^uz8o5v4!O>La)nsu9_DLi7UTdlq9bl*IMjVp3`9@ z7%hIwypTF#d)2a^*qtUiipGZy9ViV|n)f2!8+Y%X4d@x-ORmjQjHlHIctab$HlaC> z*#F{Vc!B2dee~Iefr=qsLsW-D73`ZCz|cDlzpePp&^)&`m~=+;@`?6StT})kQlh^y ziN}rdUqn0kFAWFWZ?w&e@T^`Hn4QxcW2|#xk>57M2>2eILE8@nBRp4+ zxfob`%$H~NQL#||+$|fdcJ_<P?V9nnZDu-)VL7VLc+^Yj%D;o(C)qm+ zJO2-LMWrY`%w{d-SE*dUn zQ7&gShMRfGkoOqv_cutUXJqAG9HZO3tC4&qmAACX)*-_lut}7>2wu~MR%qWDJ z2)-B42~{S1ho^$)(W?PtV_Qe)xReKYo7v6rA@YDadNc0sx@k>O%DSY1scG z1NqsX@1f{y?|VDc?Tjlm$}&WTg%zYy4%{NB*RT38K#A6k-o7fM zc{FD&C|F5qFe~o0cV%2L-f`u>`Ih|^fOUcf0xxM{X&ZGx1lmy-+i+#GM{SwWXgvSTe_DKDEqSFnS5%6pH` z2BpiZnigyxsLOc%xOr)rEHW~RE2+t&huVi&F+S;iRUW5(#5r`ObBS13v-HAiG^2HN zf-0}ZErhoeZrzwAjQcilWa=>bT-8~#c(ur~Q<|}ffyWJ4NMk#vQ7fnal*m1cs8kAB zO#b4=_G_%IN;K?LSen$4e3rco`n@3ZZX)_YZFe=H9HI8zA$-!&u1xu_JHmI|lf?_2 zV#sQ2&%B0KhivR|*6rUOCzVV`v};rxgdxPzxNI6x`K|^@gubotOJyzioe;tQe1#yJ zFPxwrS^8Aw+UA{Yk>gwfmc;2_h{+zFIw$?(Ledh7l?j)ZAlcl)#qHle$v=|Z%kyL& zrZt(j;S8cRRt9o#=^QJ*m0~pnPqpD^IcB}{Ya3YX0&NBN6_Y_(!cw)3o+=mB0kW;) zojT0!tY?yzVH;;;j&pnB@7=wU29_#@YF&5KS(_J9@O(~9q+jq{gr-)bs2zXC3rrqv zwgPSe0@g~kY5B!(2b3ut=33!-9Rs>Vi$su;z-}BPtMC`xmA$5wu0qz}pYUC0n96~Z z%$(hA^8EADqV!8mdP{QWj4L^&6=9Q?Xc9d!mc~o$H2G%8h7mdgy(y+lZg%WbgWiDI zod>in?Z{Hct(Q@Sz3fPdXS{e<(Wn~~^(ymB((ND>AG6E3UiIzCq@0B=xde;_^Q!gr zid$ZUSN!g2m1eI6cl*)9B73g14PkH{>m|^m#CW@2Cd{9$24;E%r0~nCH~iDMoCXB+ z>-KwA$~Nf&+daWx*7q)nIcCwl`hCjZvBiHLZPov9Yl#N_xlemBs_9ja-d4VQB$(YA zf_Q-6PWF;Ymm4zawaw$pjfmB@>IV%2IccIYALglxnkI=E=7oYM^UE4cvzeyxsEkhc zf@@bBnW!+^8|>)>q)Glny#qND3wR8yH@ER}BmP+k$>#X>_oT(0GuX+`+L7d!erksb z-shsAgN7ifTfe%Du=r4C<7!^Q#yOGE?~Xhy){_2b;x#$}jsdPBix>l~5c|X1Sg;OHiay;+aws==NeQQ7$FZKAvh)wY1u>B@=%XH|1 zUC~|{uB^#-v0rvqfDZjbZ8gJOzhmCkIWy&#+SxO@W`XDf#o>U>{8#Vb6m2FFIrGS{ zs5OYPw3#4}nl~Mb!4({2Xq9Vx1R3H`lW{~*mK~>hUi$dQzrDe=8c%IJGln2XRrc*s zjgOWpHiZV@Mn~Ot2I!bz1^Y@#V*mSVjBh2dLyxhP_h1 z0>Y{?z#Hq*fj`*b3a(!bHHieYFkhUW*&k|uETuRRvw8&sf`QUe<8CowbP!yw`eBg! z#P|2ypj2gyLH~Vvhf}e Date: Mon, 26 Nov 2018 10:35:06 +0100 Subject: [PATCH 134/247] Group call UI --- .../megachat/ChatActivityLollipop.java | 28 +++++++++++++++---- .../megachat/calls/ChatCallActivity.java | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 51ca55ac139..f7eeb13c983 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1591,7 +1591,6 @@ public boolean onCreateOptionsMenu(Menu menu) { inflater.inflate(R.menu.chat_action, menu); callMenuItem = menu.findItem(R.id.cab_menu_call_chat); - videoMenuItem = menu.findItem(R.id.cab_menu_video_chat); inviteMenuItem = menu.findItem(R.id.cab_menu_invite_chat); clearHistoryMenuItem = menu.findItem(R.id.cab_menu_clear_history_chat); @@ -1613,7 +1612,9 @@ public boolean onPrepareOptionsMenu(Menu menu){ clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); contactInfoMenuItem.setVisible(false); + }else { + if (megaChatApi.getChatConnectionState(idChat) != MegaChatApi.CHAT_CONNECTION_ONLINE) { leaveMenuItem.setVisible(false); callMenuItem.setVisible(false); @@ -1636,6 +1637,7 @@ public boolean onPrepareOptionsMenu(Menu menu){ if (chatRoom.isGroup()) { if (permission == MegaChatRoom.PRIV_MODERATOR) { + inviteMenuItem.setVisible(true); int lastMessageIndex = messages.size() - 1; @@ -1663,24 +1665,36 @@ public boolean onPrepareOptionsMenu(Menu menu){ leaveMenuItem.setVisible(false); clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); + callMenuItem.setVisible(false); + videoMenuItem.setVisible(false); + } else if (permission == MegaChatRoom.PRIV_RO) { - log("Group chat PRIV_RM"); + log("Group chat PRIV_RO"); leaveMenuItem.setVisible(true); clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); - } else { + callMenuItem.setVisible(false); + videoMenuItem.setVisible(false); + + } else if(permission == MegaChatRoom.PRIV_STANDARD){ + log("Group chat PRIV_STANDARD"); + leaveMenuItem.setVisible(true); + clearHistoryMenuItem.setVisible(false); + inviteMenuItem.setVisible(false); + + }else{ log("Permission: " + permission); leaveMenuItem.setVisible(true); clearHistoryMenuItem.setVisible(false); inviteMenuItem.setVisible(false); + callMenuItem.setVisible(false); + videoMenuItem.setVisible(false); } -// callMenuItem.setVisible(false); -// videoMenuItem.setVisible(false); - contactInfoMenuItem.setTitle(getString(R.string.group_chat_info_label)); contactInfoMenuItem.setVisible(true); } else { + inviteMenuItem.setVisible(false); if (permission == MegaChatRoom.PRIV_RO) { clearHistoryMenuItem.setVisible(false); @@ -1699,6 +1713,8 @@ public boolean onPrepareOptionsMenu(Menu menu){ } } }else{ + log("***** J - Chatroom null"); + log("Chatroom NULL on create menu"); leaveMenuItem.setVisible(false); callMenuItem.setVisible(false); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index d13399ff141..777fd20631a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -2147,7 +2147,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ int qualityLevel = userSession.getNetworkQuality(); if((peersOnCall!=null)&&(peersOnCall.size()!=0)){ - if(qualityLevel < 3){ + if(qualityLevel < 2){ //bad quality for(int i=0; i Date: Mon, 26 Nov 2018 11:19:04 +0100 Subject: [PATCH 135/247] Group call UI --- .../megachat/calls/BigCameraGroupCallFragment.java | 7 +++---- .../lollipop/megachat/chatAdapters/GroupCallAdapter.java | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 36f18bac907..f245def5b6a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -72,7 +72,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View v = inflater.inflate(R.layout.fragment_local_camera_call_full_screen, container, false); fullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); - fullScreenSurfaceView.setZOrderMediaOverlay(true); + fullScreenSurfaceView.setSecure(true); + SurfaceHolder localSurfaceHolder = fullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); renderer = new MegaSurfaceRendererGroup(fullScreenSurfaceView, userHandle); @@ -119,8 +120,6 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei } } - - if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. @@ -183,6 +182,6 @@ public void removeSurfaceView(){ } private static void log(String log) { - Util.log("LocalCameraCallFullScreenFragment", log); + Util.log("BigCameraGroupCallFragment", log); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index e55180771e6..bce2ff3a865 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -401,12 +401,7 @@ public void onClick(View v) { SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - - if(numPeersOnCall<7){ - surfaceView.setZOrderMediaOverlay(true); - }else{ - surfaceView.setZOrderOnTop(true); - } + surfaceView.setZOrderMediaOverlay(true); GroupCallListener listenerPeer = new GroupCallListener(context, surfaceView, peer.getHandle()); peer.setListener(listenerPeer); From d04ebed7fb8ee5b70457edf28d88ed4334e6e3e1 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 11:21:43 +0100 Subject: [PATCH 136/247] Group call UI --- .../app/lollipop/megachat/ChatActivityLollipop.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index f7eeb13c983..5e7faf842c7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -1699,22 +1699,19 @@ public boolean onPrepareOptionsMenu(Menu menu){ if (permission == MegaChatRoom.PRIV_RO) { clearHistoryMenuItem.setVisible(false); contactInfoMenuItem.setVisible(false); - //callMenuItem.setVisible(false); - //videoMenuItem.setVisible(false); + callMenuItem.setVisible(false); + videoMenuItem.setVisible(false); } else { clearHistoryMenuItem.setVisible(true); contactInfoMenuItem.setTitle(getString(R.string.contact_properties_activity)); contactInfoMenuItem.setVisible(true); - //callMenuItem.setVisible(true); - //videoMenuItem.setVisible(true); + } leaveMenuItem.setVisible(false); } } } }else{ - log("***** J - Chatroom null"); - log("Chatroom NULL on create menu"); leaveMenuItem.setVisible(false); callMenuItem.setVisible(false); From 051d99383c03ea583d67222d97228995b6ca7ce2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 15:00:07 +0100 Subject: [PATCH 137/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 48 ++++++++++--------- .../chatAdapters/GroupCallAdapter.java | 38 +++++---------- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 777fd20631a..96965421a88 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1963,8 +1963,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerView.setColumnWidth((int) widthScreenPX); int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); adapterGrid.notifyItemInserted(posInserted); -// adapterGrid.notifyDataSetChanged(); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); // updateSubtitleToolbar(); }else { @@ -1973,8 +1973,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); recyclerView.setColumnWidth((int) widthScreenPX / 2); adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); -// adapterGrid.notifyDataSetChanged(); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); // updateSubtitleToolbar(); } else { recyclerViewLayout.setPadding(0, 0, 0, 0); @@ -2044,9 +2044,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - -// adapterGrid.notifyDataSetChanged(); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); // updateSubtitleToolbar(); } else { if(peersOnCall.size() == 6){ @@ -2054,9 +2053,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX/2); adapterGrid.notifyItemRemoved(i); - adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - -// adapterGrid.notifyDataSetChanged(); +// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); + adapterGrid.notifyDataSetChanged(); // updateSubtitleToolbar(); }else{ if(peersOnCall.size() == 4){ @@ -2152,7 +2150,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ for(int i=0; i "+peer.getName()+", userSelected: "+peerSelected.getName()); + log("itemClicked-> userSelected: "+peerSelected.getName()); if(peerSelected.getHandle() == peer.getHandle()){ //I touched the same user that is now in big fragment: if(isManualMode){ isManualMode = false; - if(adapterList!=null){ - adapterList.updateMode(false); - } log("manual mode - False"); }else{ isManualMode = true; - if(adapterList!=null){ - adapterList.updateMode(true); - } log("manual mode - True"); + + } + if(adapterList!=null){ + adapterList.updateMode(isManualMode); + for(int i=0;i removeAllViews && removeAllViewsInLayout && addView && setSizeFromLayout && h(0)w(0)"); - + log("peer: "+peer.getHandle()+", VIDEO ON- listener == null "); holder.parentSurfaceView.removeAllViews(); - holder.parentSurfaceView.removeAllViewsInLayout(); SurfaceView surfaceView = new SurfaceView(context); surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); @@ -419,7 +417,6 @@ public void onClick(View v) { holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -435,7 +432,7 @@ public void onClick(View v) { if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 y 2 "); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); @@ -448,10 +445,8 @@ public void onClick(View v) { if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } - - }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 ---> addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); @@ -463,7 +458,7 @@ public void onClick(View v) { } } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 ---> addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ @@ -472,14 +467,10 @@ public void onClick(View v) { if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0"); - if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it's the same -> setSizeFromLayout && h(0)w(0)"); - + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 it is the same"); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); @@ -488,22 +479,19 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same ---->removeAllViews && removeAllViewsInLayout"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same -"); //Remove items of parent holder.parentSurfaceView.removeAllViews(); - holder.parentSurfaceView.removeAllViewsInLayout(); //Remove parent of Surface if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 ---> removeView && addView && setSizeFromLayout && h(0)w(0"); - + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 "); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -511,23 +499,20 @@ public void onClick(View v) { peer.getListener().setWidth(0); } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 -> addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } if(peer.getListener().getWidth() != 0){ peer.getListener().setWidth(0); } - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 ->addView && setSizeFromLayout && h(0)w(0)"); + log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -647,7 +632,6 @@ public void onClick(View v) { log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() != 0"); holder.parentSurfaceView.removeAllViews(); - holder.parentSurfaceView.removeAllViewsInLayout(); if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ @@ -1118,11 +1102,13 @@ public void onDestroy(){ } } }else{ + holder.parentSurfaceView.removeAllViews(); holder.parentSurfaceView.removeAllViewsInLayout(); if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ + ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); } } From 45caf574a1929e4d0dfb9284c260fcab161c5138 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 26 Nov 2018 15:18:36 +0100 Subject: [PATCH 138/247] Group call UI --- .../megachat/calls/BigCameraGroupCallFragment.java | 7 ++----- .../app/lollipop/megachat/calls/ChatCallActivity.java | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index f245def5b6a..f80df58f50b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -55,8 +55,6 @@ public void onCreate (Bundle savedInstanceState){ Bundle args = getArguments(); this.chatId = args.getLong("chatId", -1); this.userHandle = args.getLong("userHandle", -1); -// this.width = 0; -// this.height = 0; super.onCreate(savedInstanceState); log("after onCreate called super"); } @@ -156,10 +154,9 @@ public void onDestroy(){ @Override public void onResume() { log("onResume"); - this.width=0; - this.height=0; + this.width = 0; + this.height = 0; fullScreenSurfaceView.setVisibility(View.VISIBLE); - super.onResume(); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 96965421a88..3e62e017d5d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1570,11 +1570,12 @@ public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaCh log("onRequestFinish: "+request.getType()); if(request.getType() == MegaChatRequest.TYPE_HANG_CHAT_CALL){ + log("onRequestFinish: TYPE_HANG_CHAT_CALL"); + MegaApplication.activityPaused(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); - } - else { + }else { super.finish(); } } From a12eb4e2c64b857acc7014bc688b46840e3cd17f Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 27 Nov 2018 10:12:59 +0100 Subject: [PATCH 139/247] Group Call UI --- .../megachat/calls/ChatCallActivity.java | 421 ++++++++++++------ .../chatAdapters/GroupCallAdapter.java | 151 ++++--- 2 files changed, 392 insertions(+), 180 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 3e62e017d5d..1544d814ade 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -66,6 +66,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import java.io.BufferedOutputStream; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -1657,9 +1658,10 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { log("onChatCallUpdate() call.getChatid() = chatId = "+chatId); if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){ - log("CHANGE_TYPE_STATUS"); int callStatus = callChat.getStatus(); + log("onChatCallUpdate()-CHANGE_TYPE_STATUS -> status: "+callStatus); + switch (callStatus){ case MegaChatCall.CALL_STATUS_IN_PROGRESS:{ @@ -1812,6 +1814,7 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ log("CHANGE_TYPE_SESSION_STATUS"); + log("onChatCallUpdate()-CHANGE_TYPE_SESSION_STATUS"); if(chat.isGroup()){ @@ -1864,8 +1867,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){ updateRemoteAudioStatus(-1); } } - } - else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ + }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_LOCAL_AVFLAGS"); updateLocalVideoStatus(); updateLocalAudioStatus(); @@ -1875,8 +1877,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ log("onChatCallUpdate()-CHANGE_TYPE_RINGING_STATUS"); }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_CALL_COMPOSITION)){ + log("CHANGE_TYPE_CALL_COMPOSITION : call.getStatus(): "+call.getStatus()); + if(call.getStatus() == MegaChatCall.CALL_STATUS_RING_IN){ - log("CHANGE_TYPE_CALL_COMPOSITION RING IN -> participants: "+call.getParticipants().size()); + log("CHANGE_TYPE_CALL_COMPOSITION -CALL_STATUS_RING_IN -> participants: "+call.getParticipants().size()); boolean isMe = false; for(int i = 0; i < call.getParticipants().size(); i++){ @@ -1901,7 +1905,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } if(!peerContain){ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,true,null); - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+userPeer.getHandle()+" added"); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+userPeer.getName()+" added"); peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer); changes = true; } @@ -1915,7 +1919,7 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } } if(!peerContained){ - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+peersBeforeCall.get(i).getHandle()+" removed"); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+peersBeforeCall.get(i).getName()+" removed"); peersBeforeCall.remove(i); changes = true; } @@ -1927,177 +1931,340 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){ } }else if(call.getStatus() == MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("CHANGE_TYPE_CALL_COMPOSITION IN PROGRESS -> participants: "+call.getParticipants().size()); - if((peersOnCall != null)&&(peersOnCall.size() != 0)) { - //Get all participant and check it - for (int i = 0; i < call.getParticipants().size(); i++) { - boolean peerContain = false; - long userHandle = call.getParticipants().get(i); - for (InfoPeerGroupCall peerOnCall : peersOnCall) { - if (peerOnCall.getHandle() == userHandle) { - peerContain = true; - break; + log("CHANGE_TYPE_CALL_COMPOSITION -CALL_STATUS_IN_PROGRESS -> participants: "+call.getParticipants().size()); + if(peersOnCall != null){ + if(peersOnCall.size()!=0){ + //Get all participant and check it + for (int i = 0; i < call.getParticipants().size(); i++) { + boolean peerContain = false; + long userHandle = call.getParticipants().get(i); + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle() == userHandle) { + peerContain = true; + break; + } + } + if (!peerContain) { + if (userHandle == megaChatApi.getMyUserHandle()){ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, true,null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+myPeer.getName()+" added"); + peersOnCall.add(myPeer); + updatePeers(true); + } else { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+userPeer.getName()+" added"); + peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); + infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); + infoUsersBar.setAlpha(1); + infoUsersBar.setVisibility(View.VISIBLE); + infoUsersBar.animate().alpha(0).setDuration(4000); + + if(peersOnCall.size() < 7){ + if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + }else{ + if (peersOnCall.size() == 4) { + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + } else { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); + updateSubtitleToolbar(); + } + } + }else{ + updatePeers(true); + } + }else{ + if (adapterList != null) { + if(peersOnCall.size() == 7){ + updatePeers(true); + }else{ + int posInserted=(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterList.notifyItemInserted(posInserted); + adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); + updateUserSelected(true); + updateSubtitleToolbar(); + } + } else { + updatePeers(true); + } + } + + } } } - if (!peerContain) { - if (userHandle == megaChatApi.getMyUserHandle()){ - InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, true,null); - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+myPeer.getHandle()+" added"); - peersOnCall.add(myPeer); - updatePeers(true); - } else { - InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+userPeer.getHandle()+" added"); - peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); - infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); + + for (int i = 0; i < peersOnCall.size(); i++) { + boolean peerContained = false; + for (int j = 0; j < call.getParticipants().size(); j++) { + long userHandle = call.getParticipants().get(j); + if (peersOnCall.get(i).getHandle() == userHandle){ + peerContained = true; + break; + } + } + if (!peerContained) { + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+peersOnCall.get(i).getName()+" removed"); + infoUsersBar.setText(peersOnCall.get(i).getName()+" "+getString(R.string.contact_left_the_call)); infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); infoUsersBar.setAlpha(1); infoUsersBar.setVisibility(View.VISIBLE); infoUsersBar.animate().alpha(0).setDuration(4000); + peersOnCall.remove(i); if (peersOnCall.size() < 7) { - if (adapterGrid != null) { + if (adapterGrid != null) { if (peersOnCall.size() < 4) { - log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> "+peersOnCall.size()+")"); recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX); - int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyItemRemoved(i); adapterGrid.notifyDataSetChanged(); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); -// updateSubtitleToolbar(); - - }else { - if (peersOnCall.size() == 4) { - log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted range(0 -> " + peersOnCall.size() + ")"); - recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX / 2); - adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - adapterGrid.notifyDataSetChanged(); -// updateSubtitleToolbar(); - } else { + updateSubtitleToolbar(); + } else { + if(peersOnCall.size() == 6){ recyclerViewLayout.setPadding(0, 0, 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX / 2); - int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - log("(1-6)COMPOSITION IN PROGRESS, notifyItemInserted POS(" + posInserted + "), range(" + (posInserted - 1) + " -> " + peersOnCall.size() + ") "); - adapterGrid.notifyItemInserted(posInserted); -// adapterGrid.notifyDataSetChanged(); - adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); -// updateSubtitleToolbar(); - + recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + }else{ + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + }else{ + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); + updateSubtitleToolbar(); } } - - }else{ + } else { updatePeers(true); } } else { if (adapterList != null) { - if(peersOnCall.size() == 7){ - log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); - updatePeers(true); - }else{ - int posInserted=(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); - log("(7 +)COMPOSITION IN PROGRESS, notifyItemInserted POS("+(posInserted-1)+"), range("+posInserted+" -> "+peersOnCall.size()+") "); - adapterList.notifyItemInserted(posInserted); -// adapterList.notifyDataSetChanged(); - adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); + if(peersOnCall.size() >= 7){ + adapterList.notifyItemRemoved(i); + adapterList.notifyItemRangeChanged(i, peersOnCall.size()); updateUserSelected(true); -// updateSubtitleToolbar(); + updateSubtitleToolbar(); + }else{ + updatePeers(true); } - } else { - log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); updatePeers(true); } } - } } + }else{ + boolean changes = false; + for(int i=0;i participants: "+call.getParticipants().size()); + if(peersOnCall != null){ + if(peersOnCall.size()!=0){ + //Get all participant and check it + for (int i = 0; i < call.getParticipants().size(); i++) { + boolean peerContain = false; + long userHandle = call.getParticipants().get(i); + for (InfoPeerGroupCall peerOnCall : peersOnCall) { + if (peerOnCall.getHandle() == userHandle) { + peerContain = true; + break; + } + } + if (!peerContain) { + if (userHandle == megaChatApi.getMyUserHandle()){ + InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false, true,null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (joining) "+myPeer.getName()+" added"); + peersOnCall.add(myPeer); + updatePeers(true); + } else { + InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,null); + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (joining) "+userPeer.getName()+" added"); + peersOnCall.add((peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)), userPeer); + infoUsersBar.setText(userPeer.getName()+" "+getString(R.string.contact_joined_the_call)); + infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); + infoUsersBar.setAlpha(1); + infoUsersBar.setVisibility(View.VISIBLE); + infoUsersBar.animate().alpha(0).setDuration(4000); + + if(peersOnCall.size() < 7){ + if (adapterGrid != null) { + if (peersOnCall.size() < 4) { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + }else{ + if (peersOnCall.size() == 4) { + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + adapterGrid.notifyItemInserted(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + } else { + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + int posInserted = (peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterGrid.notifyItemInserted(posInserted); + adapterGrid.notifyItemRangeChanged((posInserted - 1), peersOnCall.size()); + updateSubtitleToolbar(); + } + } + }else{ + updatePeers(true); + } + }else{ + if (adapterList != null) { + if(peersOnCall.size() == 7){ + updatePeers(true); + }else{ + int posInserted=(peersOnCall.size() == 0 ? 0 : (peersOnCall.size() - 1)); + adapterList.notifyItemInserted(posInserted); + adapterList.notifyItemRangeChanged((posInserted-1), peersOnCall.size()); + updateUserSelected(true); + updateSubtitleToolbar(); + } + } else { + updatePeers(true); + } + } + + } } } - if (!peerContained) { - log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (in progress) "+peersOnCall.get(i).getHandle()+" removed"); - infoUsersBar.setText(peersOnCall.get(i).getName()+" "+getString(R.string.contact_left_the_call)); - infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); - infoUsersBar.setAlpha(1); - infoUsersBar.setVisibility(View.VISIBLE); - infoUsersBar.animate().alpha(0).setDuration(4000); - peersOnCall.remove(i); - - if (peersOnCall.size() < 7) { - - if (adapterGrid != null) { - if (peersOnCall.size() < 4) { - log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); - recyclerViewLayout.setPadding(0, 0, 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX); - adapterGrid.notifyItemRemoved(i); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); - adapterGrid.notifyDataSetChanged(); -// updateSubtitleToolbar(); - } else { - if(peersOnCall.size() == 6){ - log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved range( 0-> "+peersOnCall.size()+") "); + + for (int i = 0; i < peersOnCall.size(); i++) { + boolean peerContained = false; + for (int j = 0; j < call.getParticipants().size(); j++) { + long userHandle = call.getParticipants().get(j); + if (peersOnCall.get(i).getHandle() == userHandle){ + peerContained = true; + break; + } + } + if (!peerContained) { + log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (joining) "+peersOnCall.get(i).getName()+" removed"); + infoUsersBar.setText(peersOnCall.get(i).getName()+" "+getString(R.string.contact_left_the_call)); + infoUsersBar.setBackgroundColor(ContextCompat.getColor(this, R.color.accentColor)); + infoUsersBar.setAlpha(1); + infoUsersBar.setVisibility(View.VISIBLE); + infoUsersBar.animate().alpha(0).setDuration(4000); + peersOnCall.remove(i); + + if (peersOnCall.size() < 7) { + + if (adapterGrid != null) { + if (peersOnCall.size() < 4) { recyclerViewLayout.setPadding(0, 0, 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX/2); + recyclerView.setColumnWidth((int) widthScreenPX); adapterGrid.notifyItemRemoved(i); -// adapterGrid.notifyItemRangeChanged(0, peersOnCall.size()); adapterGrid.notifyDataSetChanged(); -// updateSubtitleToolbar(); - }else{ - if(peersOnCall.size() == 4){ - recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); - recyclerView.setColumnWidth((int) widthScreenPX / 2); - }else{ + updateSubtitleToolbar(); + } else { + if(peersOnCall.size() == 6){ recyclerViewLayout.setPadding(0, 0, 0, 0); recyclerView.setColumnWidth((int) widthScreenPX/2); + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyDataSetChanged(); + updateSubtitleToolbar(); + }else{ + if(peersOnCall.size() == 4){ + recyclerViewLayout.setPadding(0, Util.scaleWidthPx(136, outMetrics), 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX / 2); + }else{ + recyclerViewLayout.setPadding(0, 0, 0, 0); + recyclerView.setColumnWidth((int) widthScreenPX/2); + } + adapterGrid.notifyItemRemoved(i); + adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); + updateSubtitleToolbar(); } - log("(1-6) COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); - adapterGrid.notifyItemRemoved(i); -// adapterGrid.notifyDataSetChanged(); - adapterGrid.notifyItemRangeChanged(i, peersOnCall.size()); -// updateSubtitleToolbar(); } - } - } else { - updatePeers(true); - } - } else { - if (adapterList != null) { - if(peersOnCall.size() >= 7){ - log("(7 +)COMPOSITION IN PROGRESS, notifyItemRemoved POS("+i+"), range("+i+" -> "+peersOnCall.size()+") "); - adapterList.notifyItemRemoved(i); -// adapterList.notifyDataSetChanged(); - adapterList.notifyItemRangeChanged(i, peersOnCall.size()); - updateUserSelected(true); -// updateSubtitleToolbar(); - }else{ - log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); + } else { updatePeers(true); } } else { - log("(7 +)COMPOSITION IN PROGRESS, updatePeers"); - updatePeers(true); + if (adapterList != null) { + if(peersOnCall.size() >= 7){ + adapterList.notifyItemRemoved(i); + adapterList.notifyItemRangeChanged(i, peersOnCall.size()); + updateUserSelected(true); + updateSubtitleToolbar(); + }else{ + updatePeers(true); + } + } else { + updatePeers(true); + } } } } + }else{ + boolean changes = false; + for(int i=0;i 0) { + createDefaultUserAvatar(userHandle, holder, fullName, contactMail); + + ChatUserAvatarListener listener = new ChatUserAvatarListener(context, holder, this); + File avatar = null; + + if(contactMail == null){ + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), userHandle + ".jpg"); + }else { + avatar = new File(context.getCacheDir().getAbsolutePath(), userHandle + ".jpg"); + } + }else{ + if (context.getExternalCacheDir() != null){ + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + }else{ + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + } + Bitmap bitmap = null; + if (avatar.exists()){ + if (avatar.length() > 0){ BitmapFactory.Options bOpts = new BitmapFactory.Options(); bOpts.inPurgeable = true; bOpts.inInputShareable = true; bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); - if (bitmap != null) { - holder.avatarImage.setVisibility(View.VISIBLE); - holder.avatarImage.setImageBitmap(bitmap); - holder.avatarInitialLetter.setVisibility(GONE); - }else{ - UserAvatarListener listener = new UserAvatarListener(context); + if (bitmap == null) { avatar.delete(); - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } + + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; } - createDefaultAvatar(userHandle, fullName, holder); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - if(!avatarRequested){ - avatarRequested = true; if (context.getExternalCacheDir() != null){ megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } else{ megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } + }else{ + holder.avatarInitialLetter.setVisibility(GONE); + holder.avatarImage.setVisibility(View.VISIBLE); + holder.avatarImage.setImageBitmap(bitmap); } - createDefaultAvatar(userHandle, fullName, holder); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); - if(!avatarRequested){ - avatarRequested = true; + }else{ + + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; + } + if (context.getExternalCacheDir() != null){ megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ + }else{ megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); } } - createDefaultAvatar(userHandle, fullName, holder); + }else{ + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; + } + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + } } } - //Contact Default avatar - public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGroupCall holder) { - log("createDefaultAvatar"); + + //User Default avatar + public void createDefaultUserAvatar(long userHandle, ViewHolderGroupCall holder, String fullName, String contactMail){ + log("createDefaultUserAvatar()"); Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); if (color != null) { @@ -885,13 +901,42 @@ public void createDefaultAvatar(long userHandle, String fullName, ViewHolderGro }else { radius = defaultAvatar.getHeight() / 2; } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); holder.avatarImage.setVisibility(View.VISIBLE); holder.avatarImage.setImageBitmap(defaultAvatar); - String contactFirstLetter = fullName.charAt(0) + ""; - contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); - holder.avatarInitialLetter.setText(contactFirstLetter); - holder.avatarInitialLetter.setVisibility(View.VISIBLE); + + Display display = ((Activity)context).getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics (); + display.getMetrics(outMetrics); + + boolean setInitialByMail = false; + if (fullName != null){ + if (fullName.trim().length() > 0){ + String firstLetter = fullName.charAt(0) + ""; + firstLetter = firstLetter.toUpperCase(Locale.getDefault()); + holder.avatarInitialLetter.setText(firstLetter); + holder.avatarInitialLetter.setTextColor(Color.WHITE); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + }else{ + setInitialByMail=true; + } + }else{ + setInitialByMail=true; + } + if(setInitialByMail){ + if (contactMail != null){ + if (contactMail.length() > 0){ + String firstLetter = contactMail.charAt(0) + ""; + firstLetter = firstLetter.toUpperCase(Locale.getDefault()); + holder.avatarInitialLetter.setText(firstLetter); + holder.avatarInitialLetter.setTextColor(Color.WHITE); + holder.avatarInitialLetter.setVisibility(View.VISIBLE); + } + } + } +// ((ViewHolderNormalChatList)holder).contactInitialLetter.setTextSize(24); + } public RecyclerView getListFragment() { From 914268da586f6036bb08eb969596185e7ee479e3 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 27 Nov 2018 11:57:07 +0100 Subject: [PATCH 140/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 1544d814ade..d5d5f174f1c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1148,8 +1148,8 @@ protected void onCreate(Bundle savedInstanceState) { } } } - checkPermissionsWriteLog(); if(checkPermissions()){ + checkPermissionsWriteLog(); showInitialFABConfiguration(); } } @@ -2533,18 +2533,15 @@ public void onClick(View v) { } } - public boolean checkPermissionsWriteLog(){ + public void checkPermissionsWriteLog(){ log("checkPermissionsWriteLog()"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean hasWriteLogPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALL_LOG) == PackageManager.PERMISSION_GRANTED); if (!hasWriteLogPermission) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_CALL_LOG}, Constants.WRITE_LOG); - return false; - }else{ - return true; } } - return true; + } public boolean checkPermissions(){ @@ -3305,6 +3302,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in log("REQUEST_CAMERA"); if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if(checkPermissions()){ + checkPermissionsWriteLog(); showInitialFABConfiguration(); } } @@ -3317,6 +3315,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in log("RECORD_AUDIO"); if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if(checkPermissions()){ + checkPermissionsWriteLog(); showInitialFABConfiguration(); } } @@ -3329,11 +3328,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in case Constants.WRITE_LOG: { log("WRITE_LOG"); if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - if(checkPermissionsWriteLog()){ - log("accepted WRITE_LOG permissions"); - }else{ - log("rejected WRITE_LOG permissions"); - } + checkPermissionsWriteLog(); } break; } From a2ea43919868ce2dfbc80687b2706c2c1bf327e5 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 27 Nov 2018 14:52:28 +0100 Subject: [PATCH 141/247] Group calls UI --- .../megachat/calls/MegaSurfaceRenderer.java | 33 +++-- .../calls/MegaSurfaceRendererGroup.java | 131 ++++++++++++++++-- 2 files changed, 139 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java index 96c6b0769f9..78166569687 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java @@ -37,6 +37,7 @@ import org.webrtc.Logging; import mega.privacy.android.app.R; +import mega.privacy.android.app.utils.Util; public class MegaSurfaceRenderer implements Callback { @@ -59,7 +60,7 @@ public class MegaSurfaceRenderer implements Callback { public MegaSurfaceRenderer(SurfaceView view) { - Log.d("MegaSurfaceRenderer","MegaSurfaceRenderer() "); + log("MegaSurfaceRenderer() "); // this.surf = view; surfaceHolder = view.getHolder(); @@ -73,7 +74,7 @@ public MegaSurfaceRenderer(SurfaceView view) { // surfaceChanged and surfaceCreated share this function private void changeDestRect(int dstWidth, int dstHeight) { - Log.d("MegaSurfaceRenderer","changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); + log("changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); surfaceWidth = dstWidth; surfaceHeight = dstHeight; dstRect.top = 0; @@ -86,6 +87,7 @@ private void changeDestRect(int dstWidth, int dstHeight) { } private void adjustAspectRatio() { + log("adjustAspectRatio(): "); if (bitmap != null && dstRect.height() != 0) { dstRect.top = 0; @@ -118,7 +120,7 @@ private void adjustAspectRatio() { public void surfaceCreated(SurfaceHolder holder) { - Log.d("MegaSurfaceRenderer","surfaceCreated()"); + log("surfaceCreated(): "); Canvas canvas = surfaceHolder.lockCanvas(); if(canvas != null) { @@ -144,7 +146,7 @@ public void surfaceCreated(SurfaceHolder holder) { } public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - Log.d("MegaSurfaceRenderer","surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); changeDestRect(in_width, in_height); @@ -162,7 +164,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i } public void surfaceDestroyed(SurfaceHolder holder) { - Log.d("MegaSurfaceRenderer","surfaceDestroyed(): "); + log("surfaceDestroyed():"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); bitmap = null; @@ -170,7 +172,8 @@ public void surfaceDestroyed(SurfaceHolder holder) { } public Bitmap CreateBitmap(int width, int height) { - Log.d("MegaSurfaceRenderer","CreateBitmap(): width = "+width+", height = "+height); + log("CreateBitmap(): width = "+width+", height = "+height); + Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); if (bitmap == null) { @@ -187,12 +190,17 @@ public Bitmap CreateBitmap(int width, int height) { srcRect.bottom = height; srcRect.right = width; + log("CreateBitmap(): sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + + adjustAspectRatio(); return bitmap; } public ByteBuffer CreateByteBuffer(int width, int height) { + log("CreateByteBuffer(): width = "+width+", height = "+height); + Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); if (bitmap == null) { bitmap = CreateBitmap(width, height); @@ -203,12 +211,13 @@ public ByteBuffer CreateByteBuffer(int width, int height) { // It saves bitmap data to a JPEG picture, this function is for debug only. private void saveBitmapToJPEG(int width, int height) { + log("saveBitmapToJPEG(): width = "+width+", height = "+height); + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); try{ - FileOutputStream output = new FileOutputStream(String.format( - "/sdcard/render_%d.jpg", System.currentTimeMillis())); + FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); output.write(byteOutStream.toByteArray()); output.flush(); output.close(); @@ -220,6 +229,8 @@ private void saveBitmapToJPEG(int width, int height) { } public void DrawByteBuffer() { + log("DrawByteBuffer(): "); + if(byteBuffer == null) return; byteBuffer.rewind(); @@ -235,11 +246,9 @@ public void DrawBitmap(boolean flag) { if (surfaceHolder == null){ return; } - Canvas canvas = surfaceHolder.lockCanvas(); if (canvas != null) { canvas.scale(-1, 1); -// canvas.translate(-dstRect.width(), 0); canvas.translate(-canvas.getWidth(), 0); if (flag) { paint.reset(); @@ -255,6 +264,10 @@ public void DrawBitmap(boolean flag) { } } + private static void log(String log) { + Util.log("MegaSurfaceRendererGroup", log); + } + public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index a98055f4096..ee148b8bc55 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -87,6 +87,7 @@ public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { public MegaSurfaceRendererGroup(SurfaceView view, Long handle) { + log("MegaSurfaceRendererGroup(): "); surfaceHolder = view.getHolder(); if(surfaceHolder == null) @@ -110,8 +111,44 @@ private void changeDestRect(int dstWidth, int dstHeight) { dstRect.right = dstWidth; dstRect.bottom = dstHeight; dstRectf = new RectF(dstRect); + + adjustAspectRatio(); + + } + + private void adjustAspectRatio() { + log("adjustAspectRatio()"); + + if (bitmap != null && dstRect.height() != 0) { + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = surfaceWidth; + dstRect.bottom = surfaceHeight; + + dstRectf = new RectF(dstRect); + float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); + float dstaspectratio = (float) dstRect.width() / dstRect.height(); + + if (srcaspectratio != 0 && dstaspectratio != 0) { + if (srcaspectratio > dstaspectratio) { + float newHeight = dstRect.width() / srcaspectratio; + float decrease = dstRect.height() - newHeight; + dstRect.top += decrease / 2; + dstRect.bottom -= decrease / 2; + dstRectf = new RectF(dstRect); + } else { + float newWidth = dstRect.height() * srcaspectratio; + float decrease = dstRect.width() - newWidth; + dstRect.left += decrease / 2; + dstRect.right -= decrease / 2; + dstRectf = new RectF(dstRect); + } + } + } } + + public void surfaceCreated(SurfaceHolder holder) { log("surfaceCreated()"); Canvas canvas = holder.lockCanvas(); @@ -138,6 +175,7 @@ public void surfaceCreated(SurfaceHolder holder) { } } + public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); @@ -156,6 +194,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int i " dstRect.bottom:" + dstRect.bottom); } + public void surfaceDestroyed(SurfaceHolder holder) { log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); @@ -165,6 +204,8 @@ public void surfaceDestroyed(SurfaceHolder holder) { surfaceHeight = 0; } + + public Bitmap CreateBitmap(int width, int height) { log("CreateBitmap(): width = "+width+", height = "+height); @@ -184,34 +225,79 @@ public Bitmap CreateBitmap(int width, int height) { srcRect.bottom = height; srcRect.left = 0; srcRect.right = width; - log("CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + log(" CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); }else if(height > width){ - int newHeight = width; - bitmap = Bitmap.createBitmap(width, newHeight, Bitmap.Config.ARGB_8888); + bitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); srcRect.top = 0; - srcRect.bottom = newHeight; + srcRect.bottom = width; srcRect.left = 0; srcRect.right = width; log("CreateBitmap(): height > width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); }else{ - log("CreateBitmap(): height < width"); - int newWidth = height; - bitmap = Bitmap.createBitmap(newWidth, height, Bitmap.Config.ARGB_8888); +// bitmap = Bitmap.createBitmap(height, height, Bitmap.Config.ARGB_8888); +// srcRect.left = 0; +// srcRect.right = height; +// srcRect.top = 0; +// srcRect.bottom = height; +// log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); srcRect.left = 0; - srcRect.right = newWidth; + srcRect.right = width; srcRect.top = 0; srcRect.bottom = height; log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); } + + adjustAspectRatio(); return bitmap; } + public ByteBuffer CreateByteBuffer(int width, int height) { + log("CreateByteBuffer(): width = "+width+", height = "+height); + + Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); + if (bitmap == null) { + bitmap = CreateBitmap(width, height); + byteBuffer = ByteBuffer.allocateDirect(width * height * 2); + } + return byteBuffer; + } + + // It saves bitmap data to a JPEG picture, this function is for debug only. + private void saveBitmapToJPEG(int width, int height) { + log("saveBitmapToJPEG(): width = "+width+", height = "+height); + + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); + + try{ + FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); + output.write(byteOutStream.toByteArray()); + output.flush(); + output.close(); + } + catch (FileNotFoundException e) { + } + catch (IOException e) { + } + } + + public void DrawByteBuffer() { + if(byteBuffer == null) + return; + byteBuffer.rewind(); + bitmap.copyPixelsFromBuffer(byteBuffer); + DrawBitmap(false); + } + + public void DrawBitmap(boolean flag) { if(bitmap == null){ return; @@ -219,7 +305,6 @@ public void DrawBitmap(boolean flag) { if (surfaceHolder == null){ return; } - Canvas canvas = surfaceHolder.lockCanvas(); if (canvas != null) { canvas.scale(-1, 1); @@ -236,32 +321,48 @@ public void DrawBitmap(boolean flag) { surfaceHolder.unlockCanvasAndPost(canvas); } } + public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + + final Paint paint = new Paint(); + final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); + final RectF rectF = new RectF(rect); + final float roundPx = pixels; + + paint.setAntiAlias(true); + canvas.drawARGB(0, 0, 0, 0); + paint.setColor(Color.BLUE); + canvas.drawRoundRect(rectF, roundPx, roundPx, paint); + + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); + canvas.drawBitmap(bitmap, rect, rect, paint); + + return output; + } + + private static void log(String log) { Util.log("MegaSurfaceRendererGroup", log); } private void notifyStateToAll() { - log("notifyStateToAll()"); for(MegaSurfaceRendererGroupListener listener : listeners) notifyState(listener); } public void addListener(MegaSurfaceRendererGroupListener l) { - log("addListener()"); - listeners.add(l); notifyState(l); } private void notifyState(MegaSurfaceRendererGroupListener listener) { - log("notifyState()"); - if(listener == null) return; listener.resetSize(handleUser); } public interface MegaSurfaceRendererGroupListener { - public void resetSize(Long handle); + void resetSize(Long handle); } } From 4a35439ceaeb2872e8c27c5f65df43d1be19250b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 27 Nov 2018 15:11:59 +0100 Subject: [PATCH 142/247] Group calls UI --- .../calls/MegaSurfaceRendererGroup.java | 36 +------------------ 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index ee148b8bc55..17f890cb4ce 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -124,26 +124,6 @@ private void adjustAspectRatio() { dstRect.left = 0; dstRect.right = surfaceWidth; dstRect.bottom = surfaceHeight; - - dstRectf = new RectF(dstRect); - float srcaspectratio = (float) bitmap.getWidth() / bitmap.getHeight(); - float dstaspectratio = (float) dstRect.width() / dstRect.height(); - - if (srcaspectratio != 0 && dstaspectratio != 0) { - if (srcaspectratio > dstaspectratio) { - float newHeight = dstRect.width() / srcaspectratio; - float decrease = dstRect.height() - newHeight; - dstRect.top += decrease / 2; - dstRect.bottom -= decrease / 2; - dstRectf = new RectF(dstRect); - } else { - float newWidth = dstRect.height() * srcaspectratio; - float decrease = dstRect.width() - newWidth; - dstRect.left += decrease / 2; - dstRect.right -= decrease / 2; - dstRectf = new RectF(dstRect); - } - } } } @@ -219,17 +199,13 @@ public Bitmap CreateBitmap(int width, int height) { } if(height == width){ - bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); srcRect.top = 0; srcRect.bottom = height; srcRect.left = 0; srcRect.right = width; log(" CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - - }else if(height > width){ - bitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); srcRect.top = 0; srcRect.bottom = width; @@ -238,23 +214,13 @@ public Bitmap CreateBitmap(int width, int height) { log("CreateBitmap(): height > width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); }else{ - -// bitmap = Bitmap.createBitmap(height, height, Bitmap.Config.ARGB_8888); -// srcRect.left = 0; -// srcRect.right = height; -// srcRect.top = 0; -// srcRect.bottom = height; -// log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); srcRect.left = 0; - srcRect.right = width; + srcRect.right = height; srcRect.top = 0; srcRect.bottom = height; log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - } - adjustAspectRatio(); return bitmap; } From ff1fd833d5ec3e2ce53b59531e1f43b7f429ebbe Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 28 Nov 2018 11:47:53 +0100 Subject: [PATCH 143/247] Group calls UI --- .../megachat/calls/ChatCallActivity.java | 179 ++++++++++++------ 1 file changed, 125 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index f586377fbd0..8d67242fd9c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -39,6 +39,7 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.graphics.Palette; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -84,6 +85,7 @@ import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.CustomizedGridCallRecyclerView; import mega.privacy.android.app.lollipop.LoginActivityLollipop; +import mega.privacy.android.app.lollipop.listeners.ChatUserAvatarListener; import mega.privacy.android.app.lollipop.listeners.UserAvatarListener; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; import mega.privacy.android.app.lollipop.megachat.chatAdapters.GroupCallAdapter; @@ -1649,6 +1651,40 @@ else if(request.getType() == MegaChatRequest.TYPE_DISABLE_AUDIO_VIDEO_CALL){ log("Error changing audio or video: "+e.getErrorString()); // showSnackbar(getString(R.string.clear_history_error)); } + }if (request.getType() == MegaRequest.TYPE_GET_ATTR_USER) { + + log("MegaRequest.TYPE_GET_ATTR_USER"); + if (e.getErrorCode() == MegaError.API_OK) { + + +// File avatar = null; +// if (getExternalCacheDir() != null) { +// avatar = new File(getExternalCacheDir().getAbsolutePath(), request.getC + ".jpg"); +// } else { +// avatar = new File(getCacheDir().getAbsolutePath(), request.getEmail() + ".jpg"); +// } +// Bitmap imBitmap = null; +// if (avatar.exists()) { +// if (avatar.length() > 0) { +// BitmapFactory.Options bOpts = new BitmapFactory.Options(); +// bOpts.inPurgeable = true; +// bOpts.inInputShareable = true; +// imBitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); +// if (imBitmap == null) { +// avatar.delete(); +// } else { +// contactPropertiesImage.setImageBitmap(imBitmap); +// imageGradient.setVisibility(View.VISIBLE); +// +// if (imBitmap != null && !imBitmap.isRecycled()) { +// Palette palette = Palette.from(imBitmap).generate(); +// Palette.Swatch swatch = palette.getDarkVibrantSwatch(); +// imageLayout.setBackgroundColor(swatch.getBodyTextColor()); +// } +// } +// } +// } + } } } @@ -4024,86 +4060,93 @@ public void createBigAvatar(Long handle, String fullName){ } public void setProfileContactAvatarGroupCall(long userHandle, String fullName){ - log("setProfileContactAvatarGroupCall"); - Bitmap bitmap = null; - File avatar = null; + log("setProfileContactAvatarGroupCall: "+fullName); + String contactMail = megaChatApi.getContactEmail(userHandle); - if (context.getExternalCacheDir() != null) { - avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } else { - avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); - } - if (avatar.exists()) { - if (avatar.length() > 0) { + createDefaultAvatarGroupCall(userHandle, fullName, contactMail); + + File avatar = null; + + if(contactMail == null){ + if (context.getExternalCacheDir() != null) { + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), userHandle + ".jpg"); + }else { + avatar = new File(context.getCacheDir().getAbsolutePath(), userHandle + ".jpg"); + } + }else{ + if (context.getExternalCacheDir() != null){ + avatar = new File(context.getExternalCacheDir().getAbsolutePath(), contactMail + ".jpg"); + }else{ + avatar = new File(context.getCacheDir().getAbsolutePath(), contactMail + ".jpg"); + } + } + Bitmap bitmap = null; + if (avatar.exists()){ + if (avatar.length() > 0){ BitmapFactory.Options bOpts = new BitmapFactory.Options(); bOpts.inPurgeable = true; bOpts.inInputShareable = true; bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts); - bitmap = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, bitmap, 3); - if (bitmap != null) { - avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE); - avatarBigCameraGroupCallImage.setImageBitmap(bitmap); - avatarBigCameraGroupCallInitialLetter.setVisibility(GONE); - }else{ - UserAvatarListener listener = new UserAvatarListener(context); + if (bitmap == null) { avatar.delete(); - if(!avatarRequested){ - avatarRequested = true; - if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - } - createDefaultAvatarGroupCall(userHandle, fullName); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; + } - if(!avatarRequested){ - avatarRequested = true; if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); } else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); } + }else{ + avatarBigCameraGroupCallInitialLetter.setVisibility(GONE); + avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE); + avatarBigCameraGroupCallImage.setImageBitmap(bitmap); } + }else{ - createDefaultAvatarGroupCall(userHandle, fullName); - } - }else{ - UserAvatarListener listener = new UserAvatarListener(context); + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; + } - if(!avatarRequested){ - avatarRequested = true; if (context.getExternalCacheDir() != null){ - megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); - } - else{ - megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", listener); + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); + }else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); } } - createDefaultAvatarGroupCall(userHandle, fullName); + }else{ + if(megaApi==null){ + log("setUserAvatar: megaApi is Null in Offline mode"); + return; + } + if (context.getExternalCacheDir() != null){ + megaApi.getUserAvatar(contactMail, context.getExternalCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); + } + else{ + megaApi.getUserAvatar(contactMail, context.getCacheDir().getAbsolutePath() + "/" + contactMail + ".jpg", this); + } } } - public void createDefaultAvatarGroupCall(long userHandle, String fullName) { - log("createDefaultAvatarGroupCall"); + public void createDefaultAvatarGroupCall(long userHandle, String fullName, String contactMail) { + log("createDefaultAvatarGroupCall: "); + Bitmap defaultAvatar = Bitmap.createBitmap(outMetrics.widthPixels, outMetrics.widthPixels, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(defaultAvatar); Paint p = new Paint(); p.setAntiAlias(true); - p.setColor(Color.TRANSPARENT); String color = megaApi.getUserAvatarColor(MegaApiAndroid.userHandleToBase64(userHandle)); if (color != null) { p.setColor(Color.parseColor(color)); - }else{ - p.setColor(ContextCompat.getColor(this, R.color.lollipop_primary_color)); + } else { + p.setColor(ContextCompat.getColor(context, R.color.lollipop_primary_color)); } int radius; @@ -4112,12 +4155,40 @@ public void createDefaultAvatarGroupCall(long userHandle, String fullName) { }else { radius = defaultAvatar.getHeight() / 2; } + c.drawCircle(defaultAvatar.getWidth()/2, defaultAvatar.getHeight()/2, radius, p); + avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE); avatarBigCameraGroupCallImage.setImageBitmap(defaultAvatar); - String contactFirstLetter = fullName.charAt(0) + ""; - contactFirstLetter = contactFirstLetter.toUpperCase(Locale.getDefault()); - avatarBigCameraGroupCallInitialLetter.setText(contactFirstLetter); - avatarBigCameraGroupCallInitialLetter.setVisibility(View.VISIBLE); + + Display display = getWindowManager().getDefaultDisplay(); + outMetrics = new DisplayMetrics (); + display.getMetrics(outMetrics); + + boolean setInitialByMail = false; + if (fullName != null){ + if (fullName.trim().length() > 0){ + String firstLetter = fullName.charAt(0) + ""; + firstLetter = firstLetter.toUpperCase(Locale.getDefault()); + avatarBigCameraGroupCallInitialLetter.setText(firstLetter); + avatarBigCameraGroupCallInitialLetter.setTextColor(Color.WHITE); + avatarBigCameraGroupCallInitialLetter.setVisibility(View.VISIBLE); + }else{ + setInitialByMail=true; + } + }else{ + setInitialByMail=true; + } + if(setInitialByMail){ + if (contactMail != null){ + if (contactMail.length() > 0){ + String firstLetter = contactMail.charAt(0) + ""; + firstLetter = firstLetter.toUpperCase(Locale.getDefault()); + avatarBigCameraGroupCallInitialLetter.setText(firstLetter); + avatarBigCameraGroupCallInitialLetter.setTextColor(Color.WHITE); + avatarBigCameraGroupCallInitialLetter.setVisibility(View.VISIBLE); + } + } + } } public void clearHandlers(){ From 609505dc0c8bfbd83ce0749c86e8d743c73f7d95 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 28 Nov 2018 12:12:21 +0100 Subject: [PATCH 144/247] Group calls UI, textureView element --- app/src/main/AndroidManifest.xml | 1 + .../lollipop/listeners/GroupCallListener.java | 46 ++- .../calls/BigCameraGroupCallFragment.java | 4 +- .../calls/MegaSurfaceRendererGroup.java | 113 +++--- .../calls/MegaSurfaceRendererGroupBig.java | 324 ++++++++++++++++++ .../chatAdapters/GroupCallAdapter.java | 57 +-- 6 files changed, 399 insertions(+), 146 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a37dbd22000..f4262c91130 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,7 @@ android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" + android:hardwareAccelerated="true" android:theme="@style/Theme.Megaactionbar" > viewHeight) { - if (Sholder != null) { - int viewWidth = surfaceView.getWidth(); - int viewHeight = surfaceView.getHeight(); - - if ((viewWidth != 0) && (viewHeight != 0)) { - int holderWidth = viewWidth < width ? viewWidth : width; - int holderHeight = holderWidth * viewHeight / viewWidth; - if (holderHeight > viewHeight) { - - holderHeight = viewHeight; - holderWidth = holderHeight * viewWidth / viewHeight; - } - this.bitmap = localRenderer.CreateBitmap(width, height); - Sholder.setFixedSize(holderWidth, holderHeight); - }else{ - this.width = -1; - this.height = -1; + holderHeight = viewHeight; + holderWidth = holderHeight * viewWidth / viewHeight; } + this.bitmap = localRenderer.CreateBitmap(width, height); + }else{ + this.width = -1; + this.height = -1; } + } if (bitmap != null) { bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(byteBuffer)); - // Instead of using this WebRTC renderer, we should probably draw the image by ourselves. // The renderer has been modified a bit and an update of WebRTC could break our app localRenderer.DrawBitmap(false); } } - public SurfaceView getSurfaceView() { - return surfaceView; + public TextureView getSurfaceView() { + return myTexture; } public MegaSurfaceRendererGroup getLocalRenderer() { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index f80df58f50b..666bf9831ed 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -32,7 +32,7 @@ public class BigCameraGroupCallFragment extends Fragment implements MegaChatVide Long userHandle; public SurfaceView fullScreenSurfaceView; - MegaSurfaceRendererGroup renderer; + MegaSurfaceRendererGroupBig renderer; public static BigCameraGroupCallFragment newInstance(long chatId, long userHandle) { log("newInstance"); @@ -74,7 +74,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa SurfaceHolder localSurfaceHolder = fullScreenSurfaceView.getHolder(); localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - renderer = new MegaSurfaceRendererGroup(fullScreenSurfaceView, userHandle); + renderer = new MegaSurfaceRendererGroupBig(fullScreenSurfaceView, userHandle); if(userHandle.equals(megaChatApi.getMyUserHandle())){ log("onCreateView() addChatLocalVideoListener chatId: "+chatId); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index 17f890cb4ce..bad43b4a201 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -17,6 +17,7 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.SurfaceTexture; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -54,20 +55,21 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.SurfaceHolder.Callback; +import android.view.TextureView; import org.webrtc.Logging; import mega.privacy.android.app.R; import mega.privacy.android.app.utils.Util; -public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { +public class MegaSurfaceRendererGroup implements TextureView.SurfaceTextureListener{ private final static String TAG = "WEBRTC"; // the bitmap used for drawing. private Bitmap bitmap = null; private ByteBuffer byteBuffer = null; - private SurfaceHolder surfaceHolder; + private SurfaceTexture surfaceHolder; // Rect of the source bitmap to draw private Rect srcRect = new Rect(); @@ -82,18 +84,16 @@ public class MegaSurfaceRendererGroup implements SurfaceHolder.Callback { int surfaceWidth = 0; int surfaceHeight = 0; Long handleUser; + private TextureView myTexture = null; protected List listeners; - public MegaSurfaceRendererGroup(SurfaceView view, Long handle) { + public MegaSurfaceRendererGroup(TextureView view, Long handle) { log("MegaSurfaceRendererGroup(): "); - surfaceHolder = view.getHolder(); - if(surfaceHolder == null) - return; - - surfaceHolder.addCallback(this); + this.myTexture = view; + myTexture.setSurfaceTextureListener(this); paint = new Paint(); modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); @@ -127,65 +127,6 @@ private void adjustAspectRatio() { } } - - - public void surfaceCreated(SurfaceHolder holder) { - log("surfaceCreated()"); - Canvas canvas = holder.lockCanvas(); - if(canvas != null) { - Rect dst = holder.getSurfaceFrame(); - if(dst != null) { - notifyStateToAll(); - changeDestRect(dst.right - dst.left, dst.bottom - dst.top); - Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + - " dst.left:" + dst.left + - " dst.top:" + dst.top + - " dst.right:" + dst.right + - " dst.bottom:" + dst.bottom + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - } - holder.unlockCanvasAndPost(canvas); - } - } - - - public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); - - Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); - changeDestRect(in_width, in_height); - - Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + - " in_width:" + in_width + " in_height:" + in_height + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - } - - - public void surfaceDestroyed(SurfaceHolder holder) { - log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); - Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); - bitmap = null; - byteBuffer = null; - surfaceWidth = 0; - surfaceHeight = 0; - } - - - public Bitmap CreateBitmap(int width, int height) { log("CreateBitmap(): width = "+width+", height = "+height); @@ -268,10 +209,10 @@ public void DrawBitmap(boolean flag) { if(bitmap == null){ return; } - if (surfaceHolder == null){ + if (myTexture == null){ return; } - Canvas canvas = surfaceHolder.lockCanvas(); + Canvas canvas = myTexture.lockCanvas(); if (canvas != null) { canvas.scale(-1, 1); canvas.translate(-canvas.getWidth(), 0); @@ -284,7 +225,7 @@ public void DrawBitmap(boolean flag) { } else { canvas.drawBitmap(bitmap, srcRect, dstRect, null); } - surfaceHolder.unlockCanvasAndPost(canvas); + myTexture.unlockCanvasAndPost(canvas); } } public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { @@ -328,6 +269,38 @@ private void notifyState(MegaSurfaceRendererGroupListener listener) { listener.resetSize(handleUser); } + @Override + public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int in_width, int in_height) { + log("onSurfaceTextureAvailable()"); + Bitmap textureViewBitmap = myTexture.getBitmap(); + Canvas canvas = new Canvas(textureViewBitmap); + if(canvas != null) { + notifyStateToAll(); + changeDestRect(in_width, in_height); + } + } + + @Override + public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int in_width, int in_height) { + log("onSurfaceTextureSizeChanged(): in_width = "+in_width+", in_height = "+in_height); + changeDestRect(in_width, in_height); + } + + @Override + public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { + log("onSurfaceTextureDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); + bitmap = null; + byteBuffer = null; + surfaceWidth = 0; + surfaceHeight = 0; + return true; + } + + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { + + } + public interface MegaSurfaceRendererGroupListener { void resetSize(Long handle); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java new file mode 100644 index 00000000000..2f45ae6966f --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java @@ -0,0 +1,324 @@ +package mega.privacy.android.app.lollipop.megachat.calls; + +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceView; + +import org.webrtc.Logging; + +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + +// The following four imports are needed saveBitmapToJPEG which +// is for debug only +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.util.Log; +import android.util.TypedValue; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.SurfaceHolder.Callback; + +import org.webrtc.Logging; + +import mega.privacy.android.app.R; +import mega.privacy.android.app.utils.Util; + +public class MegaSurfaceRendererGroupBig implements SurfaceHolder.Callback { + + private final static String TAG = "WEBRTC"; + + // the bitmap used for drawing. + private Bitmap bitmap = null; + private ByteBuffer byteBuffer = null; + private SurfaceHolder surfaceHolder; + + // Rect of the source bitmap to draw + private Rect srcRect = new Rect(); + + // Rect of the destination canvas to draw to + private Rect dstRect = new Rect(); + private RectF dstRectf = new RectF(); + + Paint paint; + PorterDuffXfermode modesrcover; + PorterDuffXfermode modesrcin; + int surfaceWidth = 0; + int surfaceHeight = 0; + Long handleUser; + + protected List listeners; + + + public MegaSurfaceRendererGroupBig(SurfaceView view, Long handle) { + log("MegaSurfaceRendererGroupBig(): "); + + surfaceHolder = view.getHolder(); + if(surfaceHolder == null) + return; + + surfaceHolder.addCallback(this); + paint = new Paint(); + modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); + modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); + this.handleUser = handle; + listeners = new ArrayList(); + } + + // surfaceChanged and surfaceCreated share this function + private void changeDestRect(int dstWidth, int dstHeight) { + log("changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); + surfaceWidth = dstWidth; + surfaceHeight = dstHeight; + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = dstWidth; + dstRect.bottom = dstHeight; + dstRectf = new RectF(dstRect); + + adjustAspectRatio(); + + } + + private void adjustAspectRatio() { + log("adjustAspectRatio()"); + + if (bitmap != null && dstRect.height() != 0) { + dstRect.top = 0; + dstRect.left = 0; + dstRect.right = surfaceWidth; + dstRect.bottom = surfaceHeight; + } + } + + + public void surfaceCreated(SurfaceHolder holder) { + log("surfaceCreated()"); + Canvas canvas = holder.lockCanvas(); + if(canvas != null) { + Rect dst = holder.getSurfaceFrame(); + if(dst != null) { + notifyStateToAll(); + changeDestRect(dst.right - dst.left, dst.bottom - dst.top); + Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + + " dst.left:" + dst.left + + " dst.top:" + dst.top + + " dst.right:" + dst.right + + " dst.bottom:" + dst.bottom + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + } + holder.unlockCanvasAndPost(canvas); + } + } + + + public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { + log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); + changeDestRect(in_width, in_height); + + Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + + " in_width:" + in_width + " in_height:" + in_height + + " srcRect.left:" + srcRect.left + + " srcRect.top:" + srcRect.top + + " srcRect.right:" + srcRect.right + + " srcRect.bottom:" + srcRect.bottom + + " dstRect.left:" + dstRect.left + + " dstRect.top:" + dstRect.top + + " dstRect.right:" + dstRect.right + + " dstRect.bottom:" + dstRect.bottom); + } + + + public void surfaceDestroyed(SurfaceHolder holder) { + log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); + Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); + bitmap = null; + byteBuffer = null; + surfaceWidth = 0; + surfaceHeight = 0; + } + + + + public Bitmap CreateBitmap(int width, int height) { + log("CreateBitmap(): width = "+width+", height = "+height); + + Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); + if (bitmap == null) { + try { + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY); + } + catch (Exception e) { + } + } + + if(height == width){ + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + srcRect.top = 0; + srcRect.bottom = height; + srcRect.left = 0; + srcRect.right = width; + log(" CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + }else if(height > width){ + bitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); + srcRect.top = 0; + srcRect.bottom = width; + srcRect.left = 0; + srcRect.right = width; + log("CreateBitmap(): height > width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + + }else{ + bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + srcRect.left = 0; + srcRect.right = height; + srcRect.top = 0; + srcRect.bottom = height; + log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); + } + adjustAspectRatio(); + return bitmap; + } + + public ByteBuffer CreateByteBuffer(int width, int height) { + log("CreateByteBuffer(): width = "+width+", height = "+height); + + Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); + if (bitmap == null) { + bitmap = CreateBitmap(width, height); + byteBuffer = ByteBuffer.allocateDirect(width * height * 2); + } + return byteBuffer; + } + + // It saves bitmap data to a JPEG picture, this function is for debug only. + private void saveBitmapToJPEG(int width, int height) { + log("saveBitmapToJPEG(): width = "+width+", height = "+height); + + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); + + try{ + FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); + output.write(byteOutStream.toByteArray()); + output.flush(); + output.close(); + } + catch (FileNotFoundException e) { + } + catch (IOException e) { + } + } + + public void DrawByteBuffer() { + if(byteBuffer == null) + return; + byteBuffer.rewind(); + bitmap.copyPixelsFromBuffer(byteBuffer); + DrawBitmap(false); + } + + + public void DrawBitmap(boolean flag) { + if(bitmap == null){ + return; + } + if (surfaceHolder == null){ + return; + } + Canvas canvas = surfaceHolder.lockCanvas(); + if (canvas != null) { + canvas.scale(-1, 1); + canvas.translate(-canvas.getWidth(), 0); + if (flag) { + paint.reset(); + paint.setXfermode(modesrcover); + canvas.drawRoundRect(dstRectf, 20, 20, paint); + paint.setXfermode(modesrcin); + canvas.drawBitmap(bitmap, srcRect, dstRect, paint); + } else { + canvas.drawBitmap(bitmap, srcRect, dstRect, null); + } + surfaceHolder.unlockCanvasAndPost(canvas); + } + } + public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + + final Paint paint = new Paint(); + final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); + final RectF rectF = new RectF(rect); + final float roundPx = pixels; + + paint.setAntiAlias(true); + canvas.drawARGB(0, 0, 0, 0); + paint.setColor(Color.BLUE); + canvas.drawRoundRect(rectF, roundPx, roundPx, paint); + + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); + canvas.drawBitmap(bitmap, rect, rect, paint); + + return output; + } + + + private static void log(String log) { + Util.log("MegaSurfaceRendererGroup", log); + } + + private void notifyStateToAll() { + for(MegaSurfaceRendererGroupListener listener : listeners) + notifyState(listener); + } + + public void addListener(MegaSurfaceRendererGroupListener l) { + listeners.add(l); + notifyState(l); + } + + private void notifyState(MegaSurfaceRendererGroupListener listener) { + if(listener == null) + return; + listener.resetSize(handleUser); + } + + public interface MegaSurfaceRendererGroupListener { + void resetSize(Long handle); + } +} \ No newline at end of file diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index 50d4eafe141..ab52d2bc0fa 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -26,6 +26,7 @@ import android.view.PixelCopy; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.TextureView; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -61,9 +62,6 @@ import nz.mega.sdk.MegaNode; import static android.view.View.GONE; -import static mega.privacy.android.app.utils.Util.context; -import static mega.privacy.android.app.utils.Util.deleteFolderAndSubfolders; -import static mega.privacy.android.app.utils.Util.percScreenLogin; public class GroupCallAdapter extends RecyclerView.Adapter implements MegaSurfaceRendererGroup.MegaSurfaceRendererGroupListener { @@ -403,11 +401,12 @@ public void onClick(View v) { log("peer: "+peer.getHandle()+", VIDEO ON- listener == null "); holder.parentSurfaceView.removeAllViews(); - SurfaceView surfaceView = new SurfaceView(context); - surfaceView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - surfaceView.setZOrderMediaOverlay(true); + TextureView myTexture = new TextureView(context); + myTexture.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); + myTexture.setAlpha(1.0f); + myTexture.setRotation(0); - GroupCallListener listenerPeer = new GroupCallListener(context, surfaceView, peer.getHandle()); + GroupCallListener listenerPeer = new GroupCallListener(context, myTexture, peer.getHandle()); peer.setListener(listenerPeer); if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { @@ -422,13 +421,6 @@ public void onClick(View v) { } holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } }else{ log("peer: "+peer.getHandle()+", VIDEO ON - listener != null"); @@ -443,8 +435,6 @@ public void onClick(View v) { ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -455,29 +445,15 @@ public void onClick(View v) { log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } } }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + } }else{ if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 it is the same"); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -497,7 +473,6 @@ public void onClick(View v) { ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); if(peer.getListener().getHeight() != 0){ peer.getListener().setHeight(0); } @@ -507,24 +482,12 @@ public void onClick(View v) { }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + } }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + } } @@ -1107,8 +1070,6 @@ public void resetSize(Long userHandle) { if(getItemCount()!=0){ for(InfoPeerGroupCall peer:peers){ if(peer.getListener()!=null){ - peer.getListener().getSurfaceView().getHolder().setSizeFromLayout(); - if(peer.getListener().getWidth()!=0){ peer.getListener().setWidth(0); } From 4ba8ee0ac3b3c2d2fc9e27d2d94fe9828ed69047 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 28 Nov 2018 14:36:42 +0100 Subject: [PATCH 145/247] Group call UI textureView element --- .../calls/BigCameraGroupCallFragment.java | 60 +--- .../megachat/calls/ChatCallActivity.java | 5 - .../calls/MegaSurfaceRendererGroupBig.java | 324 ------------------ .../chatAdapters/GroupCallAdapter.java | 25 +- .../fragment_camera_full_screen_big.xml | 13 + 5 files changed, 55 insertions(+), 372 deletions(-) delete mode 100644 app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java create mode 100644 app/src/main/res/layout/fragment_camera_full_screen_big.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java index 666bf9831ed..0968e90f11f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java @@ -9,8 +9,10 @@ import android.view.LayoutInflater; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.TextureView; import android.view.View; import android.view.ViewGroup; +import android.widget.RelativeLayout; import java.nio.ByteBuffer; @@ -31,8 +33,8 @@ public class BigCameraGroupCallFragment extends Fragment implements MegaChatVide long chatId; Long userHandle; - public SurfaceView fullScreenSurfaceView; - MegaSurfaceRendererGroupBig renderer; + public TextureView myTexture; + MegaSurfaceRendererGroup renderer; public static BigCameraGroupCallFragment newInstance(long chatId, long userHandle) { log("newInstance"); @@ -67,14 +69,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return null; } - View v = inflater.inflate(R.layout.fragment_local_camera_call_full_screen, container, false); - - fullScreenSurfaceView = (SurfaceView)v.findViewById(R.id.surface_local_video); - fullScreenSurfaceView.setSecure(true); + View v = inflater.inflate(R.layout.fragment_camera_full_screen_big, container, false); + myTexture = (TextureView) v.findViewById(R.id.texture_view_video); + myTexture.setAlpha(1.0f); + myTexture.setRotation(0); + myTexture.setVisibility(View.VISIBLE); + this.width = 0; + this.height = 0; + renderer = new MegaSurfaceRendererGroup(myTexture, userHandle); - SurfaceHolder localSurfaceHolder = fullScreenSurfaceView.getHolder(); - localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); - renderer = new MegaSurfaceRendererGroupBig(fullScreenSurfaceView, userHandle); if(userHandle.equals(megaChatApi.getMyUserHandle())){ log("onCreateView() addChatLocalVideoListener chatId: "+chatId); @@ -97,10 +100,8 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei this.width = width; this.height = height; - SurfaceHolder holder = fullScreenSurfaceView.getHolder(); - if (holder != null) { - int viewWidth = fullScreenSurfaceView.getWidth(); - int viewHeight = fullScreenSurfaceView.getHeight(); + int viewWidth = myTexture.getWidth(); + int viewHeight = myTexture.getHeight(); if ((viewWidth != 0) && (viewHeight != 0)) { int holderWidth = viewWidth < width ? viewWidth : width; int holderHeight = holderWidth * viewHeight / viewWidth; @@ -109,13 +110,10 @@ public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int hei holderWidth = holderHeight * viewWidth / viewHeight; } this.bitmap = renderer.CreateBitmap(width, height); - holder.setFixedSize(holderWidth, holderHeight); - } - else{ + }else{ this.width = -1; this.height = -1; } - } } if (bitmap != null) { @@ -135,13 +133,12 @@ public void onAttach(Context context) { @Override public void onDestroy(){ log("onDestroy"); - if(fullScreenSurfaceView.getParent()!=null){ - if(fullScreenSurfaceView.getParent().getParent()!=null){ + if(myTexture.getParent()!=null){ + if(myTexture.getParent().getParent()!=null){ log("onDestroy() removeView chatId: "+chatId); - ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); + ((ViewGroup)myTexture.getParent()).removeView(myTexture); } } - fullScreenSurfaceView.setVisibility(View.GONE); if(userHandle.equals(megaChatApi.getMyUserHandle())){ log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId); megaChatApi.removeChatVideoListener(chatId, -1, this); @@ -154,30 +151,9 @@ public void onDestroy(){ @Override public void onResume() { log("onResume"); - this.width = 0; - this.height = 0; - fullScreenSurfaceView.setVisibility(View.VISIBLE); super.onResume(); } - public void removeSurfaceView(){ - log("removeSurfaceView()"); - if(fullScreenSurfaceView.getParent()!=null){ - if(fullScreenSurfaceView.getParent().getParent()!=null){ - log("removeSurfaceView() removeView chatId: "+chatId); - ((ViewGroup)fullScreenSurfaceView.getParent()).removeView(fullScreenSurfaceView); - } - } - fullScreenSurfaceView.setVisibility(View.GONE); - if(userHandle.equals(megaChatApi.getMyUserHandle())){ - log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId); - megaChatApi.removeChatVideoListener(chatId, -1, this); - }else{ - log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+chatId); - megaChatApi.removeChatVideoListener(chatId, userHandle, this); - } - } - private static void log(String log) { Util.log("BigCameraGroupCallFragment", log); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 8d67242fd9c..ee2a6387ff2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1510,7 +1510,6 @@ public void onDestroy(){ } if (bigCameraGroupCallFragment != null) { - bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -3605,7 +3604,6 @@ public void updatePeers(boolean flag){ if (bigCameraGroupCallFragment != null) { log("updatePeers() destroy bigCameraGroupCallFragment)"); - bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -3992,7 +3990,6 @@ public void updateUserSelected(boolean flag){ //First time: //Remove Camera element, because with incoming, avatar is the only showed if (bigCameraGroupCallFragment != null) { - bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -4019,7 +4016,6 @@ public void createBigFragment(Long handle){ //Remove big Camera if(bigCameraGroupCallFragment != null){ log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; @@ -4044,7 +4040,6 @@ public void createBigAvatar(Long handle, String fullName){ //Remove big Camera if (bigCameraGroupCallFragment != null) { log("REMOVE bigCameraGroupCallFragment"); - bigCameraGroupCallFragment.removeSurfaceView(); FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); ftFS.remove(bigCameraGroupCallFragment); bigCameraGroupCallFragment = null; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java deleted file mode 100644 index 2f45ae6966f..00000000000 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroupBig.java +++ /dev/null @@ -1,324 +0,0 @@ -package mega.privacy.android.app.lollipop.megachat.calls; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.util.Log; -import android.view.SurfaceHolder; -import android.view.SurfaceView; - -import org.webrtc.Logging; - -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; - -// The following four imports are needed saveBitmapToJPEG which -// is for debug only -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.util.Log; -import android.util.TypedValue; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.SurfaceHolder.Callback; - -import org.webrtc.Logging; - -import mega.privacy.android.app.R; -import mega.privacy.android.app.utils.Util; - -public class MegaSurfaceRendererGroupBig implements SurfaceHolder.Callback { - - private final static String TAG = "WEBRTC"; - - // the bitmap used for drawing. - private Bitmap bitmap = null; - private ByteBuffer byteBuffer = null; - private SurfaceHolder surfaceHolder; - - // Rect of the source bitmap to draw - private Rect srcRect = new Rect(); - - // Rect of the destination canvas to draw to - private Rect dstRect = new Rect(); - private RectF dstRectf = new RectF(); - - Paint paint; - PorterDuffXfermode modesrcover; - PorterDuffXfermode modesrcin; - int surfaceWidth = 0; - int surfaceHeight = 0; - Long handleUser; - - protected List listeners; - - - public MegaSurfaceRendererGroupBig(SurfaceView view, Long handle) { - log("MegaSurfaceRendererGroupBig(): "); - - surfaceHolder = view.getHolder(); - if(surfaceHolder == null) - return; - - surfaceHolder.addCallback(this); - paint = new Paint(); - modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); - modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); - this.handleUser = handle; - listeners = new ArrayList(); - } - - // surfaceChanged and surfaceCreated share this function - private void changeDestRect(int dstWidth, int dstHeight) { - log("changeDestRect(): dstWidth = "+dstWidth+", dstHeight = "+dstHeight); - surfaceWidth = dstWidth; - surfaceHeight = dstHeight; - dstRect.top = 0; - dstRect.left = 0; - dstRect.right = dstWidth; - dstRect.bottom = dstHeight; - dstRectf = new RectF(dstRect); - - adjustAspectRatio(); - - } - - private void adjustAspectRatio() { - log("adjustAspectRatio()"); - - if (bitmap != null && dstRect.height() != 0) { - dstRect.top = 0; - dstRect.left = 0; - dstRect.right = surfaceWidth; - dstRect.bottom = surfaceHeight; - } - } - - - public void surfaceCreated(SurfaceHolder holder) { - log("surfaceCreated()"); - Canvas canvas = holder.lockCanvas(); - if(canvas != null) { - Rect dst = holder.getSurfaceFrame(); - if(dst != null) { - notifyStateToAll(); - changeDestRect(dst.right - dst.left, dst.bottom - dst.top); - Logging.d(TAG, "ViESurfaceRender::surfaceCreated" + - " dst.left:" + dst.left + - " dst.top:" + dst.top + - " dst.right:" + dst.right + - " dst.bottom:" + dst.bottom + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - } - holder.unlockCanvasAndPost(canvas); - } - } - - - public void surfaceChanged(SurfaceHolder holder, int format, int in_width, int in_height) { - log("surfaceChanged(): in_width = "+in_width+", in_height = "+in_height); - - Logging.d(TAG, "ViESurfaceRender::surfaceChanged"); - changeDestRect(in_width, in_height); - - Logging.d(TAG, "ViESurfaceRender::surfaceChanged" + - " in_width:" + in_width + " in_height:" + in_height + - " srcRect.left:" + srcRect.left + - " srcRect.top:" + srcRect.top + - " srcRect.right:" + srcRect.right + - " srcRect.bottom:" + srcRect.bottom + - " dstRect.left:" + dstRect.left + - " dstRect.top:" + dstRect.top + - " dstRect.right:" + dstRect.right + - " dstRect.bottom:" + dstRect.bottom); - } - - - public void surfaceDestroyed(SurfaceHolder holder) { - log("surfaceDestroyed() -> surfaceWidth = 0 && surfaceHeight = 0"); - Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed"); - bitmap = null; - byteBuffer = null; - surfaceWidth = 0; - surfaceHeight = 0; - } - - - - public Bitmap CreateBitmap(int width, int height) { - log("CreateBitmap(): width = "+width+", height = "+height); - - Logging.d(TAG, "CreateByteBitmap " + width + ":" + height); - if (bitmap == null) { - try { - android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY); - } - catch (Exception e) { - } - } - - if(height == width){ - bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - srcRect.top = 0; - srcRect.bottom = height; - srcRect.left = 0; - srcRect.right = width; - log(" CreateBitmap(): width == height. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - }else if(height > width){ - bitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); - srcRect.top = 0; - srcRect.bottom = width; - srcRect.left = 0; - srcRect.right = width; - log("CreateBitmap(): height > width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - - }else{ - bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - srcRect.left = 0; - srcRect.right = height; - srcRect.top = 0; - srcRect.bottom = height; - log("CreateBitmap(): height < width. sRect(T "+srcRect.top+" -B "+srcRect.bottom+")(L "+srcRect.left+" - R "+srcRect.right+")"); - } - adjustAspectRatio(); - return bitmap; - } - - public ByteBuffer CreateByteBuffer(int width, int height) { - log("CreateByteBuffer(): width = "+width+", height = "+height); - - Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); - if (bitmap == null) { - bitmap = CreateBitmap(width, height); - byteBuffer = ByteBuffer.allocateDirect(width * height * 2); - } - return byteBuffer; - } - - // It saves bitmap data to a JPEG picture, this function is for debug only. - private void saveBitmapToJPEG(int width, int height) { - log("saveBitmapToJPEG(): width = "+width+", height = "+height); - - ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); - - try{ - FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); - output.write(byteOutStream.toByteArray()); - output.flush(); - output.close(); - } - catch (FileNotFoundException e) { - } - catch (IOException e) { - } - } - - public void DrawByteBuffer() { - if(byteBuffer == null) - return; - byteBuffer.rewind(); - bitmap.copyPixelsFromBuffer(byteBuffer); - DrawBitmap(false); - } - - - public void DrawBitmap(boolean flag) { - if(bitmap == null){ - return; - } - if (surfaceHolder == null){ - return; - } - Canvas canvas = surfaceHolder.lockCanvas(); - if (canvas != null) { - canvas.scale(-1, 1); - canvas.translate(-canvas.getWidth(), 0); - if (flag) { - paint.reset(); - paint.setXfermode(modesrcover); - canvas.drawRoundRect(dstRectf, 20, 20, paint); - paint.setXfermode(modesrcin); - canvas.drawBitmap(bitmap, srcRect, dstRect, paint); - } else { - canvas.drawBitmap(bitmap, srcRect, dstRect, null); - } - surfaceHolder.unlockCanvasAndPost(canvas); - } - } - public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { - Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); - final RectF rectF = new RectF(rect); - final float roundPx = pixels; - - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(Color.BLUE); - canvas.drawRoundRect(rectF, roundPx, roundPx, paint); - - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, rect, rect, paint); - - return output; - } - - - private static void log(String log) { - Util.log("MegaSurfaceRendererGroup", log); - } - - private void notifyStateToAll() { - for(MegaSurfaceRendererGroupListener listener : listeners) - notifyState(listener); - } - - public void addListener(MegaSurfaceRendererGroupListener l) { - listeners.add(l); - notifyState(l); - } - - private void notifyState(MegaSurfaceRendererGroupListener listener) { - if(listener == null) - return; - listener.resetSize(handleUser); - } - - public interface MegaSurfaceRendererGroupListener { - void resetSize(Long handle); - } -} \ No newline at end of file diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index ab52d2bc0fa..c56236e1c6e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -443,12 +443,23 @@ public void onClick(View v) { } }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 "); - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } } }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } } }else{ @@ -482,11 +493,23 @@ public void onClick(View v) { }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } } }else{ log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); + } } } diff --git a/app/src/main/res/layout/fragment_camera_full_screen_big.xml b/app/src/main/res/layout/fragment_camera_full_screen_big.xml new file mode 100644 index 00000000000..09b4b0deab6 --- /dev/null +++ b/app/src/main/res/layout/fragment_camera_full_screen_big.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file From 0b93532f630328912b1644b3cf520c1e051ff157 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Wed, 28 Nov 2018 15:51:23 +0100 Subject: [PATCH 146/247] Group call UI textureView element --- app/src/main/AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f4262c91130..a37dbd22000 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,7 +43,6 @@ android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" - android:hardwareAccelerated="true" android:theme="@style/Theme.Megaactionbar" > Date: Thu, 29 Nov 2018 09:37:37 +0100 Subject: [PATCH 147/247] Bug #10619-After entering the data in all the fields in create account page , if the password is unmasked and when click on the submit button without accepting the terms and conditions , the password is not masked --- .../ChangePasswordActivityLollipop.java | 11 +++++++++++ .../CreateAccountFragmentLollipop.java | 18 ++++++++++++++++++ .../app/lollipop/LoginFragmentLollipop.java | 13 +++++++++++++ 3 files changed, 42 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ChangePasswordActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ChangePasswordActivityLollipop.java index b37d10e8bb7..3e4170de1d8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ChangePasswordActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ChangePasswordActivityLollipop.java @@ -805,11 +805,22 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } + void hidePasswordIfVisible () { + if (passwdVisibility) { + passwdVisibility = false; + toggleButtonNewPasswd.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_b_shared_read)); + showHidePassword(R.id.toggle_button_new_passwd); + toggleButtonNewPasswd2.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_b_shared_read)); + showHidePassword(R.id.toggle_button_new_passwd2); + } + } + @Override public void onClick(View v) { log("onClick"); switch(v.getId()){ case R.id.action_change_password: { + hidePasswordIfVisible(); if (changePassword) { log("ok proceed to change"); onChangePasswordClick(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/CreateAccountFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/CreateAccountFragmentLollipop.java index 0b166dac8b1..3bfd7ee329b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/CreateAccountFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/CreateAccountFragmentLollipop.java @@ -322,6 +322,7 @@ public void onFocusChange(View v, boolean hasFocus) { tos.setOnClickListener(this); chkTOS = (CheckBox) v.findViewById(R.id.create_account_chkTOS); + chkTOS.setOnClickListener(this); bRegister = (Button) v.findViewById(R.id.button_create_account_create); bRegister.setText(getString(R.string.create_account)); @@ -495,16 +496,32 @@ public void showHidePassword (boolean confirm) { } } + void hidePasswordIfVisible () { + if (passwdVisibility) { + passwdVisibility = false; + toggleButtonPasswd.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_b_shared_read)); + showHidePassword(false); + toggleButtonConfirmPasswd.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_b_shared_read)); + showHidePassword(true); + } + } + @Override public void onClick(View v) { log("onClick"); switch (v.getId()) { + case R.id.create_account_chkTOS: + hidePasswordIfVisible(); + break; + case R.id.button_create_account_create: + hidePasswordIfVisible(); onCreateAccountClick(v); break; case R.id.button_login_create: + hidePasswordIfVisible(); ((LoginActivityLollipop) context).showFragment(Constants.LOGIN_FRAGMENT); break; @@ -515,6 +532,7 @@ public void onClick(View v) { // browserIntent.setDataAndType(Uri.parse("http://www.google.es"), "text/html"); // browserIntent.addCategory(Intent.CATEGORY_BROWSABLE); // startActivity(browserIntent); + hidePasswordIfVisible(); try { String url = "https://mega.nz/terms"; Intent openTermsIntent = new Intent(context, WebViewActivityLollipop.class); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java index 8c646cc9201..472e5378bf9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java @@ -1645,6 +1645,14 @@ private String getPasswordError() { return null; } + void hidePasswordIfVisible () { + if (passwdVisibility) { + toggleButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_b_shared_read)); + passwdVisibility = false; + showHidePassword(); + } + } + @Override public void onClick(View v) { @@ -1652,12 +1660,14 @@ public void onClick(View v) { switch(v.getId()) { case R.id.button_login_login: { log("click on button_login_login"); + hidePasswordIfVisible(); loginClicked = true; onLoginClick(v); break; } case R.id.button_create_account_login:{ log("click on button_create_account_login"); + hidePasswordIfVisible(); onRegisterClick(v); break; } @@ -1668,6 +1678,7 @@ public void onClick(View v) { } case R.id.button_forgot_pass:{ log("click on button_forgot_pass"); + hidePasswordIfVisible(); try { String url = "https://mega.nz/recovery"; Intent openTermsIntent = new Intent(context, WebViewActivityLollipop.class); @@ -1694,6 +1705,7 @@ public void onClick(View v) { break; } case R.id.login_text_view:{ + hidePasswordIfVisible(); numberOfClicksKarere++; if (numberOfClicksKarere == 5){ MegaAttributes attrs = dbH.getAttributes(); @@ -1727,6 +1739,7 @@ public void onClick(View v) { break; } case R.id.text_newToMega:{ + hidePasswordIfVisible(); numberOfClicksSDK++; if (numberOfClicksSDK == 5){ MegaAttributes attrs = dbH.getAttributes(); From a7d9124df0733170bca3ac6dca7159ee12523ea5 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 11:05:35 +0100 Subject: [PATCH 148/247] Group call UI --- .../lollipop/listeners/GroupCallListener.java | 2 + .../megachat/calls/ChatCallActivity.java | 28 ++--- .../calls/MegaSurfaceRendererGroup.java | 108 ++++++++---------- .../chatAdapters/GroupCallAdapter.java | 81 ++----------- 4 files changed, 63 insertions(+), 156 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java index bd13183cdfd..7bfbb3c93c4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java @@ -37,8 +37,10 @@ public GroupCallListener(Context context, TextureView myTexture, Long peerHandle this.localRenderer = new MegaSurfaceRendererGroup(myTexture, peerHandle); } + @Override public void onChatVideoData(MegaChatApiJava api, long chatid, int width, int height, byte[] byteBuffer) { + if((width == 0) || (height == 0)){ return; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index ee2a6387ff2..a23cbd98e14 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1435,35 +1435,21 @@ public void onPause(){ @Override protected void onResume() { log("onResume()"); + super.onResume(); if(peersOnCall!=null){ if(peersOnCall.size()!=0){ - if(peersOnCall.size()<7){ - for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListener()!=null){ - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + for(InfoPeerGroupCall peer :peersOnCall){ + if(peer.getListener()!=null){ + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); } - } - }else{ - for(InfoPeerGroupCall peer :peersOnCall){ - if(peer.getListener()!=null){ - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); } } } - } } - super.onResume(); // adapter.notifyDataSetChanged(); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java index bad43b4a201..51ed2d23bac 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java @@ -12,6 +12,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; @@ -94,6 +95,7 @@ public MegaSurfaceRendererGroup(TextureView view, Long handle) { this.myTexture = view; myTexture.setSurfaceTextureListener(this); + bitmap = myTexture.getBitmap(); paint = new Paint(); modesrcover = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); modesrcin = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); @@ -166,45 +168,6 @@ public Bitmap CreateBitmap(int width, int height) { return bitmap; } - public ByteBuffer CreateByteBuffer(int width, int height) { - log("CreateByteBuffer(): width = "+width+", height = "+height); - - Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); - if (bitmap == null) { - bitmap = CreateBitmap(width, height); - byteBuffer = ByteBuffer.allocateDirect(width * height * 2); - } - return byteBuffer; - } - - // It saves bitmap data to a JPEG picture, this function is for debug only. - private void saveBitmapToJPEG(int width, int height) { - log("saveBitmapToJPEG(): width = "+width+", height = "+height); - - ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); - - try{ - FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); - output.write(byteOutStream.toByteArray()); - output.flush(); - output.close(); - } - catch (FileNotFoundException e) { - } - catch (IOException e) { - } - } - - public void DrawByteBuffer() { - if(byteBuffer == null) - return; - byteBuffer.rewind(); - bitmap.copyPixelsFromBuffer(byteBuffer); - DrawBitmap(false); - } - - public void DrawBitmap(boolean flag) { if(bitmap == null){ return; @@ -228,30 +191,6 @@ public void DrawBitmap(boolean flag) { myTexture.unlockCanvasAndPost(canvas); } } - public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { - Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); - final RectF rectF = new RectF(rect); - final float roundPx = pixels; - - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(Color.BLUE); - canvas.drawRoundRect(rectF, roundPx, roundPx, paint); - - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, rect, rect, paint); - - return output; - } - - - private static void log(String log) { - Util.log("MegaSurfaceRendererGroup", log); - } private void notifyStateToAll() { for(MegaSurfaceRendererGroupListener listener : listeners) @@ -304,4 +243,47 @@ public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { public interface MegaSurfaceRendererGroupListener { void resetSize(Long handle); } + + public ByteBuffer CreateByteBuffer(int width, int height) { + log("CreateByteBuffer(): width = "+width+", height = "+height); + + Logging.d(TAG, "CreateByteBuffer " + width + ":" + height); + if (bitmap == null) { + bitmap = CreateBitmap(width, height); + byteBuffer = ByteBuffer.allocateDirect(width * height * 2); + } + return byteBuffer; + } + + // It saves bitmap data to a JPEG picture, this function is for debug only. + private void saveBitmapToJPEG(int width, int height) { + log("saveBitmapToJPEG(): width = "+width+", height = "+height); + + ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteOutStream); + + try{ + FileOutputStream output = new FileOutputStream(String.format("/sdcard/render_%d.jpg", System.currentTimeMillis())); + output.write(byteOutStream.toByteArray()); + output.flush(); + output.close(); + } + catch (FileNotFoundException e) { + } + catch (IOException e) { + } + } + + public void DrawByteBuffer() { + if(byteBuffer == null) + return; + byteBuffer.rewind(); + bitmap.copyPixelsFromBuffer(byteBuffer); + DrawBitmap(false); + } + + private static void log(String log) { + Util.log("MegaSurfaceRendererGroup", log); + } + } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java index c56236e1c6e..b61d98c8ade 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java @@ -90,7 +90,6 @@ public class GroupCallAdapter extends RecyclerView.Adapter peers, long chatId, boolean isCallInProgress, boolean isGrid) { log("GroupCallAdapter(peers: "+peers.size()+")"); @@ -209,7 +208,8 @@ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final in } int numPeersOnCall = getItemCount(); - log("onBindViewHolderGrid() - peer: "+peer.getName()+", numPeersOnCall: "+numPeersOnCall); + log("onBindViewHolderGrid() - peer: "+peer.getHandle()+", numPeersOnCall: "+numPeersOnCall); + if(isGrid){ CustomizedGridRecyclerView.LayoutParams lp = (CustomizedGridRecyclerView.LayoutParams) holder.rlGeneral.getLayoutParams(); @@ -400,12 +400,10 @@ public void onClick(View v) { if(peer.getListener() == null){ log("peer: "+peer.getHandle()+", VIDEO ON- listener == null "); holder.parentSurfaceView.removeAllViews(); - TextureView myTexture = new TextureView(context); myTexture.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); myTexture.setAlpha(1.0f); myTexture.setRotation(0); - GroupCallListener listenerPeer = new GroupCallListener(context, myTexture, peer.getHandle()); peer.setListener(listenerPeer); @@ -423,97 +421,43 @@ public void onClick(View v) { holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); }else{ - log("peer: "+peer.getHandle()+", VIDEO ON - listener != null"); + log("peer: "+peer.getHandle()+", VIDEO ON - listener != null"); if(holder.parentSurfaceView.getChildCount() == 0){ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() == 0"); - if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 y 2 "); - ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } - } }else{ if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 it is the same"); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same -"); - //Remove items of parent holder.parentSurfaceView.removeAllViews(); - //Remove parent of Surface if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 y 2 "); ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); - holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 1 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } - } }else{ - log("peer: "+peer.getHandle()+", VIDEO ON- getChildCount() != 0 - it is not the same - getParent 0 "); holder.parentSurfaceView.addView(peer.getListener().getSurfaceView()); - if(peer.getListener().getHeight() != 0){ - peer.getListener().setHeight(0); - } - if(peer.getListener().getWidth() != 0){ - peer.getListener().setWidth(0); - } - } } + } + if(peer.getListener().getHeight() != 0){ + peer.getListener().setHeight(0); + } + if(peer.getListener().getWidth() != 0){ + peer.getListener().setWidth(0); } } @@ -593,7 +537,6 @@ public void onClick(View v) { }else{ log("peer: "+peer.getHandle()+", VIDEO OFF"); - //Avatar: if(peer.getHandle() == megaChatApi.getMyUserHandle()){ setProfileMyAvatar(holder); @@ -606,24 +549,18 @@ public void onClick(View v) { //Remove SurfaceView && Listener: holder.surfaceMicroLayout.setVisibility(GONE); if(peer.getListener() != null){ - log("peer: "+peer.getHandle()+", VIDEO OFF - listener != null"); - if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) { megaChatApi.removeChatVideoListener(chatId, -1, peer.getListener()); }else{ megaChatApi.removeChatVideoListener(chatId, peer.getHandle(), peer.getListener()); } if(holder.parentSurfaceView.getChildCount() == 0){ - log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() == 0"); - if(peer.getListener().getSurfaceView().getParent()!=null){ if(peer.getListener().getSurfaceView().getParent().getParent()!=null){ ((ViewGroup)peer.getListener().getSurfaceView().getParent()).removeView(peer.getListener().getSurfaceView()); } } }else{ - log("peer: "+peer.getHandle()+", VIDEO OFF - getChildCount() != 0"); - holder.parentSurfaceView.removeAllViews(); if(peer.getListener().getSurfaceView().getParent()!=null){ From 2aaf1b25a266593b15c363f0a00057f8d9f92965 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 13:27:06 +0100 Subject: [PATCH 149/247] Group calls UI --- .../megachat/ChatActivityLollipop.java | 59 +++++++++---- .../megachat/calls/ChatCallActivity.java | 85 ++++++++----------- .../mega/privacy/android/app/utils/Util.java | 44 ++++++++++ app/src/main/res/values/strings.xml | 4 + 4 files changed, 128 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index a939d65a63e..08980349d55 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2514,14 +2514,16 @@ public void onClick(View v) { } case R.id.call_in_progress_layout:{ if(checkPermissionsCall()){ - log("call_in_progress_layout clicked"); MegaChatCall callInProgress = megaChatApi.getChatCall(idChat); + log("call_in_progress_layout clicked: "+callInProgress.getStatus()); + if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ - megaChatApi.startChatCall(idChat, false, null); + megaChatApi.startChatCall(idChat, false, this); + }else if((callInProgress.getStatus()==MegaChatCall.CALL_STATUS_RING_IN)){ + megaChatApi.answerChatCall(idChat, false, this); }else{ Intent intent = new Intent(this, ChatCallActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - // intent.setAction(Long.toString(System.currentTimeMillis())); intent.putExtra("chatHandle", idChat); startActivity(intent); @@ -5961,15 +5963,37 @@ public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaCh log("Error clearing history: "+e.getErrorString()); showSnackbar(getString(R.string.clear_history_error)); } - } - else if(request.getType() == MegaChatRequest.TYPE_START_CHAT_CALL){ + }else if(request.getType() == MegaChatRequest.TYPE_START_CHAT_CALL){ + if(e.getErrorCode()==MegaChatError.ERROR_OK){ + log("TYPE_START_CHAT_CALL finished with success"); + //getFlag - Returns true if it is a video-audio call or false for audio call + } + else{ + log("ERROR WHEN TYPE_START_CHAT_CALL e.getErrorCode(): " + e.getErrorString()); + if(e.getErrorCode() == MegaChatError.ERROR_TOOMANY){ + showSnackbar(getString(R.string.call_error_too_many_participants)); + }else{ + showSnackbar(getString(R.string.call_error)); + } + + + } + }else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ if(e.getErrorCode()==MegaChatError.ERROR_OK){ log("TYPE_START_CHAT_CALL finished with success"); //getFlag - Returns true if it is a video-audio call or false for audio call } else{ - log("ERROR WHEN TYPE_START_CHAT_CALL " + e.getErrorString()); - showSnackbar(getString(R.string.call_error)); + log("ERROR WHEN TYPE_START_CHAT_CALL e.getErrorCode(): " + e.getErrorString()); + if(e.getErrorCode() == MegaChatError.ERROR_TOOMANY){ + + showSnackbar(getString(R.string.call_error_too_many_participants)); + }else{ + + showSnackbar(getString(R.string.call_error)); + } + + } } else if(request.getType() == MegaChatRequest.TYPE_REMOVE_FROM_CHATROOM){ @@ -6746,19 +6770,17 @@ protected void onResume(){ if(callInProgress != null){ log("onResume() callStatus: "+callInProgress.getStatus()); - if((callInProgress.getStatus() >= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){ - log("onResume() CALL_STATUS_REQUEST_SENT - VISIBLE"); - callInProgressLayout.setVisibility(View.VISIBLE); - callInProgressText.setText(getString(R.string.call_in_progress_layout)); - callInProgressLayout.setOnClickListener(this); - } - else if(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ + if((callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT)||(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_RING_IN)){ log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); callInProgressLayout.setVisibility(View.VISIBLE); callInProgressText.setText(getString(R.string.join_call_layout)); callInProgressLayout.setOnClickListener(this); - } - else{ + }else if((callInProgress.getStatus() >= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){ + log("onResume() CALL_STATUS_REQUEST_SENT - VISIBLE"); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); + callInProgressLayout.setOnClickListener(this); + }else{ log("onResume() other case - GONE"); callInProgressLayout.setVisibility(View.GONE); } @@ -7159,6 +7181,11 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ log("onChatCallUpdate - CALL_STATUS_RING_IN "); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); + callInProgressLayout.setOnClickListener(this); + invalidateOptionsMenu(); + long openCallChatId = MegaApplication.getOpenCallChatId(); log("openCallId: "+openCallChatId); if(openCallChatId!=-1){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index a23cbd98e14..151355ef019 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -34,10 +34,12 @@ import android.renderscript.ScriptIntrinsicBlur; import android.support.design.widget.AppBarLayout; import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.graphics.Palette; import android.support.v7.widget.DefaultItemAnimator; @@ -197,6 +199,8 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis RoundedImageView contactImage; TextView contactInitialLetter; + RelativeLayout fragmentContainer; + static ChatCallActivity chatCallActivityActivity = null; private MenuItem remoteAudioIcon; @@ -269,6 +273,9 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis boolean isManualMode = false; int statusBarHeight = 0; + private AlertDialog errorCallDialog; + + @Override public boolean onCreateOptionsMenu(Menu menu) { log("onCreateOptionsMenu"); @@ -805,6 +812,7 @@ protected void onCreate(Bundle savedInstanceState) { // } getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + fragmentContainer = (RelativeLayout) findViewById(R.id.file_info_fragment_container); tB = (Toolbar) findViewById(R.id.call_toolbar); if (tB == null) { @@ -1014,7 +1022,6 @@ protected void onCreate(Bundle savedInstanceState) { if (callChat == null){ megaChatApi.removeChatCallListener(this); - MegaApplication.activityPaused(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); } @@ -1428,7 +1435,7 @@ protected void hideFABs(){ public void onPause(){ log("onPause"); mSensorManager.unregisterListener(this); - + MegaApplication.activityPaused(); super.onPause(); } @@ -1450,7 +1457,6 @@ protected void onResume() { } } } -// adapter.notifyDataSetChanged(); mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); @@ -1522,7 +1528,6 @@ public void onDestroy(){ stopAudioSignals(); mSensorManager.unregisterListener(this); - MegaApplication.activityPaused(); super.onDestroy(); } @@ -1567,23 +1572,20 @@ public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaCh if(request.getType() == MegaChatRequest.TYPE_HANG_CHAT_CALL){ log("onRequestFinish: TYPE_HANG_CHAT_CALL"); - MegaApplication.activityPaused(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); }else { super.finish(); } - } - else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ + }else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ + if(e.getErrorCode()==MegaChatError.ERROR_OK){ videoFAB.setVisibility(View.VISIBLE); relativeVideo.setVisibility(View.VISIBLE); - microFAB.setVisibility(View.VISIBLE); answerCallFAB.setVisibility(GONE); relativeCall.setVisibility(GONE); linearArrowVideo.setVisibility(GONE); - if(request.getFlag()==true){ log("Ok answer with video"); }else{ @@ -1591,20 +1593,22 @@ else if(request.getType() == MegaChatRequest.TYPE_ANSWER_CHAT_CALL){ } updateLocalVideoStatus(); updateLocalAudioStatus(); - } - else{ + }else{ log("Error call: "+e.getErrorString()); - MegaApplication.activityPaused(); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - super.finishAndRemoveTask(); - } - else { - super.finish(); + + if(e.getErrorCode() == MegaChatError.ERROR_TOOMANY){ + + Util.showErrorAlertDialogGroupCall(getString(R.string.call_error_too_many_participants), true, this); + }else{ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + super.finishAndRemoveTask(); + } + else { + super.finish(); + } } -// showSnackbar(getString(R.string.clear_history_error)); } - } - else if(request.getType() == MegaChatRequest.TYPE_DISABLE_AUDIO_VIDEO_CALL){ + }else if(request.getType() == MegaChatRequest.TYPE_DISABLE_AUDIO_VIDEO_CALL){ if(e.getErrorCode()==MegaChatError.ERROR_OK){ // if(request.getParamType()==MegaChatRequest.AUDIO){ @@ -1631,10 +1635,12 @@ else if(request.getType() == MegaChatRequest.TYPE_DISABLE_AUDIO_VIDEO_CALL){ // videoFAB.setBackgroundTintList(ColorStateList.valueOf(Color.BLACK)); // } // } - } - else{ + }else{ log("Error changing audio or video: "+e.getErrorString()); -// showSnackbar(getString(R.string.clear_history_error)); + if(e.getErrorCode() == MegaChatError.ERROR_TOOMANY){ + showSnackbar(getString(R.string.call_error_too_many_video)); + } + } }if (request.getType() == MegaRequest.TYPE_GET_ATTR_USER) { @@ -1771,13 +1777,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { if(chat.isGroup()){ stopAudioSignals(); rtcAudioManager.stop(); - MegaApplication.activityPaused(); -// if (bigCameraGroupCallFragment != null) { -// bigCameraGroupCallFragment.removeSurfaceView();; -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(bigCameraGroupCallFragment); -// bigCameraGroupCallFragment = null; -// } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); @@ -1786,22 +1785,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { super.finish(); } }else{ - -// if (localCameraFragment != null) {// -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(localCameraFragment); -// localCameraFragment = null; -// } -// if (localCameraFragmentFS != null) { -// FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction(); -// ftFS.remove(localCameraFragmentFS); -// localCameraFragmentFS = null; -// } -// if (remoteCameraFragmentFS != null) { -// FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); -// ft.remove(remoteCameraFragmentFS); -// remoteCameraFragmentFS = null; -// } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); } @@ -1828,8 +1811,6 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { stopAudioSignals(); rtcAudioManager.stop(); - MegaApplication.activityPaused(); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { super.finishAndRemoveTask(); } @@ -4194,4 +4175,12 @@ public void clearHandlers(){ } } + public void showSnackbar(String s){ + log("showSnackbar: "+s); + Snackbar snackbar = Snackbar.make(fragmentContainer, s, Snackbar.LENGTH_LONG); + TextView snackbarTextView = (TextView)snackbar.getView().findViewById(android.support.design.R.id.snackbar_text); + snackbarTextView.setMaxLines(5); + snackbar.show(); + } + } diff --git a/app/src/main/java/mega/privacy/android/app/utils/Util.java b/app/src/main/java/mega/privacy/android/app/utils/Util.java index 4bd200264ba..e9582f44d34 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/Util.java +++ b/app/src/main/java/mega/privacy/android/app/utils/Util.java @@ -232,6 +232,50 @@ public static File createTemporalURLFile(String name, String data){ } } + public static void showErrorAlertDialogGroupCall(String message, final boolean finish, final Activity activity){ + if(activity == null){ + return; + } + + try{ + AlertDialog.Builder dialogBuilder = getCustomAlertBuilder(activity, activity.getString(R.string.general_error_word), message, null); + dialogBuilder.setPositiveButton( + activity.getString(android.R.string.ok), + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + if (finish) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + activity.finishAndRemoveTask(); + }else{ + activity.finish(); + } + } + } + }); + dialogBuilder.setOnCancelListener(new OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + if (finish) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + activity.finishAndRemoveTask(); + }else{ + activity.finish(); + } + } + } + }); + + + AlertDialog dialog = dialogBuilder.create(); + dialog.show(); + brandAlertDialog(dialog); + }catch(Exception ex){ + Util.showToast(activity, message); + } + } + /* * Build error dialog * @param message Message to display diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c9033d8bc3..f0121e5d230 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2264,4 +2264,8 @@ joined the call left the call + Error. No more participants are allowed in this group call. + Error. No more video are allowed in this group call. + + From 867150d6000022fd599f690d276cb4bc81eb2bbc Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 14:18:04 +0100 Subject: [PATCH 150/247] Group calls UI --- .../java/mega/privacy/android/app/CameraSyncService.java | 1 + .../java/mega/privacy/android/app/DownloadService.java | 1 + .../android/app/fcm/MegaFirebaseMessagingService.java | 1 + .../android/app/jobservices/CameraUploadsService.java | 1 + .../app/lollipop/FileExplorerActivityLollipop.java | 2 +- .../android/app/lollipop/LoginFragmentLollipop.java | 4 ++++ .../android/app/lollipop/ManagerActivityLollipop.java | 8 ++++++++ .../android/app/providers/FileProviderActivity.java | 2 ++ app/src/main/res/values/strings.xml | 2 +- 9 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java index a01dece64e6..013a607a25f 100644 --- a/app/src/main/java/mega/privacy/android/app/CameraSyncService.java +++ b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java @@ -377,6 +377,7 @@ else if (ret == MegaChatApi.INIT_ERROR) } else{ log("shouldRun: Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } diff --git a/app/src/main/java/mega/privacy/android/app/DownloadService.java b/app/src/main/java/mega/privacy/android/app/DownloadService.java index b816237600d..9908c91b4cf 100644 --- a/app/src/main/java/mega/privacy/android/app/DownloadService.java +++ b/app/src/main/java/mega/privacy/android/app/DownloadService.java @@ -273,6 +273,7 @@ protected void onHandleIntent(final Intent intent) { megaChatApi.logout(this); } else { log("Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } diff --git a/app/src/main/java/mega/privacy/android/app/fcm/MegaFirebaseMessagingService.java b/app/src/main/java/mega/privacy/android/app/fcm/MegaFirebaseMessagingService.java index daa20c654e6..a62dd06ef3a 100644 --- a/app/src/main/java/mega/privacy/android/app/fcm/MegaFirebaseMessagingService.java +++ b/app/src/main/java/mega/privacy/android/app/fcm/MegaFirebaseMessagingService.java @@ -318,6 +318,7 @@ public void performLoginProccess(String gSession){ megaChatApi.logout(this); } else { log("Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } diff --git a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java index 75627de5d5b..dee44379d4d 100644 --- a/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java +++ b/app/src/main/java/mega/privacy/android/app/jobservices/CameraUploadsService.java @@ -1220,6 +1220,7 @@ public void run() { megaChatApi.logout(cameraUploadsService); } else { log("shouldRun: Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/FileExplorerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/FileExplorerActivityLollipop.java index e48c391aa08..241d536f7b2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/FileExplorerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/FileExplorerActivityLollipop.java @@ -502,8 +502,8 @@ else if (ret == MegaChatApi.INIT_ERROR) megaChatApi.logout(this); } else{ - log("onCreate: Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java index 8c646cc9201..377b1568729 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/LoginFragmentLollipop.java @@ -1307,10 +1307,12 @@ else if (ret == MegaChatApi.INIT_ERROR) } else{ log("enableChat: condition ret == OK -- chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } else{ log("2 - Do not init, chat already initialized"); + } } else{ @@ -1386,6 +1388,7 @@ else if (ret == MegaChatApi.INIT_ERROR) } else{ log("startFastLogin: condition ret == OK -- chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } log("After init: "+ret); } @@ -1565,6 +1568,7 @@ private void onKeysGeneratedLogin(final String email, final String password) { if (ret ==MegaChatApi.INIT_WAITING_NEW_SESSION){ log("startFastLogin: condition ret == MegaChatApi.INIT_WAITING_NEW_SESSION"); megaApi.login(lastEmail, lastPassword, this); + megaChatApi.enableGroupChatCalls(true); } else{ log("ERROR INIT CHAT: " + ret); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index e4afd49fae0..edca5950dc9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -2143,6 +2143,14 @@ public void onPageScrollStateChanged(int state) { if(ret==0||ret==MegaChatApi.INIT_ERROR){ ret = megaChatApi.init(gSession); log("After init: "+ret); + if (ret == MegaChatApi.INIT_NO_CACHE) { + log("onCreate: condition ret == MegaChatApi.INIT_NO_CACHE"); + }else if (ret == MegaChatApi.INIT_ERROR) { + log("onCreate: condition ret == MegaChatApi.INIT_ERROR"); + }else{ + log("onCreate: Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); + } } else{ log("Offline mode: Do not init, chat already initialized"); diff --git a/app/src/main/java/mega/privacy/android/app/providers/FileProviderActivity.java b/app/src/main/java/mega/privacy/android/app/providers/FileProviderActivity.java index 8a187635f87..797a6131017 100644 --- a/app/src/main/java/mega/privacy/android/app/providers/FileProviderActivity.java +++ b/app/src/main/java/mega/privacy/android/app/providers/FileProviderActivity.java @@ -380,6 +380,7 @@ else if (ret == MegaChatApi.INIT_ERROR) } else{ log("onCreate: Chat correctly initialized"); + megaChatApi.enableGroupChatCalls(true); } } } @@ -1569,6 +1570,7 @@ private void onKeysGeneratedLogin(final String email, final String password) { if (ret == MegaChatApi.INIT_WAITING_NEW_SESSION) { log("startFastLogin: condition ret == MegaChatApi.INIT_WAITING_NEW_SESSION"); megaApi.login(lastEmail, lastPassword, this); + megaChatApi.enableGroupChatCalls(true); } else { log("ERROR INIT CHAT: " + ret); megaChatApi.logout(this); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f0121e5d230..4edcdc97c09 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2265,7 +2265,7 @@ left the call Error. No more participants are allowed in this group call. - Error. No more video are allowed in this group call. + Error. No more video are allowed in this group call. From aa34ee046a2f651e0391556262c60aa3d98f0dd6 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 14:33:37 +0100 Subject: [PATCH 151/247] Group call UI --- .../megachat/ChatActivityLollipop.java | 41 ++++++++++++++----- .../main/res/layout/activity_calls_chat.xml | 1 + 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 08980349d55..a86564306fe 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -6771,10 +6771,16 @@ protected void onResume(){ log("onResume() callStatus: "+callInProgress.getStatus()); if((callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT)||(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_RING_IN)){ - log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); - callInProgressLayout.setVisibility(View.VISIBLE); - callInProgressText.setText(getString(R.string.join_call_layout)); - callInProgressLayout.setOnClickListener(this); + if(isGroup()){ + log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); + callInProgressLayout.setOnClickListener(this); + }else{ + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); + callInProgressLayout.setOnClickListener(this); + } }else if((callInProgress.getStatus() >= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){ log("onResume() CALL_STATUS_REQUEST_SENT - VISIBLE"); callInProgressLayout.setVisibility(View.VISIBLE); @@ -7181,9 +7187,17 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { }else if(call.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ log("onChatCallUpdate - CALL_STATUS_RING_IN "); - callInProgressLayout.setVisibility(View.VISIBLE); - callInProgressText.setText(getString(R.string.join_call_layout)); - callInProgressLayout.setOnClickListener(this); + + if(isGroup()){ + log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); + callInProgressLayout.setOnClickListener(this); + }else{ + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); + callInProgressLayout.setOnClickListener(this); + } invalidateOptionsMenu(); long openCallChatId = MegaApplication.getOpenCallChatId(); @@ -7197,9 +7211,16 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { } }else if(call.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){ log("onChatCallUpdate - CALL_STATUS_USER_NO_PRESENT"); - callInProgressLayout.setVisibility(View.VISIBLE); - callInProgressText.setText(getString(R.string.join_call_layout)); - callInProgressLayout.setOnClickListener(this); + if(isGroup()){ + log("onResume() CALL_STATUS_USER_NO_PRESENT - VISIBLE"); + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.join_call_layout)); + callInProgressLayout.setOnClickListener(this); + }else{ + callInProgressLayout.setVisibility(View.VISIBLE); + callInProgressText.setText(getString(R.string.call_in_progress_layout)); + callInProgressLayout.setOnClickListener(this); + } invalidateOptionsMenu(); } diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index 23170bff171..d6bb3fea5d4 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -437,6 +437,7 @@ android:layout_below="@+id/linear_arrow_video" android:scaleType="center" android:src="@drawable/ic_videocam_white" + android:background="@android:color/transparent" app:backgroundTint="@color/accentColor" app:borderWidth="0dp" app:elevation="6dp" From cd71ddeeafb57eb4e637adb15b4f2f1ec353e045 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 14:58:06 +0100 Subject: [PATCH 152/247] Group call UI --- app/src/main/res/layout/activity_calls_chat.xml | 14 ++++++++++---- app/src/main/res/layout/item_camera_group_call.xml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/layout/activity_calls_chat.xml b/app/src/main/res/layout/activity_calls_chat.xml index d6bb3fea5d4..637b40baa4e 100644 --- a/app/src/main/res/layout/activity_calls_chat.xml +++ b/app/src/main/res/layout/activity_calls_chat.xml @@ -352,7 +352,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" - android:background="@android:color/transparent"> + android:background="@null"> + android:background="@null"> + android:background="@null"> @@ -495,6 +499,7 @@ android:layout_marginRight="36dp" android:scaleType="center" android:src="@drawable/ic_record_audio_w" + android:background="@null" app:backgroundTint="@color/accentColor" app:borderWidth="0dp" app:elevation="6dp" @@ -509,6 +514,7 @@ android:layout_marginBottom="24dp" android:scaleType="center" android:src="@drawable/ic_w_end_call" + android:background="@null" app:backgroundTint="@color/delete_account" app:borderWidth="0dp" app:elevation="6dp" diff --git a/app/src/main/res/layout/item_camera_group_call.xml b/app/src/main/res/layout/item_camera_group_call.xml index 8a5c1bed049..de2a3020f0b 100644 --- a/app/src/main/res/layout/item_camera_group_call.xml +++ b/app/src/main/res/layout/item_camera_group_call.xml @@ -4,7 +4,7 @@ android:id="@+id/general" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/transparent_black"> + android:background="@android:color/transparent"> Date: Thu, 29 Nov 2018 15:06:53 +0100 Subject: [PATCH 153/247] Task #11035 - On contacts section, replace info of shared folders by last active for each contact --- .../lollipop/AddContactActivityLollipop.java | 2 +- .../lollipop/ContactInfoActivityLollipop.java | 2 +- .../app/lollipop/ManagerActivityLollipop.java | 10 +++- .../adapters/MegaContactsLollipopAdapter.java | 28 ++++++++-- .../ContactsFragmentLollipop.java | 56 ++++++++++++++++++- .../megachat/ChatActivityLollipop.java | 4 +- .../GroupChatInfoActivityLollipop.java | 2 +- .../privacy/android/app/utils/TimeUtils.java | 23 ++++++-- app/src/main/res/values/strings.xml | 5 ++ 9 files changed, 110 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/AddContactActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/AddContactActivityLollipop.java index 4cc32202824..3ffb3acf60e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/AddContactActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/AddContactActivityLollipop.java @@ -3280,7 +3280,7 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la log("onChatPresenceLastGreen"); int state = megaChatApi.getUserOnlineStatus(userhandle); if(state != MegaChatApi.STATUS_ONLINE && state != MegaChatApi.STATUS_BUSY && state != MegaChatApi.STATUS_INVALID){ - String formattedDate = TimeUtils.lastGreenDate(lastGreen); + String formattedDate = TimeUtils.lastGreenDate(this, lastGreen); if(userhandle != megaChatApi.getMyUserHandle()){ log("Status last green for the user: "+userhandle); // Replace on visible MEGA contacts (all my visible contacts) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index f7036b7e2bf..a171a353d89 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -2529,7 +2529,7 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la int state = megaChatApi.getUserOnlineStatus(user.getHandle()); if(state != MegaChatApi.STATUS_ONLINE && state != MegaChatApi.STATUS_BUSY && state != MegaChatApi.STATUS_INVALID){ - String formattedDate = TimeUtils.lastGreenDate(lastGreen); + String formattedDate = TimeUtils.lastGreenDate(this, lastGreen); secondLineTextToolbar.setVisibility(View.VISIBLE); firstLineTextToolbar.setPadding(0, Util.px2dp(6, outMetrics), 0, 0); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index e809b3c4da6..f76fc07e1f6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -17885,7 +17885,7 @@ public void onChatOnlineStatusUpdate(MegaChatApiJava api, long userHandle, int s cFLol = (ContactsFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.CONTACTS.getTag()); if(cFLol!=null){ log("Update Contacts view"); - cFLol.contactStatusUpdate(userHandle, status); + cFLol.contactPresenceUpdate(userHandle, status); } } } @@ -17937,7 +17937,13 @@ public void onChatConnectionStateUpdate(MegaChatApiJava api, long chatid, int ne @Override public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int lastGreen) { - log("onChatConnectionStateUpdate"); + log("onChatPresenceLastGreen"); + + cFLol = (ContactsFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.CONTACTS.getTag()); + if(cFLol!=null){ + log("Update Contacts view"); + cFLol.contactLastGreenUpdate(userhandle, lastGreen); + } } public boolean isMkLayoutVisible() { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index 02459a96452..dcf54331a61 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -721,34 +721,56 @@ public void onBindViewHolderList(ViewHolderContactsList holder, int position){ log("This user is connected"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_online)); + holder.textViewContent.setText(context.getString(R.string.online_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_AWAY){ log("This user is away"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_away)); + holder.textViewContent.setText(context.getString(R.string.away_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_BUSY){ log("This user is busy"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_busy)); + holder.textViewContent.setText(context.getString(R.string.busy_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_OFFLINE){ log("This user is offline"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_offline)); + holder.textViewContent.setText(context.getString(R.string.offline_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_INVALID){ log("INVALID status: "+userStatus); holder.contactStateIcon.setVisibility(View.GONE); + holder.textViewContent.setVisibility(View.GONE); } else{ log("This user status is: "+userStatus); holder.contactStateIcon.setVisibility(View.GONE); + holder.textViewContent.setVisibility(View.GONE); + } + + if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ + if(!contact.getLastGreen().isEmpty()){ + holder.textViewContent.setText(contact.getLastGreen()); + } } } } else{ holder.contactStateIcon.setVisibility(View.GONE); + + ArrayList sharedNodes = megaApi.getInShares(contact.getMegaUser()); + + String sharedNodesDescription = Util.getSubtitleDescription(sharedNodes); + + holder.textViewContent.setText(sharedNodesDescription); } holder.textViewContactName.setText(contact.getFullName()); @@ -866,12 +888,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ } } } - - ArrayList sharedNodes = megaApi.getInShares(contact.getMegaUser()); - - String sharedNodesDescription = Util.getSubtitleDescription(sharedNodes); - - holder.textViewContent.setText(sharedNodesDescription); holder.threeDotsLayout.setTag(holder); holder.threeDotsLayout.setOnClickListener(this); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index 2455e88381f..d1223356458 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -59,9 +59,12 @@ import mega.privacy.android.app.lollipop.adapters.MegaContactsLollipopAdapter; import mega.privacy.android.app.lollipop.controllers.ContactController; import mega.privacy.android.app.utils.Constants; +import mega.privacy.android.app.utils.TimeUtils; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiAndroid; import nz.mega.sdk.MegaApiJava; +import nz.mega.sdk.MegaChatApi; +import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaContactRequest; import nz.mega.sdk.MegaError; import nz.mega.sdk.MegaRequest; @@ -92,6 +95,7 @@ public class ContactsFragmentLollipop extends Fragment implements MegaRequestLis private long handleContactLink = -1; MegaApiAndroid megaApi; + MegaChatApiAndroid megaChatApi; MyAccountInfo myAccountInfo; TextView initialLetter; @@ -795,6 +799,15 @@ public void onCreate (Bundle savedInstanceState){ megaApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaApi(); } + if(Util.isChatEnabled()){ + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); + } + } + else{ + log("Chat not enabled!"); + } + dbH = DatabaseHandler.getDbHandler(context); if (savedInstanceState != null){ @@ -1200,8 +1213,8 @@ public void updateShares(){ adapter.notifyDataSetChanged(); } - public void contactStatusUpdate(long userHandle, int status) { - log("contactStatusUpdate: "+userHandle); + public void contactPresenceUpdate(long userHandle, int status) { + log("contactPresenceUpdate: "+userHandle); int indexToReplace = -1; ListIterator itrReplace = visibleContacts.listIterator(); @@ -1209,6 +1222,13 @@ public void contactStatusUpdate(long userHandle, int status) { MegaContactAdapter contact = itrReplace.next(); if (contact != null) { if (contact.getMegaUser().getHandle() == userHandle) { + if(status != MegaChatApi.STATUS_ONLINE && status != MegaChatApi.STATUS_BUSY && status != MegaChatApi.STATUS_INVALID){ + log("Request last green for user"); + megaChatApi.requestLastGreen(userHandle, ((ManagerActivityLollipop)context)); + } + else{ + contact.setLastGreen(""); + } indexToReplace = itrReplace.nextIndex() - 1; break; } @@ -1222,6 +1242,38 @@ public void contactStatusUpdate(long userHandle, int status) { } } + public void contactLastGreenUpdate(long userHandle, int lastGreen) { + log("contactLastGreenUpdate: "+userHandle); + + int state = megaChatApi.getUserOnlineStatus(userHandle); + + if(state != MegaChatApi.STATUS_ONLINE && state != MegaChatApi.STATUS_BUSY && state != MegaChatApi.STATUS_INVALID){ + String formattedDate = TimeUtils.lastGreenDate(context, lastGreen); + + int indexToReplace = -1; + ListIterator itrReplace = visibleContacts.listIterator(); + while (itrReplace.hasNext()) { + MegaContactAdapter contact = itrReplace.next(); + if (contact != null) { + if (contact.getMegaUser().getHandle() == userHandle) { + contact.setLastGreen(formattedDate); + indexToReplace = itrReplace.nextIndex() - 1; + break; + } + } else { + break; + } + } + + if (indexToReplace != -1) { + log("Index to replace: " + indexToReplace); + adapter.updateContactStatus(indexToReplace); + } + + log("Date last green: "+formattedDate); + } + } + public void sortBy(){ log("sortBy"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 3e85c2af3c2..0e3650b5ea8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -3,7 +3,6 @@ import android.Manifest; import android.app.Activity; import android.app.ActivityManager; -import android.app.NotificationManager; import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -82,7 +81,6 @@ import mega.privacy.android.app.components.NpaLinearLayoutManager; import mega.privacy.android.app.components.twemoji.EmojiEditText; import mega.privacy.android.app.components.twemoji.EmojiKeyboard; -import mega.privacy.android.app.fcm.IncomingCallService; import mega.privacy.android.app.lollipop.AddContactActivityLollipop; import mega.privacy.android.app.lollipop.AudioVideoPlayerLollipop; import mega.privacy.android.app.lollipop.ContactInfoActivityLollipop; @@ -6950,7 +6948,7 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la int state = megaChatApi.getUserOnlineStatus(chatRoom.getPeerHandle(0)); if(state != MegaChatApi.STATUS_ONLINE && state != MegaChatApi.STATUS_BUSY && state != MegaChatApi.STATUS_INVALID){ - String formattedDate = TimeUtils.lastGreenDate(lastGreen); + String formattedDate = TimeUtils.lastGreenDate(this, lastGreen); setLastGreen(formattedDate); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java index da105e3a46d..d093b29e16d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java @@ -1529,7 +1529,7 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la log("onChatPresenceLastGreen"); int state = megaChatApi.getUserOnlineStatus(userhandle); if(state != MegaChatApi.STATUS_ONLINE && state != MegaChatApi.STATUS_BUSY && state != MegaChatApi.STATUS_INVALID){ - String formattedDate = TimeUtils.lastGreenDate(lastGreen); + String formattedDate = TimeUtils.lastGreenDate(this, lastGreen); if(userhandle != megaChatApi.getMyUserHandle()){ log("Status last green for the user: "+userhandle); diff --git a/app/src/main/java/mega/privacy/android/app/utils/TimeUtils.java b/app/src/main/java/mega/privacy/android/app/utils/TimeUtils.java index 10a8733d5c5..5da7fe0bb91 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/TimeUtils.java +++ b/app/src/main/java/mega/privacy/android/app/utils/TimeUtils.java @@ -1,5 +1,7 @@ package mega.privacy.android.app.utils; +import android.content.Context; + import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Comparator; @@ -7,6 +9,7 @@ import java.util.Locale; import java.util.TimeZone; +import mega.privacy.android.app.R; import nz.mega.sdk.MegaChatMessage; public class TimeUtils implements Comparator { @@ -195,7 +198,7 @@ public static String formatTime(long ts){ return formattedDate; } - public static String lastGreenDate (int minutesAgo){ + public static String lastGreenDate (Context context, int minutesAgo){ // minutesAgo = 1442; Calendar calGreen = Calendar.getInstance(); calGreen.add(Calendar.MINUTE, -minutesAgo); @@ -206,7 +209,11 @@ public static String lastGreenDate (int minutesAgo){ TimeUtils tc = new TimeUtils(TimeUtils.DATE); long ts = calGreen.getTimeInMillis(); log("Ts last green: "+ts); - if(tc.compare(calGreen, calToday)==0) { + if(minutesAgo>=65535){ + String formattedDate = context.getString(R.string.last_seen_long_time_ago); + return formattedDate; + } + else if(tc.compare(calGreen, calToday)==0) { TimeZone tz = calGreen.getTimeZone(); @@ -215,7 +222,7 @@ public static String lastGreenDate (int minutesAgo){ String time = df.format(calGreen.getTime()); - String formattedDate = "Last seen today at" + " " + time; + String formattedDate = context.getString(R.string.last_seen_today, time); return formattedDate; } @@ -235,13 +242,17 @@ public static String lastGreenDate (int minutesAgo){ else{ TimeZone tz = calGreen.getTimeZone(); - java.text.DateFormat df = new SimpleDateFormat("dd MMM yy HH:mm", Locale.getDefault()); + java.text.DateFormat df = new SimpleDateFormat("HH:mm", Locale.getDefault()); df.setTimeZone(tz); - String formattedDate = "Last seen " + df.format(calGreen.getTime()); + String time =df.format(calGreen.getTime()); + + df = new SimpleDateFormat("dd MMM", Locale.getDefault()); + String day =df.format(calGreen.getTime()); + + String formattedDate = context.getString(R.string.last_seen_general, day, time); return formattedDate; } - } public static String formatDateAndTime(long ts, int format){ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8ffe8f4e595..955f696388b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2253,4 +2253,9 @@ [B]%1$d second[/B] [B]%1$d seconds[/B] + + Last seen today at %1$s + Last seen a long time ago + Last seen %1$s at %2$s + From 22845605caea0ad0042e5e32e0f53831d2a3bfe2 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 15:32:28 +0100 Subject: [PATCH 154/247] Group call UI --- .idea/misc.xml | 2 +- .../megachat/calls/ChatCallActivity.java | 40 +------------------ 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 635999df1e8..ba7052b8197 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index 71193c72d9e..a9a2b8baa76 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -1161,10 +1161,6 @@ protected void onCreate(Bundle savedInstanceState) { } } } -<<<<<<< HEAD -======= - ->>>>>>> develop-studio if(checkPermissions()){ checkPermissionsWriteLog(); showInitialFABConfiguration(); @@ -1536,10 +1532,7 @@ public void onDestroy(){ @Override public void onBackPressed() { log("onBackPressed"); -<<<<<<< HEAD -======= super.callToSuperBack = false; ->>>>>>> develop-studio super.onBackPressed(); if (megaChatApi != null) { @@ -2469,11 +2462,8 @@ public void onClick(View v) { break; } case R.id.video_fab:{ -<<<<<<< HEAD log("onClick video FAB"); -======= - log("Click on video fab"); ->>>>>>> develop-studio + if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); @@ -2504,10 +2494,7 @@ public void onClick(View v) { break; } case R.id.micro_fab: { -<<<<<<< HEAD -======= log("Click on micro fab"); ->>>>>>> develop-studio if(callChat.hasLocalAudio()){ megaChatApi.disableAudio(chatId, this); }else{ @@ -2529,7 +2516,6 @@ public void onClick(View v) { } case R.id.answer_call_fab:{ log("Click on answer fab"); -<<<<<<< HEAD if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){ linearFAB = (LinearLayout) findViewById(R.id.linear_buttons); RelativeLayout.LayoutParams layoutCompress = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); @@ -2556,32 +2542,14 @@ public void onClick(View v) { } } -======= - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); - megaChatApi.answerChatCall(chatId, false, this); - videoFAB.clearAnimation(); - break; - } - } - } - ->>>>>>> develop-studio public void checkPermissionsWriteLog(){ log("checkPermissionsWriteLog()"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean hasWriteLogPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALL_LOG) == PackageManager.PERMISSION_GRANTED); if (!hasWriteLogPermission) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_CALL_LOG}, Constants.WRITE_LOG); -<<<<<<< HEAD } } - -======= - }else{ - - } - } ->>>>>>> develop-studio } public boolean checkPermissions(){ @@ -3342,12 +3310,8 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in log("REQUEST_CAMERA"); if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if(checkPermissions()){ -<<<<<<< HEAD checkPermissionsWriteLog(); -======= - checkPermissionsWriteLog(); ->>>>>>> develop-studio - showInitialFABConfiguration(); + showInitialFABConfiguration(); } } else{ From 9e996b55b40ed342fd63fa5d4c23d5fc0268ae46 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Thu, 29 Nov 2018 15:55:30 +0100 Subject: [PATCH 155/247] Not allow attach from cloud drive to chat if i have not network connection --- .../lollipop/megachat/ChatActivityLollipop.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 0e3650b5ea8..53ee7733afc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2729,8 +2729,18 @@ public void attachFromFileStorage(){ public void attachFromCloud(){ log("attachFromCloud"); - ChatController chatC = new ChatController(this); - chatC.pickFileToSend(); + if(megaChatApi.isSignalActivityRequired()){ + megaChatApi.signalPresenceActivity(); + } + + if(megaApi!=null && megaApi.getRootNode()!=null){ + ChatController chatC = new ChatController(this); + chatC.pickFileToSend(); + } + else{ + log("Online but not megaApi"); + Util.showErrorAlertDialog(getString(R.string.error_server_connection_problem), false, this); + } } public void attachContact(){ From 3719fe6f9374a2c3733ce7ad5c7ede89decbb2d7 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 29 Nov 2018 16:13:29 +0100 Subject: [PATCH 156/247] Task #11035 - On contacts section, replace info of shared folders by last active for each contact --- .../app/lollipop/ManagerActivityLollipop.java | 1 - .../adapters/MegaContactsLollipopAdapter.java | 2 +- .../ContactsFragmentLollipop.java | 53 +++++-------------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index f76fc07e1f6..29417e0a713 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -5034,7 +5034,6 @@ public void selectDrawerItemContacts (){ @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - log("onPageScrolled"); indexContacts = position; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index dcf54331a61..b198bb56e20 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -769,7 +769,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ ArrayList sharedNodes = megaApi.getInShares(contact.getMegaUser()); String sharedNodesDescription = Util.getSubtitleDescription(sharedNodes); - + holder.textViewContent.setVisibility(View.VISIBLE); holder.textViewContent.setText(sharedNodesDescription); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index d1223356458..ccbc6029b7c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -846,47 +846,12 @@ public void checkScroll () { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { log("onCreateView"); - contacts = megaApi.getContacts(); - visibleContacts.clear(); - -// for (int i=0;i contacts){ } sortBy(); - - adapter.setContacts(visibleContacts); + + if(!visibleContacts.isEmpty()){ + for (int i=0;i contacts = megaApi.getContacts(); + setContacts(megaApi.getContacts()); if(adapter == null){ if (((ManagerActivityLollipop)context).isList()) { @@ -1169,7 +1144,7 @@ public void updateView () { } } else{ - this.setContacts(contacts); + adapter.setContacts(visibleContacts); } if (visibleContacts.size() == 0){ From e6eecdf1339dad189332ce26b7f3e618c666d138 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Fri, 30 Nov 2018 11:30:07 +0100 Subject: [PATCH 157/247] Bug #11012-Add scroll to last seen info on contact info, contact list and chat --- .../app/components/MarqueeTextView.java | 49 +++++++++++++++++++ .../lollipop/ContactInfoActivityLollipop.java | 25 +++++++--- .../activity_chat_contact_properties.xml | 28 +++++------ 3 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java diff --git a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java new file mode 100644 index 00000000000..8b9b5a72e73 --- /dev/null +++ b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java @@ -0,0 +1,49 @@ +package mega.privacy.android.app.components; + +import android.content.Context; +import android.graphics.Canvas; +import android.text.TextPaint; +import android.util.AttributeSet; +import android.widget.TextView; + +import mega.privacy.android.app.utils.Util; + +public class MarqueeTextView extends TextView { + public MarqueeTextView(Context context) { + super(context); + } + + public MarqueeTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public MarqueeTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + if (isMarqueeIsNecesary()) { + + } + } + + boolean isMarqueeIsNecesary() { + TextPaint textPaint = new TextPaint(); + textPaint.setTextSize(this.getPaint().getTextSize()); + if (textPaint.measureText(this.getText().toString()) > this.getMaxWidth()) { + log("Text more large than textview --> Animate"); + return true; + } + else { + log("Text less large than textview --> Not animate"); + return false; + } + } + + public static void log(String message) { + Util.log("MarqueeTextView", message); + } +} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index a171a353d89..50ea3994c40 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -66,6 +66,7 @@ import mega.privacy.android.app.MegaContactDB; import mega.privacy.android.app.R; import mega.privacy.android.app.components.EditTextCursorWatcher; +import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.lollipop.controllers.ChatController; import mega.privacy.android.app.lollipop.controllers.ContactController; import mega.privacy.android.app.lollipop.controllers.NodeController; @@ -169,7 +170,7 @@ public class ContactInfoActivityLollipop extends PinActivityLollipop implements ImageView contactStateIcon; TextView firstLineTextToolbar; TextView firstLineLengthToolbar; - TextView secondLineTextToolbar; + MarqueeTextView secondLineTextToolbar; TextView secondLineLengthToolbar; RelativeLayout clearChatLayout; @@ -286,8 +287,21 @@ protected void onCreate(Bundle savedInstanceState) { firstLineLengthToolbar = (TextView) findViewById(R.id.first_line_length_toolbar); /*SUBTITLE*/ - secondLineTextToolbar = (TextView) findViewById(R.id.second_line_toolbar); - secondLineTextToolbar.setSelected(true); +// secondLineTextToolbar = (MarqueeTextView) findViewById(R.id.second_line_toolbar); + RelativeLayout titleLayout = (RelativeLayout) findViewById(R.id.layout_title); + RelativeLayout.LayoutParams paramsR = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + paramsR.setMargins(Util.px2dp(72, outMetrics), 0, 0, 0); + paramsR.addRule(RelativeLayout.BELOW, R.id.first_line_toolbar); + secondLineTextToolbar = new MarqueeTextView(this); + secondLineTextToolbar.setLayoutParams(paramsR); + secondLineTextToolbar.setTextAppearance(R.style.ToolbarTitle_Secondary); + secondLineTextToolbar.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); + secondLineTextToolbar.setTextColor(ContextCompat.getColor(this, R.color.white)); + secondLineTextToolbar.setEllipsize(null); + secondLineTextToolbar.setSingleLine(); + secondLineTextToolbar.setPadding(0, 0, 0, Util.px2dp(9, outMetrics)); + titleLayout.addView(secondLineTextToolbar); + secondLineLengthToolbar =(TextView) findViewById(R.id.second_line_length_toolbar); nameText = (TextView) findViewById(R.id.chat_contact_properties_name_text); @@ -2534,10 +2548,9 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la secondLineTextToolbar.setVisibility(View.VISIBLE); firstLineTextToolbar.setPadding(0, Util.px2dp(6, outMetrics), 0, 0); secondLineTextToolbar.setText(formattedDate); -// secondLineTextToolbar.setText("formattedDate formattedDate formattedDate formattedDate formattedDate"); - secondLineTextToolbar.setSelected(true); secondLineLengthToolbar.setText(formattedDate); - +// secondLineTextToolbar.setText("Large text: " + formattedDate); +// secondLineLengthToolbar.setText("Large text: " + formattedDate); log("Date last green: "+formattedDate); } } diff --git a/app/src/main/res/layout/activity_chat_contact_properties.xml b/app/src/main/res/layout/activity_chat_contact_properties.xml index 27f2f859d1b..94e134cfdb5 100644 --- a/app/src/main/res/layout/activity_chat_contact_properties.xml +++ b/app/src/main/res/layout/activity_chat_contact_properties.xml @@ -133,22 +133,18 @@ android:singleLine="true" android:textAppearance="@style/ToolbarTitle.Secondary" /> - + + + + + + + + + + + + From a2d84fc0ddcf459d3933bb47ac787bb248524a20 Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Fri, 30 Nov 2018 11:47:31 +0100 Subject: [PATCH 158/247] Group call UI --- .../megachat/calls/ChatCallActivity.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java index a9a2b8baa76..9b1fdcc7b74 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/ChatCallActivity.java @@ -416,7 +416,7 @@ public void updateScreenStatusInProgress(){ } } - updateSubTitleClock(); + updateSubtitleToolbar(); }else{ log("updateScreenStatusInProgress() - individual chat - chatId: "+chatId); callChat = megaChatApi.getChatCall(chatId); @@ -479,9 +479,6 @@ public void updateScreenStatusInProgress(){ updateLocalAudioStatus(); updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); - - updateSubTitleClock(); - } stopAudioSignals(); @@ -705,6 +702,7 @@ protected void onNewIntent(Intent intent) { callChat = megaChatApi.getChatCall(chatId); titleToolbar.setText(chat.getTitle()); + updateSubTitleClock(); updateScreenStatusInProgress(); log("Start call Service"); @@ -1110,7 +1108,6 @@ protected void onCreate(Bundle savedInstanceState) { } }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){ - log("onCreate()- In Progress"); updateScreenStatusInProgress(); }else if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){ @@ -1729,6 +1726,8 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { updateLocalVideoStatus(); updateLocalAudioStatus(); + updateSubtitleToolbar(); + }else{ log("CALL_STATUS_IN_PROGRESS - Individual call"); @@ -1760,10 +1759,10 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { videoFAB.setOnTouchListener(null); videoFAB.setOnClickListener(this); - updateSubTitleClock(); stopAudioSignals(); rtcAudioManager.start(null); showInitialFABConfiguration(); + updateSubTitleClock(); break; } @@ -1835,6 +1834,10 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ if(userSession.getStatus()==MegaChatSession.SESSION_STATUS_IN_PROGRESS){ log("SESSION_STATUS_IN_PROGRESS"); + if(call.getPeerSessionStatusChange() == chat.getPeerHandle(0)){ + updateSubTitleClock(); + } + updateRemoteVideoStatus(userHandle); updateRemoteAudioStatus(userHandle); @@ -1853,8 +1856,8 @@ else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){ }else{ log("onChatCallUpdate() - CHANGE_TYPE_SESSION_STATUS"); - if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){ -// updateSubTitle(); + if(call.getPeerSessionStatusChange() == chat.getPeerHandle(0)){ + updateSubTitleClock(); } updateRemoteVideoStatus(-1); updateRemoteAudioStatus(-1); @@ -3428,7 +3431,6 @@ public static String getDateFromMillis(long d) { } private void startClock(){ - log("startClock"); long seconds = 0; if(callChat!=null){ From ffc319a463a9bfbd39eff831c5ca229e835171e9 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Fri, 30 Nov 2018 14:08:09 +0100 Subject: [PATCH 159/247] Bug #11012-Add scroll to last seen info on contact info, contact list and chat --- .../app/components/MarqueeTextView.java | 59 +++++++++++++++---- .../lollipop/ContactInfoActivityLollipop.java | 10 ++-- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java index 8b9b5a72e73..3e5f3f2f06a 100644 --- a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java +++ b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java @@ -1,7 +1,7 @@ package mega.privacy.android.app.components; import android.content.Context; -import android.graphics.Canvas; +import android.os.Handler; import android.text.TextPaint; import android.util.AttributeSet; import android.widget.TextView; @@ -9,6 +9,13 @@ import mega.privacy.android.app.utils.Util; public class MarqueeTextView extends TextView { + + private Handler mHandler = new Handler(); + private long mDelay = 200; + private int mFirstIndex; + private int mLastIndex; + private CharSequence text; + public MarqueeTextView(Context context) { super(context); } @@ -21,20 +28,26 @@ public MarqueeTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - if (isMarqueeIsNecesary()) { - + public boolean isMarqueeIsNecesary() { + TextPaint textPaint = new TextPaint(); + textPaint.setTextSize(getPaint().getTextSize()); + text = getText(); + String[] s = text.toString().split(" "); + if (s != null && s.length > 2) { + String s1 = s[0] + " " + s[1] + " "; + log("s1: "+s1); + for (int i=0; i this.getMaxWidth()) { + if (textPaint.measureText(text.toString()) > getMaxWidth()) { log("Text more large than textview --> Animate"); + mLastIndex = text.length()-1; + while (textPaint.measureText(text.subSequence(0, mLastIndex-1).toString()) > getMaxWidth()) { + mLastIndex--; + } + animateText(); return true; } else { @@ -43,6 +56,28 @@ boolean isMarqueeIsNecesary() { } } + private Runnable characterAdder = new Runnable() { + @Override + public void run() { + setText(text.subSequence(mFirstIndex, mLastIndex)); + mFirstIndex++; + mLastIndex++; + + if (mLastIndex <= text.length()) { + mHandler.postDelayed(characterAdder, mDelay); + } + else { + mHandler.removeCallbacksAndMessages(null); + } + } + }; + + public void animateText () { + mFirstIndex = 0; + mHandler.removeCallbacksAndMessages(characterAdder); + mHandler.postDelayed(characterAdder, mDelay); + } + public static void log(String message) { Util.log("MarqueeTextView", message); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index 50ea3994c40..f569fcca5f2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -297,7 +297,6 @@ protected void onCreate(Bundle savedInstanceState) { secondLineTextToolbar.setTextAppearance(R.style.ToolbarTitle_Secondary); secondLineTextToolbar.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); secondLineTextToolbar.setTextColor(ContextCompat.getColor(this, R.color.white)); - secondLineTextToolbar.setEllipsize(null); secondLineTextToolbar.setSingleLine(); secondLineTextToolbar.setPadding(0, 0, 0, Util.px2dp(9, outMetrics)); titleLayout.addView(secondLineTextToolbar); @@ -2547,10 +2546,11 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la secondLineTextToolbar.setVisibility(View.VISIBLE); firstLineTextToolbar.setPadding(0, Util.px2dp(6, outMetrics), 0, 0); - secondLineTextToolbar.setText(formattedDate); - secondLineLengthToolbar.setText(formattedDate); -// secondLineTextToolbar.setText("Large text: " + formattedDate); -// secondLineLengthToolbar.setText("Large text: " + formattedDate); +// secondLineTextToolbar.setText(formattedDate); +// secondLineLengthToolbar.setText(formattedDate); + secondLineTextToolbar.setText("Large text: " + formattedDate); + secondLineTextToolbar.isMarqueeIsNecesary(); + secondLineLengthToolbar.setText("Large text: " + formattedDate); log("Date last green: "+formattedDate); } } From 3278a9ea4806db34938dc02f7f417f7aeafd6c42 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Fri, 30 Nov 2018 14:23:25 +0100 Subject: [PATCH 160/247] Task #11035 - On contacts section, replace info of shared folders by last active for each contact --- .../adapters/MegaContactsLollipopAdapter.java | 38 ++++++++++++++----- .../ContactsFragmentLollipop.java | 3 +- app/src/main/res/layout/item_contact_grid.xml | 5 +++ app/src/main/res/layout/item_contact_list.xml | 7 +++- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index b198bb56e20..cde3b61b3e8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -154,7 +154,9 @@ public ViewHolderContacts onCreateViewHolder(ViewGroup parent, int viewType) { holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); - holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); + holderList.textViewContent.setSelected(true); + holderList.textViewContent.setHorizontallyScrolling(true); + holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); @@ -186,6 +188,8 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_GRID){ holderGrid.contactInitialLetter = (TextView) v.findViewById(R.id.contact_grid_initial_letter); holderGrid.textViewContactName = (TextView) v.findViewById(R.id.contact_grid_name); holderGrid.textViewContent = (TextView) v.findViewById(R.id.contact_grid_content); + holderGrid.textViewContent.setSelected(true); + holderGrid.textViewContent.setHorizontallyScrolling(true); holderGrid.imageButtonThreeDots = (ImageButton) v.findViewById(R.id.contact_grid_three_dots); holderGrid.contactStateIcon = (ImageView) v.findViewById(R.id.contact_grid_drawable_state); @@ -321,34 +325,56 @@ public void onBindViewHolderGrid (ViewHolderContactsGrid holder, int position){ log("This user is connected"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_online_grid)); + holder.textViewContent.setText(context.getString(R.string.online_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_AWAY){ log("This user is away"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_away_grid)); + holder.textViewContent.setText(context.getString(R.string.away_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_BUSY){ log("This user is busy"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_busy_grid)); + holder.textViewContent.setText(context.getString(R.string.busy_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_OFFLINE){ log("This user is offline"); holder.contactStateIcon.setVisibility(View.VISIBLE); holder.contactStateIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.circle_status_contact_offline_grid)); + holder.textViewContent.setText(context.getString(R.string.offline_status)); + holder.textViewContent.setVisibility(View.VISIBLE); } else if(userStatus == MegaChatApi.STATUS_INVALID){ log("INVALID status: "+userStatus); holder.contactStateIcon.setVisibility(View.GONE); + holder.textViewContent.setVisibility(View.GONE); } else{ log("This user status is: "+userStatus); holder.contactStateIcon.setVisibility(View.GONE); + holder.textViewContent.setVisibility(View.GONE); + } + + if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ + if(!contact.getLastGreen().isEmpty()){ + holder.textViewContent.setText(contact.getLastGreen()); + } } } } else{ holder.contactStateIcon.setVisibility(View.GONE); + + ArrayList sharedNodes = megaApi.getInShares(contact.getMegaUser()); + + String sharedNodesDescription = Util.getSubtitleDescription(sharedNodes); + holder.textViewContent.setVisibility(View.VISIBLE); + holder.textViewContent.setText(sharedNodesDescription); } if (!multipleSelect) { @@ -418,13 +444,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ megaApi.getUserAvatar(contact.getMegaUser(), context.getCacheDir().getAbsolutePath() + "/" + contact.getMegaUser().getEmail() + ".jpg", listener); } } - - ArrayList sharedNodes = megaApi.getInShares(contact.getMegaUser()); - - String sharedNodesDescription = Util.getSubtitleDescription(sharedNodes); - - holder.textViewContent.setText(sharedNodesDescription); - + holder.imageButtonThreeDots.setTag(holder); holder.imageButtonThreeDots.setOnClickListener(this); } @@ -634,8 +654,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ holder.contactStateIcon.setVisibility(View.GONE); } - - holder.textViewContactName.setText(contact.getFullName()); createDefaultAvatar(holder, contact); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index ccbc6029b7c..8b507ca9322 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -850,8 +850,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle sav if(myAccountInfo == null){ myAccountInfo = ((MegaApplication) ((Activity)context).getApplication()).getMyAccountInfo(); } - - display = ((Activity)context).getWindowManager().getDefaultDisplay(); outMetrics = new DisplayMetrics (); @@ -1232,6 +1230,7 @@ public void contactLastGreenUpdate(long userHandle, int lastGreen) { if (contact != null) { if (contact.getMegaUser().getHandle() == userHandle) { contact.setLastGreen(formattedDate); + //contact.setLastGreen("Veryyy veryy longg tooo check what happens"); indexToReplace = itrReplace.nextIndex() - 1; break; } diff --git a/app/src/main/res/layout/item_contact_grid.xml b/app/src/main/res/layout/item_contact_grid.xml index 85a9463fe4c..d0852d660f4 100644 --- a/app/src/main/res/layout/item_contact_grid.xml +++ b/app/src/main/res/layout/item_contact_grid.xml @@ -80,6 +80,11 @@ android:layout_alignParentLeft="true" android:layout_marginBottom="16dp" android:layout_marginLeft="13dp" + android:focusable="true" + android:focusableInTouchMode="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" android:textColor="@color/mail_my_account" android:layout_below="@id/contact_grid_name" android:textSize="12sp" /> diff --git a/app/src/main/res/layout/item_contact_list.xml b/app/src/main/res/layout/item_contact_list.xml index b85b65e48e1..5d234701d1c 100644 --- a/app/src/main/res/layout/item_contact_list.xml +++ b/app/src/main/res/layout/item_contact_list.xml @@ -100,8 +100,11 @@ android:layout_height="wrap_content" android:layout_below="@id/contact_list_name" android:textSize="14sp" - android:ellipsize="end" - android:maxLines="1" + android:focusable="true" + android:focusableInTouchMode="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" android:textColor="@color/file_list_second_row" /> From 3480de13ace175297307173bdf858842dad45279 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Mon, 3 Dec 2018 12:46:24 +0100 Subject: [PATCH 161/247] Task #11075-Improvements on contacts grid view Fix: When it opens for first time the Contacts section, if it is in grid mode, it shows incorrectly no contacts --- .idea/compiler.xml | 22 ----- .idea/copyright/profiles_settings.xml | 3 - .idea/misc.xml | 13 ++- .../adapters/MegaContactsLollipopAdapter.java | 18 +++- .../ContactsFragmentLollipop.java | 3 +- ...ckground_item_grid_long_click_lollipop.xml | 4 +- app/src/main/res/layout/item_contact_grid.xml | 92 ++++++++++--------- 7 files changed, 75 insertions(+), 80 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43efa6a..00000000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3377d..00000000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index ba7052b8197..17426a40d4c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,21 +5,26 @@ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index cde3b61b3e8..16b895892eb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -71,7 +71,8 @@ public class MegaContactsLollipopAdapter extends RecyclerView.Adapter _contacts, RecyclerView _listView, int adapterType) { this.context = _context; @@ -139,7 +140,7 @@ public ViewHolderContacts onCreateViewHolder(ViewGroup parent, int viewType) { log("onCreateViewHolder"); Display display = ((Activity)context).getWindowManager().getDefaultDisplay(); - DisplayMetrics outMetrics = new DisplayMetrics (); + outMetrics = new DisplayMetrics (); display.getMetrics(outMetrics); dbH = DatabaseHandler.getDbHandler(context); @@ -376,10 +377,19 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ holder.textViewContent.setVisibility(View.VISIBLE); holder.textViewContent.setText(sharedNodesDescription); } + + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.textViewContactName.getLayoutParams(); + if (holder.textViewContent.getVisibility() == View.VISIBLE) { + params.setMargins(Util.px2dp(13, outMetrics), Util.px2dp(16, outMetrics), 0, 0); + } + else if (holder.textViewContent.getVisibility() == View.GONE) { + params.setMargins(Util.px2dp(13, outMetrics), Util.px2dp(24, outMetrics), 0, Util.px2dp(24, outMetrics)); + } + holder.textViewContactName.setLayoutParams(params); if (!multipleSelect) { - holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid)); + holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid_new)); } else { @@ -387,7 +397,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid_long_click_lollipop)); } else{ - holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid)); + holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid_new)); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index 8b507ca9322..0a97977ea6f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -967,6 +967,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { emptyTextView = (LinearLayout) v.findViewById(R.id.contact_grid_empty_text); emptyTextViewFirst = (TextView) v.findViewById(R.id.contact_grid_empty_text_first); + setContacts(megaApi.getContacts()); if (adapter == null){ adapter = new MegaContactsLollipopAdapter(context, this, visibleContacts, recyclerView, MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_GRID); } @@ -979,7 +980,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { adapter.setPositionClicked(-1); adapter.setMultipleSelect(false); recyclerView.setAdapter(adapter); - + if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); diff --git a/app/src/main/res/drawable/background_item_grid_long_click_lollipop.xml b/app/src/main/res/drawable/background_item_grid_long_click_lollipop.xml index 881e6528fef..68bae2eaf95 100644 --- a/app/src/main/res/drawable/background_item_grid_long_click_lollipop.xml +++ b/app/src/main/res/drawable/background_item_grid_long_click_lollipop.xml @@ -1,8 +1,8 @@ - + - + diff --git a/app/src/main/res/layout/item_contact_grid.xml b/app/src/main/res/layout/item_contact_grid.xml index d0852d660f4..b2ade26e06d 100644 --- a/app/src/main/res/layout/item_contact_grid.xml +++ b/app/src/main/res/layout/item_contact_grid.xml @@ -2,15 +2,15 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/contact_grid_item_layout" - android:background="@drawable/background_item_grid" + android:background="@drawable/background_item_grid_new" android:layout_margin="6dp" + android:padding="1dp" android:descendantFocusability="blocksDescendants" > + android:layout_height="172dp"> - - - - - + android:layout_below="@id/contact_grid_separator"> + + + + + + + + + From 767d48f66a62d91185508df0ca488eebaa33f6c3 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 3 Dec 2018 16:12:33 +0100 Subject: [PATCH 162/247] Bug #11013 - Differentiate on notifications TYPE_DELETEDSHARE if the shared folder was removed or a contact has left the folder --- .../adapters/MegaNotificationsAdapter.java | 17 ++++++++++++----- app/src/main/res/values/strings.xml | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNotificationsAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNotificationsAdapter.java index ca2ddde5bf1..1508666ab71 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNotificationsAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNotificationsAdapter.java @@ -917,17 +917,24 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) { holder.titleText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); String email = alert.getEmail(); - MegaNode node = megaApi.getNodeByHandle(alert.getNodeHandle()); String textToShow = ""; Spanned result = null; - if(node!=null){ - textToShow = String.format(context.getString(R.string.notification_left_shared_folder), email); - holder.itemLayout.setOnClickListener(this); + //TYPE_DELETEDSHARE (0: value 1 if access for this user was removed by the share owner, otherwise + //value 0 if someone left the folder) + if(alert.getNumber(0)==0){ + MegaNode node = megaApi.getNodeByHandle(alert.getNodeHandle()); + if(node!=null){ + holder.itemLayout.setOnClickListener(this); + textToShow = String.format(context.getString(R.string.notification_left_shared_folder_with_name), email, node.getName()); + } + else{ + holder.itemLayout.setOnClickListener(null); + textToShow = String.format(context.getString(R.string.notification_left_shared_folder), email); + } } else{ textToShow = String.format(context.getString(R.string.notification_deleted_shared_folder), email); - holder.itemLayout.setOnClickListener(null); } try{ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 955f696388b..551b058ca35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2137,7 +2137,7 @@ [A]%s [/A][B]sent you a contact request.[/B] [A]%s [/A][B]is now a contact.[/B] - [B]New shared folder from [/B][A]%s[/A] + [B]New shared folder from [/B][A]%s.[/A] [A]Reminder: [/A][B]%s [/B][C]sent you a contact request.[/C] @@ -2169,6 +2169,7 @@ [B]Access to folder shared by [/B][A]%s[/A][B] was removed.[/B] [A]%s[/A][B] has left a shared folder.[/B] + [A]%1$s[/A][B] has left the shared folder [/B][A]%2$s.[/A] [B]Contact request from [/B][A]%s [/A][B]was ignored[/B] [B]Contact request from [/B][A]%s [/A][B]was accepted[/B] From fe5179c2c18d09a91a9a0334934073e2e4895b37 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 3 Dec 2018 16:27:33 +0100 Subject: [PATCH 163/247] Bug #11079 - Remove "Rubbish bin" option from Setiings menu --- .../privacy/android/app/lollipop/ManagerActivityLollipop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index 29417e0a713..31404ac3cac 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -7161,7 +7161,7 @@ else if (drawerItem == DrawerItem.SETTINGS){ unSelectMenuItem.setVisible(false); thumbViewMenuItem.setVisible(false); addMenuItem.setEnabled(false); - rubbishBinMenuItem.setVisible(true); + rubbishBinMenuItem.setVisible(false); clearRubbishBinMenuitem.setVisible(false); importLinkMenuItem.setVisible(false); takePicture.setVisible(false); From c25bc433e8dfd4127ad59f9c3097c2c2e24a2b32 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 3 Dec 2018 16:43:19 +0100 Subject: [PATCH 164/247] Replace singular string to plural --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 551b058ca35..198c5aa26a3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2167,7 +2167,7 @@ [A]%s [/A][B]denied your contact request.[/B] [A]%s [/A][B]accepted your contact request.[/B] - [B]Access to folder shared by [/B][A]%s[/A][B] was removed.[/B] + [B]Access to folders shared by [/B][A]%s[/A][B] was removed.[/B] [A]%s[/A][B] has left a shared folder.[/B] [A]%1$s[/A][B] has left the shared folder [/B][A]%2$s.[/A] From a4d38f3f7f73b696c361b2a4c13c29e0ca73d230 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Tue, 4 Dec 2018 12:45:22 +0100 Subject: [PATCH 165/247] Fix if Notifications fragment is already created, refresh it --- .../app/components/MarqueeTextView.java | 49 +++++++++++++------ .../lollipop/ContactInfoActivityLollipop.java | 25 +++------- .../adapters/MegaContactsLollipopAdapter.java | 22 ++++----- .../megachat/ChatActivityLollipop.java | 14 ++---- app/src/main/res/layout/activity_chat.xml | 7 ++- .../activity_chat_contact_properties.xml | 24 ++++----- app/src/main/res/layout/item_contact_grid.xml | 3 +- app/src/main/res/layout/item_contact_list.xml | 9 ++-- app/src/main/res/values/strings.xml | 6 +-- 9 files changed, 79 insertions(+), 80 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java index 3e5f3f2f06a..0573d229808 100644 --- a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java +++ b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java @@ -6,6 +6,7 @@ import android.util.AttributeSet; import android.widget.TextView; +import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; import mega.privacy.android.app.utils.Util; public class MarqueeTextView extends TextView { @@ -14,6 +15,7 @@ public class MarqueeTextView extends TextView { private long mDelay = 200; private int mFirstIndex; private int mLastIndex; + private int scrollIndex; private CharSequence text; public MarqueeTextView(Context context) { @@ -28,42 +30,61 @@ public MarqueeTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } - public boolean isMarqueeIsNecesary() { + public void isMarqueeIsNecessary(Context context) { TextPaint textPaint = new TextPaint(); textPaint.setTextSize(getPaint().getTextSize()); - text = getText(); - String[] s = text.toString().split(" "); - if (s != null && s.length > 2) { - String s1 = s[0] + " " + s[1] + " "; - log("s1: "+s1); - for (int i=0; i getMaxWidth()) { + + } + + private void scroll (TextPaint textPaint, int width) { + if (textPaint.measureText(text.toString()) > width) { log("Text more large than textview --> Animate"); mLastIndex = text.length()-1; - while (textPaint.measureText(text.subSequence(0, mLastIndex-1).toString()) > getMaxWidth()) { + while (textPaint.measureText(text.subSequence(0, mLastIndex-1).toString()) > width) { mLastIndex--; } animateText(); - return true; } else { log("Text less large than textview --> Not animate"); - return false; + setText(text); } } + public void formatString () { + String stringToFormat = getText().toString(); + stringToFormat = stringToFormat.replace("[A]", ""); + scrollIndex = stringToFormat.indexOf("[/A]"); + stringToFormat = stringToFormat.replace("[/A]", ""); + text = stringToFormat; + setText(text); + } + private Runnable characterAdder = new Runnable() { @Override public void run() { + text = text + " "; setText(text.subSequence(mFirstIndex, mLastIndex)); mFirstIndex++; mLastIndex++; - if (mLastIndex <= text.length()) { + if (mFirstIndex <= scrollIndex) { mHandler.postDelayed(characterAdder, mDelay); } else { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index f569fcca5f2..82fc9919a21 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -287,20 +287,7 @@ protected void onCreate(Bundle savedInstanceState) { firstLineLengthToolbar = (TextView) findViewById(R.id.first_line_length_toolbar); /*SUBTITLE*/ -// secondLineTextToolbar = (MarqueeTextView) findViewById(R.id.second_line_toolbar); - RelativeLayout titleLayout = (RelativeLayout) findViewById(R.id.layout_title); - RelativeLayout.LayoutParams paramsR = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - paramsR.setMargins(Util.px2dp(72, outMetrics), 0, 0, 0); - paramsR.addRule(RelativeLayout.BELOW, R.id.first_line_toolbar); - secondLineTextToolbar = new MarqueeTextView(this); - secondLineTextToolbar.setLayoutParams(paramsR); - secondLineTextToolbar.setTextAppearance(R.style.ToolbarTitle_Secondary); - secondLineTextToolbar.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); - secondLineTextToolbar.setTextColor(ContextCompat.getColor(this, R.color.white)); - secondLineTextToolbar.setSingleLine(); - secondLineTextToolbar.setPadding(0, 0, 0, Util.px2dp(9, outMetrics)); - titleLayout.addView(secondLineTextToolbar); - + secondLineTextToolbar = (MarqueeTextView) findViewById(R.id.second_line_toolbar); secondLineLengthToolbar =(TextView) findViewById(R.id.second_line_length_toolbar); nameText = (TextView) findViewById(R.id.chat_contact_properties_name_text); @@ -2546,11 +2533,11 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la secondLineTextToolbar.setVisibility(View.VISIBLE); firstLineTextToolbar.setPadding(0, Util.px2dp(6, outMetrics), 0, 0); -// secondLineTextToolbar.setText(formattedDate); -// secondLineLengthToolbar.setText(formattedDate); - secondLineTextToolbar.setText("Large text: " + formattedDate); - secondLineTextToolbar.isMarqueeIsNecesary(); - secondLineLengthToolbar.setText("Large text: " + formattedDate); + secondLineTextToolbar.setText(formattedDate); + secondLineTextToolbar.isMarqueeIsNecessary(this); + secondLineLengthToolbar.setText(formattedDate); +// secondLineTextToolbar.setText("Large: " + formattedDate); +// secondLineLengthToolbar.setText("Large: " + formattedDate); log("Date last green: "+formattedDate); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index cde3b61b3e8..e71cfc9ad3c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -34,6 +34,7 @@ import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.MegaContactAdapter; import mega.privacy.android.app.R; +import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; import mega.privacy.android.app.lollipop.AddContactActivityLollipop; @@ -107,7 +108,7 @@ public ViewHolderContacts(View v) { public TextView contactInitialLetter; // ImageView imageView; TextView textViewContactName; - TextView textViewContent; + MarqueeTextView textViewContent; RelativeLayout itemLayout; public String contactMail; } @@ -153,9 +154,7 @@ public ViewHolderContacts onCreateViewHolder(ViewGroup parent, int viewType) { holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); - holderList.textViewContent.setSelected(true); - holderList.textViewContent.setHorizontallyScrolling(true); + holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); @@ -187,9 +186,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_GRID){ holderGrid.imageView = (ImageView) v.findViewById(R.id.contact_grid_thumbnail); holderGrid.contactInitialLetter = (TextView) v.findViewById(R.id.contact_grid_initial_letter); holderGrid.textViewContactName = (TextView) v.findViewById(R.id.contact_grid_name); - holderGrid.textViewContent = (TextView) v.findViewById(R.id.contact_grid_content); - holderGrid.textViewContent.setSelected(true); - holderGrid.textViewContent.setHorizontallyScrolling(true); + holderGrid.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_grid_content); holderGrid.imageButtonThreeDots = (ImageButton) v.findViewById(R.id.contact_grid_three_dots); holderGrid.contactStateIcon = (ImageView) v.findViewById(R.id.contact_grid_drawable_state); @@ -218,7 +215,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_ADD_CONTACT holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout.setVisibility(View.GONE); @@ -232,7 +229,6 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_ADD_CONTACT holderList.textViewContent.setMaxWidth(Util.scaleWidthPx(MAX_WIDTH_CONTACT_NAME_PORT, outMetrics)); } - holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); //Right margin @@ -257,7 +253,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_GROUP_CHAT) holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); holderList.declineLayout.setVisibility(View.VISIBLE); @@ -271,7 +267,6 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_GROUP_CHAT) holderList.textViewContent.setMaxWidth(Util.scaleWidthPx(MAX_WIDTH_CONTACT_NAME_PORT, outMetrics)); } - holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); holderList.declineLayout.setTag(holderList); @@ -363,6 +358,8 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ if(!contact.getLastGreen().isEmpty()){ holder.textViewContent.setText(contact.getLastGreen()); + holder.textViewContent.formatString(); + holder.textViewContent.setSelected(true); } } } @@ -508,6 +505,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID) { if (!contact.getLastGreen().isEmpty()) { holder.textViewContent.setText(contact.getLastGreen()); + holder.textViewContent.isMarqueeIsNecessary(context); } } } @@ -644,6 +642,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID) { if (!contact.getLastGreen().isEmpty()) { holder.textViewContent.setText(contact.getLastGreen()); + holder.textViewContent.isMarqueeIsNecessary(context); } } } @@ -777,6 +776,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ if(!contact.getLastGreen().isEmpty()){ holder.textViewContent.setText(contact.getLastGreen()); + holder.textViewContent.isMarqueeIsNecessary(context); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 0e3650b5ea8..346c6c29688 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -34,7 +34,6 @@ import android.text.Editable; import android.text.Html; import android.text.Spanned; -import android.text.TextUtils; import android.text.TextWatcher; import android.util.DisplayMetrics; import android.view.Display; @@ -78,6 +77,7 @@ import mega.privacy.android.app.MimeTypeList; import mega.privacy.android.app.R; import mega.privacy.android.app.ShareInfo; +import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.components.NpaLinearLayoutManager; import mega.privacy.android.app.components.twemoji.EmojiEditText; import mega.privacy.android.app.components.twemoji.EmojiKeyboard; @@ -228,7 +228,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha LinearLayout toolbarElements; TextView titleToolbar; - TextView subtitleToobar; + MarqueeTextView subtitleToobar; ImageView iconStateToolbar; float scaleH, scaleW; float density; @@ -592,13 +592,7 @@ protected void onCreate(Bundle savedInstanceState) { tB.setOnClickListener(this); toolbarElements = (LinearLayout) tB.findViewById(R.id.toolbar_elements); titleToolbar = (TextView) tB.findViewById(R.id.title_toolbar); - subtitleToobar = (TextView) tB.findViewById(R.id.subtitle_toolbar); - subtitleToobar.setFocusable(true); - subtitleToobar.setFocusableInTouchMode(true); - subtitleToobar.setEllipsize(TextUtils.TruncateAt.MARQUEE); - subtitleToobar.setMarqueeRepeatLimit(-1); - subtitleToobar.setSingleLine(true); - subtitleToobar.setHorizontallyScrolling(true); + subtitleToobar = (MarqueeTextView) tB.findViewById(R.id.subtitle_toolbar); iconStateToolbar = (ImageView) tB.findViewById(R.id.state_icon_toolbar); titleToolbar.setText(" "); @@ -1396,7 +1390,7 @@ else if(permission==MegaChatRoom.PRIV_RM) { public void setLastGreen(String date){ subtitleToobar.setText(date); - subtitleToobar.setSelected(true); + subtitleToobar.isMarqueeIsNecessary(this); subtitleToobar.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index 3a3a513fd2e..e89ce589520 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -85,16 +85,15 @@ android:layout_alignParentTop="true" android:visibility="gone"/> - diff --git a/app/src/main/res/layout/activity_chat_contact_properties.xml b/app/src/main/res/layout/activity_chat_contact_properties.xml index 94e134cfdb5..7d40054cffd 100644 --- a/app/src/main/res/layout/activity_chat_contact_properties.xml +++ b/app/src/main/res/layout/activity_chat_contact_properties.xml @@ -133,18 +133,18 @@ android:singleLine="true" android:textAppearance="@style/ToolbarTitle.Secondary" /> - - - - - - - - - - - - + diff --git a/app/src/main/res/layout/item_contact_grid.xml b/app/src/main/res/layout/item_contact_grid.xml index d0852d660f4..b181c8d0cb6 100644 --- a/app/src/main/res/layout/item_contact_grid.xml +++ b/app/src/main/res/layout/item_contact_grid.xml @@ -73,7 +73,7 @@ android:maxLines="1" android:singleLine="true"/> - diff --git a/app/src/main/res/layout/item_contact_list.xml b/app/src/main/res/layout/item_contact_list.xml index 5d234701d1c..2db68bb2490 100644 --- a/app/src/main/res/layout/item_contact_list.xml +++ b/app/src/main/res/layout/item_contact_list.xml @@ -94,17 +94,14 @@ android:background="@null" android:src="@drawable/circle_status_contact_offline" /> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 955f696388b..0c149fe70c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2254,8 +2254,8 @@ [B]%1$d seconds[/B] - Last seen today at %1$s - Last seen a long time ago - Last seen %1$s at %2$s + [A]Last seen [/A]today at %1$s + [A]Last seen [/A]a long time ago + [A]Last seen [/A]%1$s at %2$s From 8ddbdfe5a7d25c483a192198ff9c15ebcd69e6df Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 4 Dec 2018 13:20:46 +0100 Subject: [PATCH 166/247] Feature #10972 - Chat node history --- app/src/main/AndroidManifest.xml | 6 + .../lollipop/ContactInfoActivityLollipop.java | 7 +- .../megachat/ChatActivityLollipop.java | 4 - .../NodeAttachmentHistoryActivity.java | 164 +++++++++++++++--- .../NodeAttachmentHistoryAdapter.java | 5 +- .../main/res/layout/activity_node_history.xml | 69 ++++++++ app/src/main/res/values/strings.xml | 3 + 7 files changed, 225 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/layout/activity_node_history.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e56142736d5..57e8662725a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -186,6 +186,12 @@ + + + diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index 3354d975781..922011da312 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -75,6 +75,7 @@ import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences; import mega.privacy.android.app.lollipop.megachat.ChatSettings; +import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity; import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity; import mega.privacy.android.app.modalbottomsheet.ContactInfoBottomSheetDialogFragment; import mega.privacy.android.app.snackbarListeners.SnackbarNavigateOption; @@ -1286,7 +1287,11 @@ public void onClick(View v) { break; } case R.id.chat_contact_properties_chat_files_shared_layout:{ - + Intent nodeHistoryIntent = new Intent(this, NodeAttachmentHistoryActivity.class); + if(chat!=null){ + nodeHistoryIntent.putExtra("chatId", chat.getChatId()); + } + startActivity(nodeHistoryIntent); break; } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 0e3650b5ea8..9cb51771523 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -687,7 +687,6 @@ protected void onCreate(Bundle savedInstanceState) { fileStorageLayout.setVisibility(View.GONE); pickFileStorageButton.setImageResource(R.drawable.ic_b_select_image); - textChat.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } @@ -912,9 +911,6 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { // showSnackbar("loadMoreMessages!!!"); // } if(pos<=NUMBER_MESSAGES_BEFORE_LOAD&&getMoreHistory){ - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } log("DE->loadMessages:scrolling up"); isLoadingHistory = true; stateHistory = megaChatApi.loadMessages(idChat, NUMBER_MESSAGES_TO_LOAD); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index 5e7b7df3cc8..c10ec92f9fb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -3,6 +3,7 @@ import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; @@ -17,6 +18,8 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; +import android.text.Html; +import android.text.Spanned; import android.util.DisplayMetrics; import android.view.Display; import android.view.GestureDetector; @@ -59,6 +62,7 @@ import nz.mega.sdk.MegaChatRequestListenerInterface; import nz.mega.sdk.MegaChatRoom; import nz.mega.sdk.MegaNode; +import nz.mega.sdk.MegaNodeList; public class NodeAttachmentHistoryActivity extends PinActivityLollipop implements MegaChatRequestListenerInterface, RecyclerView.OnItemTouchListener, GestureDetector.OnGestureListener, OnClickListener, MegaChatListenerInterface, MegaChatNodeHistoryListenerInterface { @@ -79,14 +83,18 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement RecyclerView listView; LinearLayoutManager mLayoutManager; GestureDetectorCompat detector; - ImageView emptyImage; - TextView emptyText; + RelativeLayout emptyLayout; + TextView emptyTextView; + ImageView emptyImageView; ArrayList messages; MegaChatRoom chatRoom; NodeAttachmentHistoryAdapter adapter; + boolean scrollingUp = false; + boolean getMoreHistory=false; + boolean isLoadingHistory = false; private ActionMode actionMode; @@ -149,22 +157,23 @@ protected void onCreate(Bundle savedInstanceState) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.lollipop_dark_primary_color)); } - setContentView(R.layout.activity_versions_file); + setContentView(R.layout.activity_node_history); //Set toolbar - tB = (Toolbar) findViewById(R.id.toolbar_versions_file); + tB = (Toolbar) findViewById(R.id.toolbar_node_history); setSupportActionBar(tB); aB = getSupportActionBar(); // aB.setHomeAsUpIndicator(R.drawable.ic_menu_white); aB.setDisplayHomeAsUpEnabled(true); aB.setDisplayShowHomeEnabled(true); - aB.setTitle(getString(R.string.title_section_versions)); - container = (RelativeLayout) findViewById(R.id.versions_main_layout); + aB.setTitle(getString(R.string.title_chat_shared_files_info).toUpperCase()); + + container = (RelativeLayout) findViewById(R.id.node_history_main_layout); detector = new GestureDetectorCompat(this, new RecyclerViewOnGestureListener()); - listView = (RecyclerView) findViewById(R.id.recycler_view_versions_file); + listView = (RecyclerView) findViewById(R.id.node_history_list_view); listView.setPadding(0, 0, 0, Util.scaleHeightPx(85, outMetrics)); listView.setClipToPadding(false); listView.addItemDecoration(new PositionDividerItemDecoration(this, outMetrics)); @@ -173,10 +182,58 @@ protected void onCreate(Bundle savedInstanceState) { listView.addOnItemTouchListener(this); listView.setItemAnimator(new DefaultItemAnimator()); - emptyImage = (ImageView) findViewById(R.id.versions_file_empty_image); - emptyText = (TextView) findViewById(R.id.versions_file_empty_text); - emptyImage.setImageResource(R.drawable.ic_empty_contacts); - emptyText.setText(R.string.contacts_list_empty_text); + listView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + + if(stateHistory!=MegaChatApi.SOURCE_NONE){ + if (dy > 0) { + // Scrolling up + scrollingUp = true; + } else { + // Scrolling down + scrollingUp = false; + } + + if(!scrollingUp){ + int pos = mLayoutManager.findFirstVisibleItemPosition(); + + if(pos<=NUMBER_MESSAGES_BEFORE_LOAD&&getMoreHistory){ + log("DE->loadMessages:scrolling up"); + isLoadingHistory = true; + stateHistory = megaChatApi.loadMessages(chatId, NUMBER_MESSAGES_TO_LOAD); + getMoreHistory = false; + } + } + } + } + }); + + emptyLayout = (RelativeLayout) findViewById(R.id.empty_layout_node_history); + emptyTextView = (TextView) findViewById(R.id.empty_text_node_history); + emptyImageView = (ImageView) findViewById(R.id.empty_image_view_node_history); + + if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){ + emptyImageView.setImageResource(R.drawable.contacts_empty_landscape); + }else{ + emptyImageView.setImageResource(R.drawable.ic_empty_contacts); + } + + String textToShow = String.format(getString(R.string.context_empty_shared_files)); + try{ + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + textToShow = textToShow.replace("[B]", ""); + textToShow = textToShow.replace("[/B]", ""); + } + catch (Exception e){} + Spanned result = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + result = Html.fromHtml(textToShow,Html.FROM_HTML_MODE_LEGACY); + } else { + result = Html.fromHtml(textToShow); + } + emptyTextView.setText(result); if (savedInstanceState != null){ chatId = savedInstanceState.getLong("chatId", -1); @@ -194,18 +251,17 @@ protected void onCreate(Bundle savedInstanceState) { messages = new ArrayList<>(); if (messages.size() != 0){ - emptyImage.setVisibility(View.GONE); - emptyText.setVisibility(View.GONE); + emptyLayout.setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); } else{ - emptyImage.setVisibility(View.VISIBLE); - emptyText.setVisibility(View.VISIBLE); + emptyLayout.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); } - boolean result = megaChatApi.openNodeHistory(chatId, this); - if(result){ + boolean resultOpen = megaChatApi.openNodeHistory(chatId, this); + if(resultOpen){ log("Node history opened correctly"); messages = new ArrayList(); @@ -217,14 +273,13 @@ protected void onCreate(Bundle savedInstanceState) { listView.setAdapter(adapter); adapter.setMultipleSelect(false); + isLoadingHistory = true; stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); } } else{ log("ERROR: node is NULL"); } - - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); } } @@ -273,7 +328,6 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); // Handle presses on the action bar items switch (item.getItemId()) { case android.R.id.home:{ @@ -323,12 +377,11 @@ public boolean showSelectMenuItem(){ } public static void log(String log) { - Util.log("VersionsFileActivity", log); + Util.log("NodeAttachmentHistoryActivity", log); } public void itemClick(int position) { log("itemClick"); - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); if (adapter.isMultipleSelect()){ adapter.toggleSelection(position); updateActionModeTitle(); @@ -342,8 +395,8 @@ public void itemClick(int position) { @Override public void onBackPressed() { log("onBackPressed"); + super.callToSuperBack = true; super.onBackPressed(); - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); } private void updateActionModeTitle() { @@ -377,7 +430,6 @@ public void hideMultipleSelect() { @Override public void onClick(View v) { - ((MegaApplication) getApplication()).sendSignalPresenceActivity(); switch (v.getId()){ case R.id.file_contact_list_layout:{ Intent i = new Intent(this, ManagerActivityLollipop.class); @@ -524,7 +576,9 @@ public void onClick(DialogInterface dialog, int which) { public void onSaveInstanceState(Bundle outState) { log("onSaveInstanceState"); super.onSaveInstanceState(outState); - outState.putLong("chatId", chatRoom.getChatId()); + if(chatRoom!=null){ + outState.putLong("chatId", chatRoom.getChatId()); + } } //Multiselection @@ -690,6 +744,66 @@ public void onRequestTemporaryError(MegaChatApiJava api, MegaChatRequest request @Override public void onAttachmentLoaded(MegaChatApiJava api, MegaChatMessage msg) { log("onAttachmentLoaded"); + if(msg!=null){ + if(msg.getType()==MegaChatMessage.TYPE_NODE_ATTACHMENT){ + + MegaNodeList nodeList = msg.getMegaNodeList(); + if (nodeList != null) { + + if (nodeList.size() == 1) { + MegaNode node = nodeList.get(0); + log("---Node Name: " + node.getName()); + messages.add(0,msg); + } + } + } + } + else{ + log("onAttachmentLoaded: msg NULL: end of history"); + if((messages.size())>=NUMBER_MESSAGES_TO_LOAD){ + fullHistoryReceivedOnLoad(); + isLoadingHistory = false; + } + else{ + log("onMessageLoaded:lessNumberReceived"); + if((stateHistory!=MegaChatApi.SOURCE_NONE)&&(stateHistory!=MegaChatApi.SOURCE_ERROR)){ + log("But more history exists --> loadMessages"); + log("G->loadMessages unread is 0"); + isLoadingHistory = true; + stateHistory = megaChatApi.loadMessages(chatId, NUMBER_MESSAGES_TO_LOAD); + log("New state of history: "+stateHistory); + getMoreHistory = false; + if(stateHistory==MegaChatApi.SOURCE_NONE || stateHistory==MegaChatApi.SOURCE_ERROR){ + fullHistoryReceivedOnLoad(); + isLoadingHistory = false; + } + } + else{ + fullHistoryReceivedOnLoad(); + isLoadingHistory = false; + } + } + } + } + + public void fullHistoryReceivedOnLoad() { + log("fullHistoryReceivedOnLoad"); + if(messages.size()!=0){ + if(adapter==null){ + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + adapter.setHasStableIds(true); + listView.setLayoutManager(mLayoutManager); + listView.setAdapter(adapter); + adapter.setMessages(messages); + } + else{ + + //adapter.loadPreviousMessages(messages, bufferMessages.size()); + + } + + } + } @Override diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index b3c1e39c53f..30f7fa531f6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -301,9 +301,8 @@ public NodeAttachmentHistoryAdapter(Context _context, ArrayList } } - public void setNodes(ArrayList messages) { - log("setNodes"); -// contentTextFragment.setText(getInfoFolder(node)); + public void setMessages(ArrayList messages) { + this.messages = messages; notifyDataSetChanged(); } diff --git a/app/src/main/res/layout/activity_node_history.xml b/app/src/main/res/layout/activity_node_history.xml new file mode 100644 index 00000000000..e8dcdffcfd7 --- /dev/null +++ b/app/src/main/res/layout/activity_node_history.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 49c6f301e85..1dd88872626 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2260,4 +2260,7 @@ Last seen today at %1$s Last seen a long time ago Last seen %1$s at %2$s + + [B]No [/B][A]Shared Files[/A][B].[/B] + From 0bb9b6b20194e84216674276ff2908f1aa11160b Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 4 Dec 2018 15:00:20 +0100 Subject: [PATCH 167/247] Adapt the incoming call notification that is shown when there is already a call in progress --- .../app/fcm/ChatAdvancedNotificationBuilder.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java b/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java index b398075f6c8..6101002cec4 100644 --- a/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java +++ b/app/src/main/java/mega/privacy/android/app/fcm/ChatAdvancedNotificationBuilder.java @@ -929,7 +929,6 @@ public void showIncomingCallNotification(MegaChatCall callToAnswer, MegaChatCall NotificationCompat.Builder notificationBuilderO = new NotificationCompat.Builder(context, notificationChannelIdIncomingCall); notificationBuilderO .setSmallIcon(R.drawable.ic_stat_notify) - .setContentTitle(chatToAnswer.getPeerFullname(0)) .setContentText(context.getString(R.string.notification_subtitle_incoming)) .setAutoCancel(false) .setVibrate(pattern) @@ -939,6 +938,13 @@ public void showIncomingCallNotification(MegaChatCall callToAnswer, MegaChatCall .setPriority(NotificationManager.IMPORTANCE_HIGH) .setFullScreenIntent(pendingIntentAnswer, true); + if(chatToAnswer.isGroup()){ + notificationBuilderO.setContentTitle(chatToAnswer.getTitle()); + } + else{ + notificationBuilderO.setContentTitle(chatToAnswer.getPeerFullname(0)); + } + Bitmap largeIcon = setUserAvatar(chatToAnswer); if (largeIcon != null) { notificationBuilderO.setLargeIcon(largeIcon); @@ -951,13 +957,19 @@ public void showIncomingCallNotification(MegaChatCall callToAnswer, MegaChatCall //No sound just vibration NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_notify) - .setContentTitle(chatToAnswer.getPeerFullname(0)) .setContentText(context.getString(R.string.notification_subtitle_incoming)) .setAutoCancel(false) .setVibrate(pattern) .addAction(actionIgnore) .addAction(actionAnswer); + if(chatToAnswer.isGroup()){ + notificationBuilder.setContentTitle(chatToAnswer.getTitle()); + } + else{ + notificationBuilder.setContentTitle(chatToAnswer.getPeerFullname(0)); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notificationBuilder.setColor(ContextCompat.getColor(context, R.color.mega)); } From dedb2e3ac2eff06188e5984913f66091a8a0fd4c Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Tue, 4 Dec 2018 15:08:19 +0100 Subject: [PATCH 168/247] Bug #11020-There is some strange behaviour when the Recovery Key is saved for offline --- .../adapters/MegaOfflineLollipopAdapter.java | 54 ++++++++++--------- .../OfflineFragmentLollipop.java | 7 +-- app/src/main/res/layout/item_offline_grid.xml | 3 +- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java index 6f038064aef..df6b40b016d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java @@ -430,7 +430,8 @@ public MegaOfflineLollipopAdapter(OfflineFragmentLollipop _fragment, Context _co this.positionClicked = -1; //After this.listFragment = listView; - this.mOffList = insertPlaceHolderNode(_mOffList); +// this.mOffList = insertPlaceHolderNode(_mOffList); + setNodes(_mOffList); } public void setRecylerView(RecyclerView recylerView) { @@ -470,6 +471,7 @@ public void setNodes(ArrayList mOffList){ } this.mOffList = insertPlaceHolderNode(mOffList); + ((OfflineFragmentLollipop) fragment).addSectionTitle(this.mOffList); positionClicked = -1; notifyDataSetChanged(); } @@ -632,29 +634,29 @@ public void onBindViewHolderGrid (ViewHolderOfflineGrid holder, int position){ holder.itemLayout.setVisibility(View.INVISIBLE); return; } - if(currentNode.getHandle().equals("0")){ - //The node is the MasterKey File - holder.textViewFileName.setText(currentNode.getName()); - - String path = Environment.getExternalStorageDirectory().getAbsolutePath()+Util.rKFile; - File file= new File(path); - long nodeSize; - if(file.exists()){ - nodeSize = file.length(); - holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); - } - holder.iconView.setImageResource(MimeTypeThumbnail.typeForName(currentNode.getName()).getIconResourceId()); - holder.iconView.setVisibility(View.VISIBLE); - holder.imageView.setVisibility(View.GONE); - holder.imageButtonThreeDots.setTag(holder); - holder.imageButtonThreeDots.setOnClickListener(this); - - holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid)); - holder.separator.setBackgroundColor(ContextCompat.getColor(context, R.color.new_background_fragment)); - -// holder.imageButtonThreeDots.setVisibility(View.VISIBLE); - return; - } +// if(currentNode.getHandle().equals("0")){ +// //The node is the MasterKey File +// holder.textViewFileName.setText(currentNode.getName()); +// +// String path = Environment.getExternalStorageDirectory().getAbsolutePath()+Util.rKFile; +// File file= new File(path); +// long nodeSize; +// if(file.exists()){ +// nodeSize = file.length(); +// holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); +// } +// holder.iconView.setImageResource(MimeTypeThumbnail.typeForName(currentNode.getName()).getIconResourceId()); +// holder.iconView.setVisibility(View.VISIBLE); +// holder.imageView.setVisibility(View.GONE); +// holder.imageButtonThreeDots.setTag(holder); +// holder.imageButtonThreeDots.setOnClickListener(this); +// +// holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.background_item_grid)); +// holder.separator.setBackgroundColor(ContextCompat.getColor(context, R.color.new_background_fragment)); +// +//// holder.imageButtonThreeDots.setVisibility(View.VISIBLE); +// return; +// } String path=null; @@ -724,11 +726,11 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){ holder.imageView.setVisibility(View.GONE); holder.iconView.setVisibility(View.VISIBLE); - if (currentFile.isFile()){ + if (currentFile.isFile() || currentNode.getHandle().equals("0")){ holder.itemLayout.setVisibility(View.VISIBLE); holder.folderLayout.setVisibility(View.GONE); holder.fileLayout.setVisibility(View.VISIBLE); - + holder.itemLayout.setVisibility(View.VISIBLE); holder.folderLayout.setVisibility(View.GONE); // holder.imageViewThumb.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java index d576d27c80c..361d45dd84e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/OfflineFragmentLollipop.java @@ -593,7 +593,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { adapter.setRecylerView(recyclerView); // adapter.setAdapterType(MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_LIST); } - + return v; } else{ @@ -753,7 +753,6 @@ else if(checkOffline.getOrigin()==MegaOffline.INBOX){ } if(adapter!=null){ - addSectionTitle(mOffList); adapter.setNodes(mOffList); adapter.setPositionClicked(-1); @@ -853,7 +852,6 @@ public void sortByNameDescending(){ mOffList.clear(); mOffList.addAll(tempOffline); if (adapter!= null) { - addSectionTitle(mOffList); adapter.setNodes(mOffList); } // contentText.setText(getInfoFolder(mOffList)); @@ -925,7 +923,6 @@ public void sortByNameAscending() { mOffList.clear(); mOffList.addAll(tempOffline); if (adapter!= null) { - addSectionTitle(mOffList); adapter.setNodes(mOffList); } // contentText.setText(getInfoFolder(mOffList)); @@ -1164,7 +1161,6 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){ } } // contentText.setText(getInfoFolder(mOffList)); - addSectionTitle(mOffList); adapter.setNodes(mOffList); if(orderGetChildren == MegaApiJava.ORDER_DEFAULT_DESC){ @@ -1610,7 +1606,6 @@ public void setNodes(ArrayList _mOff){ this.mOffList = _mOff; if (adapter != null){ - addSectionTitle(mOffList); adapter.setNodes(mOffList); if (adapter.getItemCount() == 0){ recyclerView.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/item_offline_grid.xml b/app/src/main/res/layout/item_offline_grid.xml index 921176e6847..0e72da8153b 100644 --- a/app/src/main/res/layout/item_offline_grid.xml +++ b/app/src/main/res/layout/item_offline_grid.xml @@ -95,9 +95,10 @@ android:layout_below="@+id/file_grid_thumbnail_layout_for_file"> Date: Wed, 5 Dec 2018 10:19:06 +0100 Subject: [PATCH 169/247] Bug #11091 - Add verification and management of errors to httpServerGetLocalLink to avoid null pointer when trying to open a file with another app ("open with" menu option) --- .../UtilsModalBottomSheet.java | 20 +++++++++++++++---- app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/UtilsModalBottomSheet.java b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/UtilsModalBottomSheet.java index 23a8150dd7a..bf1941050c6 100644 --- a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/UtilsModalBottomSheet.java +++ b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/UtilsModalBottomSheet.java @@ -86,6 +86,8 @@ public static int getPeekHeight (LinearLayout items_layout, int heightDisplay, C public static void openWith (MegaApiAndroid megaApi, Context context, MegaNode node) { log("openWith"); + boolean isError = false; + String mimeType = MimeTypeList.typeForName(node.getName()).getType(); log("FILENAME: " + node.getName()); @@ -130,14 +132,24 @@ public static void openWith (MegaApiAndroid megaApi, Context context, MegaNode n String url = megaApi.httpServerGetLocalLink(node); - mediaIntent.setDataAndType(Uri.parse(url), mimeType); + if(url==null){ + isError=true; + } + else{ + mediaIntent.setDataAndType(Uri.parse(url), mimeType); + } } - if (MegaApiUtils.isIntentAvailable(context, mediaIntent)){ - context.startActivity(mediaIntent); + if(isError){ + Toast.makeText(context, context.getResources().getString(R.string.error_open_file_with), Toast.LENGTH_LONG).show(); } else{ - Toast.makeText(context, context.getResources().getString(R.string.intent_not_available), Toast.LENGTH_LONG).show(); + if (MegaApiUtils.isIntentAvailable(context, mediaIntent)){ + context.startActivity(mediaIntent); + } + else{ + Toast.makeText(context, context.getResources().getString(R.string.intent_not_available), Toast.LENGTH_LONG).show(); + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 198c5aa26a3..ec4607d7a1f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2259,4 +2259,6 @@ Last seen a long time ago Last seen %1$s at %2$s + Error. The file cannot be opened. + From ba78d8953cc5de2887abd6bdf9a4d1fd884877de Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Wed, 5 Dec 2018 10:27:42 +0100 Subject: [PATCH 170/247] Improve multiselect mode --- .../lollipop/adapters/MegaNodeAdapter.java | 453 +++++------------- .../main/res/layout/item_file_grid_new.xml | 11 +- 2 files changed, 127 insertions(+), 337 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java index d5bcf147a20..7dab22d35c8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java @@ -142,106 +142,36 @@ public int getPlaceholderCount() { public void toggleAllSelection(int pos) { log("toggleAllSelection: " + pos); - final int positionToflip = pos; - - if (selectedItems.get(pos,false)) { - log("delete pos: " + pos); - selectedItems.delete(pos); - - } else { - log("PUT pos: " + pos); - selectedItems.put(pos,true); - } - - if (adapterType == MegaNodeAdapter.ITEM_VIEW_TYPE_LIST) { - log("adapter type is LIST"); - MegaNodeAdapter.ViewHolderBrowserList view = (MegaNodeAdapter.ViewHolderBrowserList)listFragment.findViewHolderForLayoutPosition(pos); - if (view != null) { - log("Start animation: " + pos + " multiselection state: " + isMultipleSelect()); - Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); - flipAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) { - - } - - @Override - public void onAnimationEnd(Animation animation) { - log("onAnimationEnd: " + selectedItems.size()); - if (selectedItems.size() <= 0) { - log("toggleAllSelection: hideMultipleSelect"); - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - }else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } - } - log("toggleAllSelection: notified item changed"); - notifyItemChanged(positionToflip); - } - - @Override - public void onAnimationRepeat(Animation animation) { - - } - }); - view.imageView.startAnimation(flipAnimation); - } else { - log("NULL view pos: " + positionToflip); - notifyItemChanged(pos); - } - } else { - log("adapter type is GRID"); - if (selectedItems.size() <= 0) { - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - } else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } - } - notifyItemChanged(positionToflip); - } + putOrDeletePostion(pos); +// startAnimation(pos, true); } public void toggleSelection(int pos) { log("toggleSelection: " + pos); + putOrDeletePostion(pos); +// startAnimation(pos, false); + } + + void putOrDeletePostion(int pos) { + + boolean delete; + if (selectedItems.get(pos,false)) { log("delete pos: " + pos); + delete = true; selectedItems.delete(pos); } else { log("PUT pos: " + pos); + delete = false; selectedItems.put(pos,true); } - notifyItemChanged(pos); + startAnimation(pos, delete); + } + + void startAnimation (int pos, final boolean delete) { + final int positionToflip = pos; + if (adapterType == MegaNodeAdapter.ITEM_VIEW_TYPE_LIST) { log("adapter type is LIST"); MegaNodeAdapter.ViewHolderBrowserList view = (MegaNodeAdapter.ViewHolderBrowserList)listFragment.findViewHolderForLayoutPosition(pos); @@ -251,31 +181,16 @@ public void toggleSelection(int pos) { flipAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { - + if (!delete) { + notifyItemChanged(positionToflip); + } } @Override public void onAnimationEnd(Animation animation) { - if (selectedItems.size() <= 0) { - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - } else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } + hideMultipleSelect(); + if (delete) { + notifyItemChanged(positionToflip); } } @@ -287,29 +202,11 @@ public void onAnimationRepeat(Animation animation) { view.imageView.startAnimation(flipAnimation); - } else { + } + else { log("view is null - not animation"); - if (selectedItems.size() <= 0) { - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - }else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } - } + hideMultipleSelect(); + notifyItemChanged(positionToflip); } } else { log("adapter type is GRID"); @@ -321,31 +218,16 @@ public void onAnimationRepeat(Animation animation) { flipAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { - + if (!delete) { + notifyItemChanged(positionToflip); + } } @Override public void onAnimationEnd(Animation animation) { - if (selectedItems.size() <= 0) { - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - } else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } + hideMultipleSelect(); + if (delete) { + notifyItemChanged(positionToflip); } } @@ -354,36 +236,44 @@ public void onAnimationRepeat(Animation animation) { } }); - if (view.folderLayout.getVisibility() == View.VISIBLE) { - view.imageViewIcon.startAnimation(flipAnimation); - } - else { - view.fileGridSelected.startAnimation(flipAnimation); + MegaNode node = (MegaNode)getItem(pos); + if (node != null) { + if (node.isFolder()) { + view.imageViewIcon.startAnimation(flipAnimation); + } + else { + view.fileGridSelected.startAnimation(flipAnimation); + } } } else { log("view is null - not animation"); - if (selectedItems.size() <= 0) { - if (type == Constants.RUBBISH_BIN_ADAPTER) { - ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INBOX_ADAPTER) { - ((InboxFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.INCOMING_SHARES_ADAPTER) { - ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); - } else if (type == Constants.CONTACT_FILE_ADAPTER) { - ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); - } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); - } else if (type == Constants.FOLDER_LINK_ADAPTER) { - ((FolderLinkActivityLollipop)context).hideMultipleSelect(); - } else if (type == Constants.SEARCH_ADAPTER) { - ((SearchFragmentLollipop)fragment).hideMultipleSelect(); - } else { - ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); - } - } + hideMultipleSelect(); + notifyItemChanged(positionToflip); + } + } + } + + void hideMultipleSelect () { + if (selectedItems.size() <= 0) { + if (type == Constants.RUBBISH_BIN_ADAPTER) { + ((RubbishBinFragmentLollipop)fragment).hideMultipleSelect(); + } else if (type == Constants.INBOX_ADAPTER) { + ((InboxFragmentLollipop)fragment).hideMultipleSelect(); + } else if (type == Constants.INCOMING_SHARES_ADAPTER) { + ((IncomingSharesFragmentLollipop)fragment).hideMultipleSelect(); + } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { + ((OutgoingSharesFragmentLollipop)fragment).hideMultipleSelect(); + } else if (type == Constants.CONTACT_FILE_ADAPTER) { + ((ContactFileListFragmentLollipop)fragment).hideMultipleSelect(); + } else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){ + ((ContactSharedFolderFragment) fragment).hideMultipleSelect(); + } else if (type == Constants.FOLDER_LINK_ADAPTER) { + ((FolderLinkActivityLollipop)context).hideMultipleSelect(); + } else if (type == Constants.SEARCH_ADAPTER) { + ((SearchFragmentLollipop)fragment).hideMultipleSelect(); + } else { + ((FileBrowserFragmentLollipop)fragment).hideMultipleSelect(); } } } @@ -742,7 +632,7 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { if (type == Constants.FOLDER_LINK_ADAPTER) { holder.textViewFileSize.setText(MegaApiUtils.getInfoFolder(node,context,megaApi)); - setFolderSelected(holder,position,R.drawable.ic_folder_list); + setFolderGridSelected(holder,position,R.drawable.ic_folder_list); } else { holder.textViewFileSize.setText(MegaApiUtils.getInfoFolder(node,context)); } @@ -751,7 +641,7 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { holder.thumbLayout.setBackgroundColor(Color.TRANSPARENT); if (type == Constants.INCOMING_SHARES_ADAPTER) { - setFolderSelected(holder,position,R.drawable.ic_folder_incoming); + setFolderGridSelected(holder,position,R.drawable.ic_folder_incoming); //Show the owner of the shared folder ArrayList sharesIncoming = megaApi.getInSharesList(); for (int j = 0;j < sharesIncoming.size();j++) { @@ -776,7 +666,7 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { } } } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - setFolderSelected(holder,position,R.drawable.ic_folder_outgoing); + setFolderGridSelected(holder,position,R.drawable.ic_folder_outgoing); //Show the number of contacts who shared the folder ArrayList sl = megaApi.getOutShares(node); if (sl != null) { @@ -786,23 +676,23 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { } } else if (type == Constants.FILE_BROWSER_ADAPTER) { if (node.isOutShare() || megaApi.isPendingShare(node)) { - setFolderSelected(holder,position,R.drawable.ic_folder_outgoing); + setFolderGridSelected(holder,position,R.drawable.ic_folder_outgoing); } else if (node.isInShare()) { - setFolderSelected(holder,position,R.drawable.ic_folder_incoming); + setFolderGridSelected(holder,position,R.drawable.ic_folder_incoming); } else { if (((ManagerActivityLollipop)context).isCameraUploads(node)) { - setFolderSelected(holder,position,R.drawable.ic_folder_image); + setFolderGridSelected(holder,position,R.drawable.ic_folder_image); } else { - setFolderSelected(holder,position,R.drawable.ic_folder); + setFolderGridSelected(holder,position,R.drawable.ic_folder); } } } else { if (node.isOutShare() || megaApi.isPendingShare(node)) { - setFolderSelected(holder,position,R.drawable.ic_folder_outgoing); + setFolderGridSelected(holder,position,R.drawable.ic_folder_outgoing); } else if (node.isInShare()) { - setFolderSelected(holder,position,R.drawable.ic_folder_incoming); + setFolderGridSelected(holder,position,R.drawable.ic_folder_incoming); } else { - setFolderSelected(holder,position,R.drawable.ic_folder); + setFolderGridSelected(holder,position,R.drawable.ic_folder); } } } else if (node.isFile()) { @@ -823,15 +713,17 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { holder.fileGridIconForFile.setImageResource(MimeTypeThumbnail.typeForName(node.getName()).getIconResourceId()); holder.thumbLayoutForFile.setBackgroundColor(Color.TRANSPARENT); - if (multipleSelect && isItemChecked(position)) { + if (isMultipleSelect() && isItemChecked(position)) { // holder.itemLayout.setForeground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); - holder.fileGridSelected.setVisibility(View.VISIBLE); + holder.fileGridSelected.setImageResource(R.drawable.ic_select_folder); +// holder.fileGridSelected.setVisibility(View.VISIBLE); } else { // holder.itemLayout.setForeground(new ColorDrawable()); holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); - holder.fileGridSelected.setVisibility(View.GONE); + holder.fileGridSelected.setImageDrawable(null); +// holder.fileGridSelected.setVisibility(View.GONE); } if (Util.isVideoFile(node.getName())) { @@ -951,8 +843,8 @@ else if (inbox){ } } - private void setFolderSelected(ViewHolderBrowserGrid holder,int position,int folderDrawableResId) { - if (multipleSelect && isItemChecked(position)) { + private void setFolderGridSelected(ViewHolderBrowserGrid holder, int position, int folderDrawableResId) { + if (isMultipleSelect() && isItemChecked(position)) { RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageViewIcon.getLayoutParams(); paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,24,context.getResources().getDisplayMetrics()); paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,24,context.getResources().getDisplayMetrics()); @@ -965,6 +857,22 @@ private void setFolderSelected(ViewHolderBrowserGrid holder,int position,int fol } } + private void setFolderListSelected (ViewHolderBrowserList holder, int position, int folderDrawableResId) { + if (isMultipleSelect() && isItemChecked(position)) { + RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); + paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); + paramsMultiselect.setMargins(0,0,0,0); + holder.imageView.setLayoutParams(paramsMultiselect); + holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); + holder.imageView.setImageResource(R.drawable.ic_select_folder); + } + else { + holder.itemLayout.setBackgroundColor(Color.WHITE); + holder.imageView.setImageResource(folderDrawableResId); + } + } + public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { log("onBindViewHolderList: " + position); @@ -1009,43 +917,9 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { if (type == Constants.FOLDER_LINK_ADAPTER) { holder.textViewFileSize.setText(MegaApiUtils.getInfoFolder(node,context,megaApi)); - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } else { - - if (this.isItemChecked(position)) { - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } - } + setFolderListSelected(holder, position, R.drawable.ic_folder_list); } else if (type == Constants.CONTACT_FILE_ADAPTER|| type == Constants.CONTACT_SHARED_FOLDER_ADAPTER){ - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - - if (this.isItemChecked(position)) { - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } - } + setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list); boolean firstLevel; if(type == Constants.CONTACT_FILE_ADAPTER){ @@ -1070,24 +944,7 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { } } else if (type == Constants.INCOMING_SHARES_ADAPTER) { holder.publicLinkImage.setVisibility(View.INVISIBLE); - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - - if (this.isItemChecked(position)) { - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } - } + setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list); //Show the owner of the shared folder ArrayList sharesIncoming = megaApi.getInSharesList(); @@ -1131,24 +988,7 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { } } else if (type == Constants.OUTGOING_SHARES_ADAPTER) { - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } else { - - if (this.isItemChecked(position)) { - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } - } + setFolderListSelected(holder, position, R.drawable.ic_folder_outgoing_list); //Show the number of contacts who shared the folder ArrayList sl = megaApi.getOutShares(node); if (sl != null) { @@ -1157,76 +997,25 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { } } } else if (type == Constants.FILE_BROWSER_ADAPTER) { - - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - if (node.isOutShare() || megaApi.isPendingShare(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } else if (node.isInShare()) { - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - if (((ManagerActivityLollipop)context).isCameraUploads(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_image_list); - } else { - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } - } - } else { - - if (this.isItemChecked(position)) { - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - if (node.isOutShare() || megaApi.isPendingShare(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } else if (node.isInShare()) { - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - if (((ManagerActivityLollipop)context).isCameraUploads(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_image_list); - } else { - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } - } - } + if (node.isOutShare() || megaApi.isPendingShare(node)) { + setFolderListSelected(holder, position, R.drawable.ic_folder_outgoing_list); + } + else if (node.isInShare()) { + setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list); + } + else { + setFolderListSelected(holder, position, R.drawable.ic_folder_list); } } else { - if (!multipleSelect) { - holder.itemLayout.setBackgroundColor(Color.WHITE); - if (node.isOutShare() || megaApi.isPendingShare(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } else if (node.isInShare()) { - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } - } else { - - if (this.isItemChecked(position)) { - holder.itemLayout.setBackgroundColor(ContextCompat.getColor(context,R.color.new_multiselect_color)); - RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageView.getLayoutParams(); - paramsMultiselect.height = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics()); - paramsMultiselect.setMargins(0,0,0,0); - holder.imageView.setLayoutParams(paramsMultiselect); - holder.imageView.setImageResource(R.drawable.ic_select_folder); - } else { - holder.itemLayout.setBackgroundColor(Color.WHITE); - if (node.isOutShare() || megaApi.isPendingShare(node)) { - holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_list); - } else if (node.isInShare()) { - holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list); - } else { - holder.imageView.setImageResource(R.drawable.ic_folder_list); - } - } + if (node.isOutShare() || megaApi.isPendingShare(node)) { + setFolderListSelected(holder, position, R.drawable.ic_folder_outgoing_list); + } + else if (node.isInShare()) { + setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list); + } + else { + setFolderListSelected(holder, position, R.drawable.ic_folder_list); } } } else { diff --git a/app/src/main/res/layout/item_file_grid_new.xml b/app/src/main/res/layout/item_file_grid_new.xml index abad441c0c2..38796e6833d 100644 --- a/app/src/main/res/layout/item_file_grid_new.xml +++ b/app/src/main/res/layout/item_file_grid_new.xml @@ -29,11 +29,12 @@ android:scaleType="fitCenter"/> + android:visibility="visible"/> Date: Wed, 5 Dec 2018 10:54:28 +0100 Subject: [PATCH 171/247] Remove unnecessary chat signal presence --- .../android/app/lollipop/megachat/ChatActivityLollipop.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 53ee7733afc..bf7788419e1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -2729,10 +2729,6 @@ public void attachFromFileStorage(){ public void attachFromCloud(){ log("attachFromCloud"); - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } - if(megaApi!=null && megaApi.getRootNode()!=null){ ChatController chatC = new ChatController(this); chatC.pickFileToSend(); From b5d346350da66ce44d2a71351172228f6a6863d1 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Wed, 5 Dec 2018 16:10:51 +0100 Subject: [PATCH 172/247] Feature #10972 - Chat node history --- .../megachat/ChatActivityLollipop.java | 4 +- .../NodeAttachmentHistoryActivity.java | 190 ++++++++++++++++-- .../NodeAttachmentHistoryAdapter.java | 34 ++++ .../app/utils/ThumbnailUtilsLollipop.java | 10 + .../main/res/layout/activity_node_history.xml | 4 +- 5 files changed, 217 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 9cb51771523..83bdbe8ed7c 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -4768,7 +4768,8 @@ else if(msg.getType()==MegaChatMessage.TYPE_TRUNCATE){ @Override public void onMessageUpdate(MegaChatApiJava api, MegaChatMessage msg) { -// log("onMessageUpdate!: "+ msg.getMsgId()); + log("onMessageUpdate!: "+ msg.getMsgId()); + int resultModify = -1; if(msg.isDeleted()){ log("The message has been deleted"); @@ -5199,7 +5200,6 @@ public void loadBufferMessages(){ adapter.setMessages(messages); } else{ -// adapter.setPositionClicked(-1); adapter.loadPreviousMessages(messages, bufferMessages.size()); log("addMessage: "+messages.size()); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index c10ec92f9fb..bc77aff7562 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -38,10 +38,12 @@ import java.util.ArrayList; import java.util.List; +import java.util.ListIterator; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; import mega.privacy.android.app.components.PositionDividerItemDecoration; +import mega.privacy.android.app.components.SimpleDividerItemDecoration; import mega.privacy.android.app.lollipop.LoginActivityLollipop; import mega.privacy.android.app.lollipop.ManagerActivityLollipop; import mega.privacy.android.app.lollipop.PinActivityLollipop; @@ -88,6 +90,7 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement ImageView emptyImageView; ArrayList messages; + ArrayList bufferMessages; MegaChatRoom chatRoom; @@ -97,6 +100,7 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement boolean isLoadingHistory = false; private ActionMode actionMode; + DisplayMetrics outMetrics; ProgressDialog statusDialog; @@ -145,6 +149,7 @@ protected void onCreate(Bundle savedInstanceState) { megaChatApi.addNodeHistoryListener(chatId,this); handler = new Handler(); + outMetrics = new DisplayMetrics (); Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics (); @@ -174,7 +179,7 @@ protected void onCreate(Bundle savedInstanceState) { detector = new GestureDetectorCompat(this, new RecyclerViewOnGestureListener()); listView = (RecyclerView) findViewById(R.id.node_history_list_view); - listView.setPadding(0, 0, 0, Util.scaleHeightPx(85, outMetrics)); + listView.setPadding(0,Util.scaleHeightPx(8, outMetrics),0,Util.scaleHeightPx(16, outMetrics)); listView.setClipToPadding(false); listView.addItemDecoration(new PositionDividerItemDecoration(this, outMetrics)); mLayoutManager = new LinearLayoutManager(this); @@ -195,13 +200,13 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { scrollingUp = false; } - if(!scrollingUp){ + if(scrollingUp){ int pos = mLayoutManager.findFirstVisibleItemPosition(); if(pos<=NUMBER_MESSAGES_BEFORE_LOAD&&getMoreHistory){ - log("DE->loadMessages:scrolling up"); + log("DE->loadAttachments:scrolling up"); isLoadingHistory = true; - stateHistory = megaChatApi.loadMessages(chatId, NUMBER_MESSAGES_TO_LOAD); + stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); getMoreHistory = false; } } @@ -249,10 +254,10 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if(chatRoom!=null){ messages = new ArrayList<>(); + bufferMessages = new ArrayList(); if (messages.size() != 0){ emptyLayout.setVisibility(View.GONE); - listView.setVisibility(View.VISIBLE); } else{ @@ -272,6 +277,17 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { listView.setAdapter(adapter); adapter.setMultipleSelect(false); + listView.setLayoutManager(mLayoutManager); + listView.addItemDecoration(new SimpleDividerItemDecoration(this, outMetrics)); + listView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + checkScroll(); + } + }); + + adapter.setMessages(messages); isLoadingHistory = true; stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); @@ -753,24 +769,26 @@ public void onAttachmentLoaded(MegaChatApiJava api, MegaChatMessage msg) { if (nodeList.size() == 1) { MegaNode node = nodeList.get(0); log("---Node Name: " + node.getName()); - messages.add(0,msg); + bufferMessages.add(msg); + log("onMessageLoaded: Size of buffer: "+bufferMessages.size()); + log("onMessageLoaded: Size of messages: "+messages.size()); } } } } else{ log("onAttachmentLoaded: msg NULL: end of history"); - if((messages.size())>=NUMBER_MESSAGES_TO_LOAD){ + if((bufferMessages.size()+messages.size())>=NUMBER_MESSAGES_TO_LOAD){ fullHistoryReceivedOnLoad(); isLoadingHistory = false; } else{ - log("onMessageLoaded:lessNumberReceived"); + log("onAttachmentLoaded:lessNumberReceived"); if((stateHistory!=MegaChatApi.SOURCE_NONE)&&(stateHistory!=MegaChatApi.SOURCE_ERROR)){ - log("But more history exists --> loadMessages"); - log("G->loadMessages unread is 0"); + log("But more history exists --> loadAttachments"); + log("G->loadAttachments unread is 0"); isLoadingHistory = true; - stateHistory = megaChatApi.loadMessages(chatId, NUMBER_MESSAGES_TO_LOAD); + stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); log("New state of history: "+stateHistory); getMoreHistory = false; if(stateHistory==MegaChatApi.SOURCE_NONE || stateHistory==MegaChatApi.SOURCE_ERROR){ @@ -787,38 +805,166 @@ public void onAttachmentLoaded(MegaChatApiJava api, MegaChatMessage msg) { } public void fullHistoryReceivedOnLoad() { - log("fullHistoryReceivedOnLoad"); - if(messages.size()!=0){ - if(adapter==null){ - adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); - adapter.setHasStableIds(true); - listView.setLayoutManager(mLayoutManager); - listView.setAdapter(adapter); - adapter.setMessages(messages); + log("fullHistoryReceivedOnLoad: "+messages.size()); + + if(bufferMessages.size()!=0) { + log("fullHistoryReceivedOnLoad:buffer size: " + bufferMessages.size()); + emptyLayout.setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); + + ListIterator itr = bufferMessages.listIterator(); + while (itr.hasNext()) { + int currentIndex = itr.nextIndex(); + MegaChatMessage messageToShow = itr.next(); + messages.add(messageToShow); } - else{ - //adapter.loadPreviousMessages(messages, bufferMessages.size()); + if(messages.size()!=0){ + if(adapter==null){ + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + listView.setLayoutManager(mLayoutManager); + listView.addItemDecoration(new SimpleDividerItemDecoration(this, outMetrics)); + listView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + checkScroll(); + } + }); + listView.setAdapter(adapter); + adapter.setMessages(messages); + } + else{ + adapter.loadPreviousMessages(messages, bufferMessages.size()); + } } - + bufferMessages.clear(); } + log("fullHistoryReceivedOnLoad:getMoreHistoryTRUE"); + getMoreHistory = true; + } @Override public void onAttachmentReceived(MegaChatApiJava api, MegaChatMessage msg) { log("onAttachmentReceived"); + + log("STATUS: "+msg.getStatus()); + log("TEMP ID: "+msg.getTempId()); + log("FINAL ID: "+msg.getMsgId()); + log("TIMESTAMP: "+msg.getTimestamp()); + log("TYPE: "+msg.getType()); + + int lastIndex = 0; + if(messages.size()==0){ + messages.add(msg); + } + else{ + log("status of message: "+msg.getStatus()); + + while(messages.get(lastIndex).getMsgIndex()>msg.getMsgIndex()){ + lastIndex++; + } + + log("Append in position: "+lastIndex); + messages.add(lastIndex, msg); + } + + //Create adapter + if(adapter==null){ + log("Create adapter"); + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + listView.setLayoutManager(mLayoutManager); + listView.addItemDecoration(new SimpleDividerItemDecoration(this, outMetrics)); + listView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + checkScroll(); + } + }); + listView.setAdapter(adapter); + adapter.setMessages(messages); + }else{ + log("Update adapter with last index: "+lastIndex); + if(lastIndex<0){ + log("Arrives the first message of the chat"); + adapter.setMessages(messages); + } + else{ + adapter.addMessage(messages, lastIndex+1); + adapter.notifyItemChanged(lastIndex); + } + } + + emptyLayout.setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); } @Override public void onAttachmentDeleted(MegaChatApiJava api, long msgid) { log("onAttachmentDeleted"); + + int indexToChange = -1; + + ListIterator itr = messages.listIterator(); + while (itr.hasNext()) { + MegaChatMessage messageToCheck = itr.next(); + if (messageToCheck.getTempId() == msgid) { + indexToChange = itr.previousIndex(); + break; + } + if (messageToCheck.getMsgId() == msgid) { + indexToChange = itr.previousIndex(); + break; + } + } + + if(indexToChange!=-1) { + messages.remove(indexToChange); + log("Removed index: " + indexToChange + " messages size: " + messages.size()); + + adapter.removeMessage(indexToChange, messages); + + if(messages.isEmpty()){ + emptyLayout.setVisibility(View.VISIBLE); + listView.setVisibility(View.GONE); + } + } + else{ + log("Index to remove not found"); + } } @Override public void onTruncate(MegaChatApiJava api, long msgid) { log("onTruncate"); + invalidateOptionsMenu(); + messages.clear(); + } + + public void checkScroll () { + if (listView != null) { + if (listView.canScrollVertically(-1) || (adapter != null && adapter.isMultipleSelect())) { + changeActionBarElevation(true); + } + else { + changeActionBarElevation(false); + } + } + } + + public void changeActionBarElevation(boolean whitElevation){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { +// if (whitElevation) { +// abL.setElevation(Util.px2dp(4, outMetrics)); +// } +// else { +// abL.setElevation(0); +// } + } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index 30f7fa531f6..bc3751fc55d 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -810,6 +810,40 @@ public void onClick(View v) { } } + public void loadPreviousMessages(ArrayList messages, int counter) { + log("loadPreviousMessages: " + counter); + this.messages = messages; + notifyItemRangeInserted(messages.size()-counter, counter); + } + + public void addMessage(ArrayList messages, int position) { + log("addMessage: " + position); + this.messages = messages; + notifyItemInserted(position); + if (position == messages.size()) { + log("No need to update more"); + } else { + log("Update until end"); + int itemCount = messages.size() - position; + log("itemCount: " + itemCount); + notifyItemRangeChanged(position, itemCount + 1); + } + } + + public void removeMessage(int position, ArrayList messages) { + log("removeMessage: size: " + messages.size()); + this.messages = messages; + notifyItemRemoved(position); + + if (position == messages.size() - 1) { + log("No need to update more"); + } else { + log("Update until end"); + int itemCount = messages.size() - position; + log("itemCount: " + itemCount); + notifyItemRangeChanged(position, itemCount); + } + } private void threeDotsClicked(int currentPosition,MegaChatMessage m) { log("onClick: file_list_three_dots: " + currentPosition); diff --git a/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java b/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java index 51ea6a40c3e..bd53f5c4257 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/utils/ThumbnailUtilsLollipop.java @@ -412,6 +412,16 @@ else if(holder instanceof VersionsFileAdapter.ViewHolderVersion){ log("Thumbnail update"); } } + else if(holder instanceof NodeAttachmentHistoryAdapter.ViewHolderBrowserList){ + if ((((NodeAttachmentHistoryAdapter.ViewHolderBrowserList)holder).document == handle)){ + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserList)holder).imageView.setImageBitmap(bitmap); + Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in); + ((NodeAttachmentHistoryAdapter.ViewHolderBrowserList)holder).imageView.startAnimation(fadeInAnimation); + int position = holder.getAdapterPosition(); + adapter.notifyItemChanged(position); + log("Thumbnail update"); + } + } } } } diff --git a/app/src/main/res/layout/activity_node_history.xml b/app/src/main/res/layout/activity_node_history.xml index e8dcdffcfd7..e64219b970e 100644 --- a/app/src/main/res/layout/activity_node_history.xml +++ b/app/src/main/res/layout/activity_node_history.xml @@ -25,6 +25,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" + android:layout_below="@id/toolbar_node_history" android:gravity="center_horizontal"> + android:layout_height="match_parent" + android:layout_below="@id/toolbar_node_history"> Date: Fri, 7 Dec 2018 11:54:29 +0100 Subject: [PATCH 173/247] Feature #10972 - Chat node history --- .../lollipop/adapters/MegaNodeAdapter.java | 2 +- .../NodeAttachmentHistoryActivity.java | 10 +- .../NodeAttachmentHistoryAdapter.java | 138 ++++++++++++++---- app/src/main/res/values/strings.xml | 1 + 4 files changed, 122 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java index d5bcf147a20..7bd5a50a238 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java @@ -657,7 +657,7 @@ public MegaNodeAdapter.ViewHolderBrowser onCreateViewHolder(ViewGroup parent, in if (holderGrid.textViewFileSize != null) { holderGrid.textViewFileSize.setVisibility(View.VISIBLE); } else { - log("textViewFileSize is NULL"); + log("textViewMessageInfo is NULL"); } holderGrid.savedOffline.setVisibility(View.INVISIBLE); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index bc77aff7562..fc89e547b00 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -92,7 +92,7 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement ArrayList messages; ArrayList bufferMessages; - MegaChatRoom chatRoom; + public MegaChatRoom chatRoom; NodeAttachmentHistoryAdapter adapter; boolean scrollingUp = false; @@ -361,6 +361,14 @@ public boolean onOptionsItemSelected(MenuItem item) { } } + public void activateActionMode(){ + log("activateActionMode"); + if (!adapter.isMultipleSelect()){ + adapter.setMultipleSelect(true); + actionMode = startSupportActionMode(new NodeAttachmentHistoryActivity.ActionBarCallBack()); + } + } + // Clear all selected items private void clearSelections() { if(adapter.isMultipleSelect()){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index bc3751fc55d..5824bfa1772 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -8,6 +8,7 @@ import android.graphics.drawable.ColorDrawable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.SparseBooleanArray; import android.util.TypedValue; @@ -32,11 +33,16 @@ import mega.privacy.android.app.MimeTypeThumbnail; import mega.privacy.android.app.R; import mega.privacy.android.app.lollipop.ManagerActivityLollipop; +import mega.privacy.android.app.lollipop.controllers.ChatController; +import mega.privacy.android.app.lollipop.listeners.ChatNonContactNameListener; import mega.privacy.android.app.lollipop.managerSections.FileBrowserFragmentLollipop; +import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity; import mega.privacy.android.app.utils.ThumbnailUtils; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; +import mega.privacy.android.app.utils.TimeUtils; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaChatMessage; import nz.mega.sdk.MegaNode; @@ -47,6 +53,7 @@ public class NodeAttachmentHistoryAdapter extends RecyclerView.Adapter messages; @@ -62,6 +69,8 @@ public class NodeAttachmentHistoryAdapter extends RecyclerView.Adapter if (megaApi == null) { megaApi = ((MegaApplication)((Activity)context).getApplication()).getMegaApi(); } + + if (megaChatApi == null) { + megaChatApi = ((MegaApplication) ((Activity) context).getApplication()).getMegaChatApi(); + } + + cC = new ChatController(context); } public void setMessages(ArrayList messages) { @@ -327,14 +348,30 @@ public NodeAttachmentHistoryAdapter.ViewHolderBrowser onCreateViewHolder(ViewGro ViewHolderBrowserList holderList = new ViewHolderBrowserList(v); holderList.itemLayout = (RelativeLayout)v.findViewById(R.id.file_list_item_layout); holderList.imageView = (ImageView)v.findViewById(R.id.file_list_thumbnail); - + holderList.savedOffline = (ImageView)v.findViewById(R.id.file_list_saved_offline); + holderList.publicLinkImage = (ImageView)v.findViewById(R.id.file_list_public_link); holderList.textViewFileName = (TextView)v.findViewById(R.id.file_list_filename); - - holderList.textViewFileSize = (TextView)v.findViewById(R.id.file_list_filesize); - + holderList.textViewMessageInfo = (TextView)v.findViewById(R.id.file_list_filesize); holderList.threeDotsLayout = (RelativeLayout)v.findViewById(R.id.file_list_three_dots_layout); - - holderList.textViewFileSize.setVisibility(View.VISIBLE); + holderList.threeDotsImageView = (ImageView) v.findViewById(R.id.file_list_three_dots); + holderList.versionsIcon = (ImageView) v.findViewById(R.id.file_list_versions_icon); + holderList.textViewMessageInfo.setVisibility(View.VISIBLE); + + RelativeLayout.LayoutParams paramsThreeDotsIcon = (RelativeLayout.LayoutParams) holderList.threeDotsImageView.getLayoutParams(); + paramsThreeDotsIcon.leftMargin = Util.scaleWidthPx(8, outMetrics); + holderList.threeDotsImageView.setLayoutParams(paramsThreeDotsIcon); + + holderList.textViewMessageInfo.setSelected(true); + holderList.textViewMessageInfo.setHorizontallyScrolling(true); + holderList.textViewMessageInfo.setFocusable(true); + holderList.textViewMessageInfo.setEllipsize(TextUtils.TruncateAt.MARQUEE); + holderList.textViewMessageInfo.setMarqueeRepeatLimit(-1); + holderList.textViewMessageInfo.setSingleLine(true); + holderList.textViewMessageInfo.setHorizontallyScrolling(true); + + holderList.savedOffline.setVisibility(View.INVISIBLE); + holderList.versionsIcon.setVisibility(View.GONE); + holderList.publicLinkImage.setVisibility(View.GONE); holderList.itemLayout.setTag(holderList); holderList.itemLayout.setOnClickListener(this); @@ -361,9 +398,10 @@ public NodeAttachmentHistoryAdapter.ViewHolderBrowser onCreateViewHolder(ViewGro holderGrid.textViewFileName = (TextView)v.findViewById(R.id.file_grid_filename); holderGrid.textViewFileNameForFile = (TextView)v.findViewById(R.id.file_grid_filename_for_file); holderGrid.imageButtonThreeDotsForFile = (ImageButton)v.findViewById(R.id.file_grid_three_dots_for_file); - holderGrid.textViewFileSize = (TextView)v.findViewById(R.id.file_grid_filesize); + holderGrid.textViewMessageInfo = (TextView)v.findViewById(R.id.file_grid_filesize); holderGrid.imageButtonThreeDots = (ImageButton)v.findViewById(R.id.file_grid_three_dots); - + holderGrid.savedOffline = (ImageView)v.findViewById(R.id.file_grid_saved_offline); + holderGrid.publicLinkImage = (ImageView)v.findViewById(R.id.file_grid_public_link); holderGrid.separator = (View)v.findViewById(R.id.file_grid_separator); holderGrid.imageViewVideoIcon = (ImageView)v.findViewById(R.id.file_grid_video_icon); @@ -372,16 +410,20 @@ public NodeAttachmentHistoryAdapter.ViewHolderBrowser onCreateViewHolder(ViewGro holderGrid.fileGridSelected = (ImageView)v.findViewById(R.id.file_grid_selected); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - holderGrid.textViewFileSize.setMaxWidth(Util.scaleWidthPx(70,outMetrics)); + holderGrid.textViewMessageInfo.setMaxWidth(Util.scaleWidthPx(70,outMetrics)); } else { - holderGrid.textViewFileSize.setMaxWidth(Util.scaleWidthPx(130,outMetrics)); + holderGrid.textViewMessageInfo.setMaxWidth(Util.scaleWidthPx(130,outMetrics)); } - if (holderGrid.textViewFileSize != null) { - holderGrid.textViewFileSize.setVisibility(View.VISIBLE); + + if (holderGrid.textViewMessageInfo != null) { + holderGrid.textViewMessageInfo.setVisibility(View.VISIBLE); } else { - log("textViewFileSize is NULL"); + log("textViewMessageInfo is NULL"); } + holderGrid.savedOffline.setVisibility(View.INVISIBLE); + holderGrid.publicLinkImage.setVisibility(View.GONE); + holderGrid.itemLayout.setTag(holderGrid); holderGrid.itemLayout.setOnClickListener(this); holderGrid.itemLayout.setOnLongClickListener(this); @@ -421,7 +463,7 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { log("Node : " + position + " " + node.getName()); holder.textViewFileName.setText(node.getName()); - holder.textViewFileSize.setText(""); + holder.textViewMessageInfo.setText(""); holder.videoInfoLayout.setVisibility(View.GONE); holder.itemLayout.setVisibility(View.VISIBLE); @@ -430,11 +472,11 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { holder.imageViewThumb.setVisibility(View.GONE); holder.fileLayout.setVisibility(View.VISIBLE); holder.textViewFileName.setVisibility(View.VISIBLE); - holder.textViewFileSize.setVisibility(View.GONE); + holder.textViewMessageInfo.setVisibility(View.GONE); holder.textViewFileNameForFile.setText(node.getName()); long nodeSize = node.getSize(); - holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); + holder.textViewMessageInfo.setText(Util.getSizeString(nodeSize)); holder.fileGridIconForFile.setVisibility(View.VISIBLE); holder.fileGridIconForFile.setImageResource(MimeTypeThumbnail.typeForName(node.getName()).getIconResourceId()); @@ -558,10 +600,52 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) { Bitmap thumb = null; holder.textViewFileName.setText(node.getName()); - holder.textViewFileSize.setText(""); + holder.textViewMessageInfo.setText(""); - long nodeSize = node.getSize(); - holder.textViewFileSize.setText(Util.getSizeString(nodeSize)); + String date = TimeUtils.formatDateAndTime(m.getTimestamp(), TimeUtils.DATE_LONG_FORMAT); + + if (m.getUserHandle() == megaChatApi.getMyUserHandle()) { + log("MY message handle!!: " + m.getMsgId()); + holder.fullNameTitle = megaChatApi.getMyFullname(); + } + else{ + + long userHandle = m.getUserHandle(); + log("Contact message!!: " + userHandle); + + if (((NodeAttachmentHistoryActivity)context).chatRoom.isGroup()) { + + holder.fullNameTitle = cC.getFullName(userHandle, ((NodeAttachmentHistoryActivity)context).chatRoom); + + if (holder.fullNameTitle == null) { + holder.fullNameTitle = ""; + } + + if (holder.fullNameTitle.trim().length() <= 0) { + + log("NOT found in DB - ((ViewHolderMessageChat)holder).fullNameTitle"); + holder.fullNameTitle = "Unknown name"; + if (!(holder.nameRequestedAction)) { + log("3-Call for nonContactName: " + m.getUserHandle()); + holder.nameRequestedAction = true; + ChatNonContactNameListener listener = new ChatNonContactNameListener(context, holder, this, userHandle); + megaChatApi.getUserFirstname(userHandle, listener); + megaChatApi.getUserLastname(userHandle, listener); + megaChatApi.getUserEmail(userHandle, listener); + } else { + log("4-Name already asked and no name received: " + m.getUserHandle()); + } + } + + } else { + holder.fullNameTitle = ((NodeAttachmentHistoryActivity)context).chatRoom.getTitle(); + } + } + + String secondRowInfo = context.getString(R.string.second_row_info_item_shard_file_chat, holder.fullNameTitle, date); + + holder.textViewMessageInfo.setText(secondRowInfo); + holder.textViewMessageInfo.setVisibility(View.VISIBLE); if (!multipleSelect) { log("Not multiselect"); @@ -872,8 +956,8 @@ public boolean onLongClick(View view) { int currentPosition = holder.getAdapterPosition(); // Toast.makeText(context,"pos:" + currentPosition ,Toast.LENGTH_SHORT ).show(); - ((FileBrowserFragmentLollipop)fragment).activateActionMode(); - ((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,null,null); + ((NodeAttachmentHistoryActivity)context).activateActionMode(); + ((NodeAttachmentHistoryActivity)context).itemClick(currentPosition); return true; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c2ada885a7..f03cbe79656 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2265,4 +2265,5 @@ Error. The file cannot be opened. + %1$s . %2$s From 92216993339e902eb3bad150f1cc2d21d3b56d83 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Fri, 7 Dec 2018 12:36:02 +0100 Subject: [PATCH 174/247] Task #11092-Improve multiselect mode --- .../lollipop/adapters/MegaNodeAdapter.java | 188 +++++++--------- .../adapters/MegaOfflineLollipopAdapter.java | 207 ++++++++---------- ...MegaPhotoSyncGridTitleAdapterLollipop.java | 154 ++++++++++--- .../MegaPhotoSyncListAdapterLollipop.java | 71 ++---- .../res/layout/cell_photosync_grid_title.xml | 3 +- .../main/res/layout/item_file_grid_new.xml | 3 +- app/src/main/res/layout/item_offline_grid.xml | 4 +- 7 files changed, 326 insertions(+), 304 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java index 7dab22d35c8..718be7c7b0a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java @@ -142,35 +142,27 @@ public int getPlaceholderCount() { public void toggleAllSelection(int pos) { log("toggleAllSelection: " + pos); - putOrDeletePostion(pos); -// startAnimation(pos, true); + startAnimation(pos, putOrDeletePostion(pos)); } public void toggleSelection(int pos) { log("toggleSelection: " + pos); - - putOrDeletePostion(pos); -// startAnimation(pos, false); + startAnimation(pos, putOrDeletePostion(pos)); } - void putOrDeletePostion(int pos) { - - boolean delete; - + boolean putOrDeletePostion(int pos) { if (selectedItems.get(pos,false)) { log("delete pos: " + pos); - delete = true; selectedItems.delete(pos); + return true; } else { log("PUT pos: " + pos); - delete = false; selectedItems.put(pos,true); + return false; } - startAnimation(pos, delete); } - void startAnimation (int pos, final boolean delete) { - final int positionToflip = pos; + void startAnimation (final int pos, final boolean delete) { if (adapterType == MegaNodeAdapter.ITEM_VIEW_TYPE_LIST) { log("adapter type is LIST"); @@ -182,7 +174,7 @@ void startAnimation (int pos, final boolean delete) { @Override public void onAnimationStart(Animation animation) { if (!delete) { - notifyItemChanged(positionToflip); + notifyItemChanged(pos); } } @@ -190,7 +182,7 @@ public void onAnimationStart(Animation animation) { public void onAnimationEnd(Animation animation) { hideMultipleSelect(); if (delete) { - notifyItemChanged(positionToflip); + notifyItemChanged(pos); } } @@ -199,36 +191,45 @@ public void onAnimationRepeat(Animation animation) { } }); - view.imageView.startAnimation(flipAnimation); - } else { log("view is null - not animation"); hideMultipleSelect(); - notifyItemChanged(positionToflip); + notifyItemChanged(pos); } } else { log("adapter type is GRID"); + MegaNode node = (MegaNode)getItem(pos); + boolean isFile = false; + if (node != null) { + if (node.isFolder()) { + isFile = false; + } + else { + isFile = true; + } + } MegaNodeAdapter.ViewHolderBrowserGrid view = (MegaNodeAdapter.ViewHolderBrowserGrid)listFragment.findViewHolderForLayoutPosition(pos); if (view != null) { log("Start animation: " + pos); - //Current node is folder. Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); + if (!delete && isFile) { + notifyItemChanged(pos); + flipAnimation.setDuration(250); + } flipAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { if (!delete) { - notifyItemChanged(positionToflip); + notifyItemChanged(pos); } } @Override public void onAnimationEnd(Animation animation) { hideMultipleSelect(); - if (delete) { - notifyItemChanged(positionToflip); - } + notifyItemChanged(pos); } @Override @@ -236,20 +237,17 @@ public void onAnimationRepeat(Animation animation) { } }); - MegaNode node = (MegaNode)getItem(pos); - if (node != null) { - if (node.isFolder()) { - view.imageViewIcon.startAnimation(flipAnimation); - } - else { - view.fileGridSelected.startAnimation(flipAnimation); - } + if (isFile) { + view.fileGridSelected.startAnimation(flipAnimation); + } + else { + view.imageViewIcon.startAnimation(flipAnimation); } } else { log("view is null - not animation"); hideMultipleSelect(); - notifyItemChanged(positionToflip); + notifyItemChanged(pos); } } } @@ -381,7 +379,7 @@ private ArrayList insertPlaceHolderNode(ArrayList nodes) { if (listFragment instanceof NewGridRecyclerView) { spanCount = ((NewGridRecyclerView)listFragment).getSpanCount(); } - int placeholderCount = (folderCount % spanCount) == 0 ? 0 : spanCount - (folderCount % spanCount); + placeholderCount = (folderCount % spanCount) == 0 ? 0 : spanCount - (folderCount % spanCount); if (folderCount > 0 && placeholderCount != 0 && adapterType == ITEM_VIEW_TYPE_GRID) { //Add placeholder at folders' end. @@ -593,27 +591,12 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { } holder.document = node.getHandle(); - Bitmap thumb = null; - log("Node : " + position + " " + node.getName()); holder.textViewFileName.setText(node.getName()); holder.textViewFileSize.setText(""); holder.videoInfoLayout.setVisibility(View.GONE); -// if (!multipleSelect) { -// holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); -//// holder.separator.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); -// } else { -// if (this.isItemChecked(position)) { -// holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context,R.drawable.background_item_grid_long_click_lollipop)); -// holder.separator.setBackgroundColor(Color.WHITE); -// } else { -// holder.itemLayout.setBackgroundDrawable(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); -// holder.separator.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); -// } -// } - if (node.isExported()) { //Node has public link holder.publicLinkImage.setVisibility(View.VISIBLE); @@ -713,19 +696,6 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { holder.fileGridIconForFile.setImageResource(MimeTypeThumbnail.typeForName(node.getName()).getIconResourceId()); holder.thumbLayoutForFile.setBackgroundColor(Color.TRANSPARENT); - if (isMultipleSelect() && isItemChecked(position)) { -// holder.itemLayout.setForeground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); - holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); - holder.fileGridSelected.setImageResource(R.drawable.ic_select_folder); -// holder.fileGridSelected.setVisibility(View.VISIBLE); - - } else { -// holder.itemLayout.setForeground(new ColorDrawable()); - holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); - holder.fileGridSelected.setImageDrawable(null); -// holder.fileGridSelected.setVisibility(View.GONE); - } - if (Util.isVideoFile(node.getName())) { holder.videoInfoLayout.setVisibility(View.VISIBLE); holder.videoDuration.setVisibility(View.GONE); @@ -751,77 +721,56 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) { } if (node.hasThumbnail()) { - -// DisplayMetrics dm = new DisplayMetrics(); -// float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, dm); -// -// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.imageView.getLayoutParams(); -// params.width = ViewGroup.LayoutParams.MATCH_PARENT; -// params.height = ViewGroup.LayoutParams.MATCH_PARENT; -// holder.imageView.setLayoutParams(params); - Bitmap temp = ThumbnailUtils.getThumbnailFromCache(node); if (temp != null) { - thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); - holder.fileGridIconForFile.setVisibility(View.GONE); - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewThumb.setImageBitmap(thumb); - holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); - - } else { + setImageThumbnail(holder, temp); + } + else { temp = ThumbnailUtils.getThumbnailFromFolder(node,context); if (temp != null) { - thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); - holder.fileGridIconForFile.setVisibility(View.GONE); - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewThumb.setImageBitmap(thumb); - holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); - - } else { + setImageThumbnail(holder, temp); + } + else { try { temp = ThumbnailUtilsLollipop.getThumbnailFromMegaGrid(node,context,holder,megaApi,this); - } catch (Exception e) { - } // Too many AsyncTasks + } catch (Exception e) {} // Too many AsyncTasks if (temp != null) { - thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); - holder.imageViewIcon.setVisibility(View.GONE); - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewThumb.setImageBitmap(thumb); - holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + setImageThumbnail(holder, temp); } } } - } else { + } + else { Bitmap temp = ThumbnailUtils.getThumbnailFromCache(node); - -// thumb = ThumbnailUtils.getThumbnailFromCache(node); if (temp != null) { - thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); - holder.fileGridIconForFile.setVisibility(View.GONE); - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewThumb.setImageBitmap(thumb); - holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); - } else { + setImageThumbnail(holder, temp); + } + else { temp = ThumbnailUtils.getThumbnailFromFolder(node,context); if (temp != null) { - thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); - holder.fileGridIconForFile.setVisibility(View.GONE); - holder.imageViewThumb.setVisibility(View.VISIBLE); - holder.imageViewThumb.setImageBitmap(thumb); - holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); - } else { + setImageThumbnail(holder, temp); + } + else { try { ThumbnailUtilsLollipop.createThumbnailGrid(context,node,holder,megaApi,this); - } catch (Exception e) { - } // Too many AsyncTasks + } catch (Exception e) {} // Too many AsyncTasks } } } + + if (isMultipleSelect() && isItemChecked(position)) { + holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); + holder.fileGridSelected.setImageResource(R.drawable.ic_select_folder); + + } else { + holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); + holder.fileGridSelected.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); + } } //Check if is an offline file to show the red arrow @@ -843,6 +792,14 @@ else if (inbox){ } } + private void setImageThumbnail (ViewHolderBrowserGrid holder, Bitmap temp) { + Bitmap thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context,temp,2); + holder.fileGridIconForFile.setVisibility(View.GONE); + holder.imageViewThumb.setVisibility(View.VISIBLE); + holder.imageViewThumb.setImageBitmap(thumb); + holder.thumbLayoutForFile.setBackgroundColor(ContextCompat.getColor(context,R.color.new_background_fragment)); + } + private void setFolderGridSelected(ViewHolderBrowserGrid holder, int position, int folderDrawableResId) { if (isMultipleSelect() && isItemChecked(position)) { RelativeLayout.LayoutParams paramsMultiselect = (RelativeLayout.LayoutParams)holder.imageViewIcon.getLayoutParams(); @@ -1004,7 +961,12 @@ else if (node.isInShare()) { setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list); } else { - setFolderListSelected(holder, position, R.drawable.ic_folder_list); + if (((ManagerActivityLollipop) context).isCameraUploads(node)) { + setFolderListSelected(holder, position, R.drawable.ic_folder_image_list); + } + else { + setFolderListSelected(holder, position, R.drawable.ic_folder_list); + } } } else { @@ -1031,7 +993,7 @@ else if (node.isInShare()) { holder.versionsIcon.setVisibility(View.GONE); } - if (!multipleSelect) { + if (!isMultipleSelect()) { log("Not multiselect"); holder.itemLayout.setBackgroundColor(Color.WHITE); holder.imageView.setImageResource(MimeTypeList.typeForName(node.getName()).getIconResourceId()); @@ -1239,7 +1201,7 @@ private String getItemNode(int position) { @Override public int getItemCount() { if (nodes != null) { - return nodes.size(); + return nodes.size() - placeholderCount; } else { return 0; } @@ -1356,7 +1318,7 @@ private void threeDotsClicked(int currentPosition,MegaNode n) { return; } - if (multipleSelect) { + if (isMultipleSelect()) { if (type == Constants.RUBBISH_BIN_ADAPTER) { ((RubbishBinFragmentLollipop)fragment).itemClick(currentPosition,null,null); } else if (type == Constants.INBOX_ADAPTER) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java index 6f038064aef..e523fdd8884 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java @@ -6,6 +6,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.media.ExifInterface; import android.os.AsyncTask; import android.os.Environment; @@ -192,36 +193,27 @@ protected void onPostExecute(Bitmap thumb){ } } } - - public void toggleSelection(int pos) { - log("toggleSelection"); - //Otherwise out of bounds exception happens. - boolean a = pos >= folderCount; - boolean b = getAdapterType() == MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_GRID; - boolean c = placeholderCount != 0; - if (a && b && c) { - pos += placeholderCount; - } - //Check if it's the Master Key file - MegaOffline currentNode = (MegaOffline) getItem(pos); - if(currentNode.getHandle().equals("0")){ - String path = Environment.getExternalStorageDirectory().getAbsolutePath()+Util.rKFile; - File file= new File(path); - if(file.exists()){ - notifyItemChanged(pos); - return; - } - } - + + boolean putOrDeletePosition (int pos) { if (selectedItems.get(pos, false)) { log("delete pos: "+pos); selectedItems.delete(pos); + return true; } else { log("PUT pos: "+pos); selectedItems.put(pos, true); + return false; + } + } + + void hideMultipleSelect () { + if (selectedItems.size() <= 0){ + fragment.hideMultipleSelect(); } - notifyItemChanged(pos); + } + + void startAnimation (final int pos, final boolean delete) { if (getAdapterType() == MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_LIST){ MegaOfflineLollipopAdapter.ViewHolderOfflineList view = (MegaOfflineLollipopAdapter.ViewHolderOfflineList) listFragment.findViewHolderForLayoutPosition(pos); if(view!=null){ @@ -230,13 +222,16 @@ public void toggleSelection(int pos) { flipAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { - + if (!delete) { + notifyItemChanged(pos); + } } @Override public void onAnimationEnd(Animation animation) { - if (selectedItems.size() <= 0){ - fragment.hideMultipleSelect(); + hideMultipleSelect(); + if (delete) { + notifyItemChanged(pos); } } @@ -247,80 +242,42 @@ public void onAnimationRepeat(Animation animation) { }); view.imageView.startAnimation(flipAnimation); } - } - else{ - log("adapter type is GRID"); - MegaOfflineLollipopAdapter.ViewHolderOfflineGrid view = (MegaOfflineLollipopAdapter.ViewHolderOfflineGrid) listFragment.findViewHolderForLayoutPosition(pos); - if(view != null) { - if (view.folderLayout.getVisibility() == View.VISIBLE) { - Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); - flipAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) { - - } - - @Override - public void onAnimationEnd(Animation animation) { - if (selectedItems.size() <= 0){ - fragment.hideMultipleSelect(); - } - } - - @Override - public void onAnimationRepeat(Animation animation) { - - } - }); - view.imageViewIcon.startAnimation(flipAnimation); - }else{ - if (selectedItems.size() <= 0){ - fragment.hideMultipleSelect(); - } - } - } - } - } - - public void toggleAllSelection(int pos) { - final int positionToflip = pos; - //Check if it's the Master Key file - MegaOffline currentNode = (MegaOffline) getItem(pos); - if(currentNode.getHandle().equals("0")){ - String path = Environment.getExternalStorageDirectory().getAbsolutePath()+Util.rKFile; - File file= new File(path); - if(file.exists()){ + else { + hideMultipleSelect(); notifyItemChanged(pos); - return; } } - - if (selectedItems.get(pos, false)) { - log("delete pos: "+pos); - selectedItems.delete(pos); - } - else { - log("PUT pos: "+pos); - selectedItems.put(pos, true); - } - - if (getAdapterType() == MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_LIST){ - MegaOfflineLollipopAdapter.ViewHolderOfflineList view = (MegaOfflineLollipopAdapter.ViewHolderOfflineList) listFragment.findViewHolderForLayoutPosition(pos); - if(view!=null){ - log("Start animation: "+pos); - Animation flipAnimation = AnimationUtils.loadAnimation(context, R.anim.multiselect_flip); + else{ + log("adapter type is GRID"); + MegaOffline node = (MegaOffline) getItem(pos); + boolean isFile = false; + if (node != null) { + if (node.isFolder()) { + isFile = false; + } + else { + isFile =true; + } + } + MegaOfflineLollipopAdapter.ViewHolderOfflineGrid view = (MegaOfflineLollipopAdapter.ViewHolderOfflineGrid) listFragment.findViewHolderForLayoutPosition(pos); + if(view != null) { + Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); + if (!delete && isFile) { + notifyItemChanged(pos); + flipAnimation.setDuration(250); + } flipAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { - + if (!delete) { + notifyItemChanged(pos); + } } @Override public void onAnimationEnd(Animation animation) { - if (selectedItems.size() <= 0){ - ((OfflineFragmentLollipop) fragment).hideMultipleSelect(); - } - notifyItemChanged(positionToflip); + hideMultipleSelect(); + notifyItemChanged(pos); } @Override @@ -328,20 +285,57 @@ public void onAnimationRepeat(Animation animation) { } }); - view.imageView.startAnimation(flipAnimation); - } - else{ - log("NULL view pos: "+positionToflip); + if (isFile) { + view.fileGridSelected.startAnimation(flipAnimation); + } + else { + view.imageViewIcon.startAnimation(flipAnimation); + } + + }else{ + hideMultipleSelect(); notifyItemChanged(pos); } } - else{ - log("adapter type is GRID"); - if (selectedItems.size() <= 0){ - ((OfflineFragmentLollipop) fragment).hideMultipleSelect(); + } + + boolean isRKSavedForOffline (MegaOffline currentNode) { + if(currentNode.getHandle().equals("0")){ + String path = Environment.getExternalStorageDirectory().getAbsolutePath()+Util.rKFile; + File file= new File(path); + if(file.exists()){ + return true; } - notifyItemChanged(positionToflip); } + return false; + } + + public void toggleSelection(int pos) { + log("toggleSelection"); + //Otherwise out of bounds exception happens. + boolean a = pos >= folderCount; + boolean b = getAdapterType() == MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_GRID; + boolean c = placeholderCount != 0; + if (a && b && c) { + pos += placeholderCount; + } + //Check if it's the Master Key file + if (isRKSavedForOffline((MegaOffline)getItem(pos))) { + notifyItemChanged(pos); + return; + } + + startAnimation(pos, putOrDeletePosition(pos)); + } + + public void toggleAllSelection(int pos) { + //Check if it's the Master Key file + if (isRKSavedForOffline((MegaOffline)getItem(pos))) { + notifyItemChanged(pos); + return; + } + + startAnimation(pos, putOrDeletePosition(pos)); } public void selectAll() { @@ -354,17 +348,6 @@ public void selectAll() { } } } - -// public boolean isRecoveryKey(MegaOffline currentNode){ -// log("isRecoveryKey"); -// -// //Check if it's the Master Key file -// if(currentNode.getHandle().equals("0")){ -// return true; -// }else{ -// return false; -// } -// } public void clearSelections() { for (int i = 0;i < this.getItemCount();i++) { @@ -747,10 +730,10 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){ if (multipleSelect && isItemChecked(position)) { holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); - holder.fileGridSelected.setVisibility(View.VISIBLE); + holder.fileGridSelected.setImageResource(R.drawable.ic_select_folder); } else { holder.itemLayout.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid)); - holder.fileGridSelected.setVisibility(View.GONE); + holder.fileGridSelected.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); } if (MimeTypeThumbnail.typeForName(currentNode.getName()).isImage()){ Bitmap thumb = null; @@ -1034,7 +1017,7 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){ @Override public int getItemCount() { log("getItemCount"); - return mOffList.size(); + return mOffList.size() - placeholderCount; } public int getItemCountWithoutRK(){ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncGridTitleAdapterLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncGridTitleAdapterLollipop.java index 5ff7216fb93..ac3d7c4e0bb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncGridTitleAdapterLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncGridTitleAdapterLollipop.java @@ -6,6 +6,8 @@ import android.content.Intent; import android.content.res.Resources; import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build; import android.os.Environment; @@ -28,6 +30,8 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; @@ -507,7 +511,6 @@ public ViewHolderPhotoTitleSyncGridTitle(View itemView, int gridWidth, int margi gradient_effect = (RelativeLayout) itemView.findViewById(R.id.cell_photosync_title_gradient_effect); gradient_effect.setVisibility(View.GONE); click_icon = (ImageView) itemView.findViewById(R.id.cell_photosync_title_menu_long_click_select); - click_icon.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsI = (RelativeLayout.LayoutParams) click_icon.getLayoutParams(); if (((ManagerActivityLollipop)context).isSmallGridCameraUploads){ paramsI.width = Util.px2dp(16, outMetrics); @@ -604,20 +607,20 @@ public void setDataImage(MegaNode n, boolean checked, boolean multipleSelect, in if (multipleSelect){ if (checked){ - click_icon.setVisibility(View.VISIBLE); + click_icon.setImageResource(R.drawable.ic_select_folder); photo.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); photo.setPadding(Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics)); click_unselected.setVisibility(View.GONE); } else{ - click_icon.setVisibility(View.GONE); + click_icon.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); photo.setBackground(null); photo.setPadding(0, 0, 0, 0); click_unselected.setVisibility(View.VISIBLE); } } else{ - click_icon.setVisibility(View.GONE); + click_icon.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); photo.setBackground(null); photo.setPadding(0, 0, 0, 0); click_unselected.setVisibility(View.GONE); @@ -707,14 +710,14 @@ public void setDataVideo(MegaNode n, boolean checked, boolean multipleSelect, in if (multipleSelect){ if (checked){ - click_icon.setVisibility(View.VISIBLE); + click_icon.setImageResource(R.drawable.ic_select_folder); photo.setBackground(ContextCompat.getDrawable(context,R.drawable.background_item_grid_selected)); photo.setPadding(Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics), Util.px2dp(1, outMetrics)); gradient_effect.setBackground(ContextCompat.getDrawable(context, R.drawable.gradient_cam_uploads_rounded)); click_unselected.setVisibility(View.GONE); } else{ - click_icon.setVisibility(View.GONE); + click_icon.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); photo.setBackground(null); photo.setPadding(0, 0, 0, 0); gradient_effect.setBackground(ContextCompat.getDrawable(context, R.drawable.gradient_cam_uploads)); @@ -722,7 +725,7 @@ public void setDataVideo(MegaNode n, boolean checked, boolean multipleSelect, in } } else{ - click_icon.setVisibility(View.GONE); + click_icon.setImageDrawable(new ColorDrawable(Color.TRANSPARENT)); photo.setBackground(null); photo.setPadding(0, 0, 0, 0); gradient_effect.setBackground(ContextCompat.getDrawable(context, R.drawable.gradient_cam_uploads)); @@ -1109,18 +1112,34 @@ public void hideMultipleSelect() { public void selectAll(){ this.multipleSelect = true; - if(nodes != null){ - for(int i=0; i selectedNodes = getSelectedDocuments(); if (selectedNodes.size() > 0){ updateActionModeTitle(); - notifyItemChanged(holder.getPositionOnAdapter()); +// notifyItemChanged(holder.getPositionOnAdapter()); } else{ // hideMultipleSelect(); @@ -1324,6 +1364,70 @@ else if (MimeTypeThumbnail.typeForName(n.getName()).isVideoReproducible()){ } } + void notifyItem (int type, final MegaPhotoSyncGridTitleAdapterLollipop.ViewHolderPhotoTitleSyncGridTitle holder, int pos) { + if (type == 0) { + notifyItemChanged(holder.getPositionOnAdapter()); + } + else { + notifyItemChanged(pos); + } + } + + void startAnimation (final MegaPhotoSyncGridTitleAdapterLollipop.ViewHolderPhotoTitleSyncGridTitle holder, final int pos, final boolean delete) { + MegaPhotoSyncGridTitleAdapterLollipop.ViewHolderPhotoTitleSyncGridTitle view = (MegaPhotoSyncGridTitleAdapterLollipop.ViewHolderPhotoTitleSyncGridTitle)listFragment.findViewHolderForLayoutPosition(pos); + int type; + if ((holder != null && holder.click_icon != null)) { + type = 0; + } + else { + type = 1; + } + final int finalType = type; + if ((holder != null && holder.click_icon != null) || view != null) { + if ((holder != null && holder.click_icon != null)) { + log("Start animation: holderPosition: " + holder.getPositionOnAdapter()); + } + else { + log("Start animation: position: " + pos); + } + Animation flipAnimation = AnimationUtils.loadAnimation(context,R.anim.multiselect_flip); + notifyItem(finalType, holder, pos); + flipAnimation.setDuration(200); + flipAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + log("onAnimationStart"); + if (!delete) { + notifyItem(finalType, holder, pos); + } + } + + @Override + public void onAnimationEnd(Animation animation) { + log("onAnimationEnd"); + if (delete) { + notifyItem(finalType, holder, pos); + } + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + if (finalType == 0) { + holder.click_icon.startAnimation(flipAnimation); + } + else { + view.click_icon.startAnimation(flipAnimation); + } + } + else { + log("view is null - not animation"); + notifyItem(finalType, holder, pos); + } + } + public String findLocalPath (String fileName, long fileSize, MegaNode file) { log("findLocalPath"); String localPath = null; @@ -1452,9 +1556,9 @@ public void onNodeLongClick(MegaPhotoSyncGridTitleAdapterLollipop.ViewHolderPhot actionMode = ((AppCompatActivity)context).startSupportActionMode(new MegaPhotoSyncGridTitleAdapterLollipop.ActionBarCallBack()); - updateActionModeTitle(); + startAnimation(holder, -1, false); - notifyItemChanged(holder.getPositionOnAdapter()); + updateActionModeTitle(); } else{ onNodeClick(holder, positionInNodes); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncListAdapterLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncListAdapterLollipop.java index d8a54bd6855..cd5fc03736e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncListAdapterLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaPhotoSyncListAdapterLollipop.java @@ -234,62 +234,20 @@ public List getSelectedDocuments() { return nodes; } - public void toggleAllSelection(int pos) { - log("toggleAllSelection: " + pos); - final int positionToflip = pos; - - if (selectedItems.get(pos,false)) { - log("delete pos: " + pos); - selectedItems.delete(pos); - - } else { - log("PUT pos: " + pos); - selectedItems.put(pos,true); - } - - MegaPhotoSyncListAdapterLollipop.ViewHolderPhotoSyncList view = (MegaPhotoSyncListAdapterLollipop.ViewHolderPhotoSyncList)listFragment.findViewHolderForLayoutPosition(pos); - if (view != null) { - log("toggleSelection Start animation: " + pos); - Animation flipAnimation = AnimationUtils.loadAnimation(context, R.anim.multiselect_flip); - flipAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) { - log("toggleSelection onAnimationStart"); - } - - @Override - public void onAnimationEnd(Animation animation) { - log("toggleSelection onAnimationEnd"); - if (selectedItems.size() <= 0) { - ((CameraUploadFragmentLollipop) fragment).hideMultipleSelect(); - } - notifyItemChanged(positionToflip); - } - - @Override - public void onAnimationRepeat(Animation animation) { - - } - }); - view.imageView.startAnimation(flipAnimation); - } - else { - notifyItemChanged(pos); - } - } - - public void toggleSelection(int pos) { - log("toggleSelection"); + boolean putOrDeletePosition (int pos) { if (selectedItems.get(pos, false)) { log("toggleSelection delete pos: "+pos); selectedItems.delete(pos); + return true; } else { log("toggleSelection PUT pos: "+pos); selectedItems.put(pos, true); + return false; } - notifyItemChanged(pos); + } + void startAnimation (final int pos, final boolean delete) { MegaPhotoSyncListAdapterLollipop.ViewHolderPhotoSyncList view = (MegaPhotoSyncListAdapterLollipop.ViewHolderPhotoSyncList)listFragment.findViewHolderForLayoutPosition(pos); if (view != null) { log("toggleSelection Start animation: " + pos); @@ -298,6 +256,9 @@ public void toggleSelection(int pos) { @Override public void onAnimationStart(Animation animation) { log("toggleSelection onAnimationStart"); + if (!delete) { + notifyItemChanged(pos); + } } @Override @@ -306,6 +267,9 @@ public void onAnimationEnd(Animation animation) { if (selectedItems.size() <= 0) { ((CameraUploadFragmentLollipop) fragment).hideMultipleSelect(); } + if (delete) { + notifyItemChanged(pos); + } } @Override @@ -319,8 +283,21 @@ public void onAnimationRepeat(Animation animation) { if (selectedItems.size() <= 0) { ((CameraUploadFragmentLollipop) fragment).hideMultipleSelect(); } + notifyItemChanged(pos); } } + + public void toggleAllSelection(int pos) { + log("toggleAllSelection: " + pos); + + startAnimation(pos, putOrDeletePosition(pos)); + } + + public void toggleSelection(final int pos) { + log("toggleSelection"); + + startAnimation(pos, putOrDeletePosition(pos)); + } private boolean isItemChecked(int position) { return selectedItems.get(position); diff --git a/app/src/main/res/layout/cell_photosync_grid_title.xml b/app/src/main/res/layout/cell_photosync_grid_title.xml index 1f3555f189b..b53387f1d8d 100644 --- a/app/src/main/res/layout/cell_photosync_grid_title.xml +++ b/app/src/main/res/layout/cell_photosync_grid_title.xml @@ -47,8 +47,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:src="@drawable/ic_select_folder"/> + android:layout_alignParentTop="true"/> + android:layout_marginTop="7dp"/> + android:layout_marginTop="7dp"/> Date: Fri, 7 Dec 2018 15:40:45 +0100 Subject: [PATCH 175/247] Bug #11084-When a pdf is protected with a password and it opens with the MEGA pdf viewer an alert saying 'Error. The pdf file is corrupted or not exists' --- .../github/barteksc/pdfviewer/PDFView.java | 153 ++++++++++++++++-- .../lollipop/PdfViewerActivityLollipop.java | 36 ++++- .../main/res/layout/dialog_pdf_password.xml | 67 ++++++++ app/src/main/res/values/strings.xml | 4 + 4 files changed, 243 insertions(+), 17 deletions(-) create mode 100644 app/src/main/res/layout/dialog_pdf_password.xml diff --git a/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java b/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java index e7d09e66e50..a960e7f336f 100644 --- a/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java +++ b/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java @@ -25,16 +25,28 @@ import android.graphics.Paint.Style; import android.graphics.PaintFlagsDrawFilter; import android.graphics.PointF; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.HandlerThread; +import android.support.v4.content.ContextCompat; +import android.text.Editable; +import android.text.InputType; +import android.text.TextWatcher; import android.util.AttributeSet; import android.util.Log; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.EditText; +import android.widget.ImageView; import android.widget.RelativeLayout; +import android.widget.TextView; import com.github.barteksc.pdfviewer.exception.PageRenderingException; import com.github.barteksc.pdfviewer.link.DefaultLinkHandler; @@ -700,6 +712,125 @@ void loadComplete(PdfFile pdfFile) { // ((PdfViewerActivityLollipop) getContext()).progressDialog.hide(); } + public void showHidePassword (EditText passwordText, ImageView toggleButton) { + boolean passwdVisible; + if (passwordText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { + passwdVisible = true; + } + else { + passwdVisible = false; + } + + if(passwdVisible){ + toggleButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_b_shared_read)); + passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + passwordText.setTypeface(Typeface.SANS_SERIF,Typeface.NORMAL); + passwordText.setSelection(passwordText.getText().length()); + } + else{ + toggleButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_b_see)); + passwordText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + passwordText.setSelection(passwordText.getText().length()); + } + } + + void showErrorDialog(final Throwable t) { + AlertDialog.Builder builder; + builder = new AlertDialog.Builder(getContext()); + + builder.setCancelable(false); + if (t.getLocalizedMessage().equals("Password required or incorrect password.") || t.getMessage().equals("Password required or incorrect password.")) { + if (((PdfViewerActivityLollipop) getContext()).getMaxIntents() > 0) { + LayoutInflater inflater = ((PdfViewerActivityLollipop) getContext()).getLayoutInflater(); + View layout = inflater.inflate(R.layout.dialog_pdf_password, null); + final EditText passwordText = layout.findViewById(R.id.password_text); + final ImageView toggleButton = (ImageView) layout.findViewById(R.id.toggle_button); + toggleButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + showHidePassword(passwordText, toggleButton); + } + }); + final RelativeLayout errorLayout = layout.findViewById(R.id.password_text_error); + if (((PdfViewerActivityLollipop) getContext()).getPassword() != null) { + errorLayout.setVisibility(VISIBLE); + String text = ((PdfViewerActivityLollipop) getContext()).getPassword(); + passwordText.setText(text); + passwordText.setSelection(text.length()); + passwordText.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.login_warning), PorterDuff.Mode.SRC_ATOP); + } else { + errorLayout.setVisibility(GONE); + } + passwordText.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + showHidePassword(passwordText, toggleButton); + ((PdfViewerActivityLollipop) getContext()).reloadPDFwithPassword(textView.getText().toString()); + return true; + } + return false; + } + }); + passwordText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (errorLayout.getVisibility() == VISIBLE) { + errorLayout.setVisibility(GONE); + passwordText.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.accentColor), PorterDuff.Mode.SRC_ATOP); + } + } + }); + builder.setView(layout); + builder.setTitle(getContext().getString(R.string.title_pdf_password)) + .setMessage(getContext().getString(R.string.text_pdf_password, ((PdfViewerActivityLollipop) getContext()).getPdfFileName())) + .setNegativeButton(R.string.general_cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + showHidePassword(passwordText, toggleButton); + ((PdfViewerActivityLollipop) getContext()).finish(); + } + }) + .setPositiveButton(R.string.contact_accept, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + showHidePassword(passwordText, toggleButton); + ((PdfViewerActivityLollipop) getContext()).reloadPDFwithPassword(passwordText.getText().toString()); + } + }).show(); + } + else { + builder.setTitle(getResources().getString(R.string.general_error_word)) + .setMessage(getResources().getString(R.string.error_max_pdf_password)) + .setPositiveButton(R.string.contact_accept, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + ((PdfViewerActivityLollipop) getContext()).finish(); + } + }).show(); + } + } + else { + builder.setMessage(R.string.corrupt_pdf_dialog_text) + .setPositiveButton(R.string.cam_sync_ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + ((PdfViewerActivityLollipop) getContext()).finish(); + } + }) + .show(); + } + } + void loadError(Throwable t) { state = State.ERROR; // store reference, because callbacks will be cleared in recycle() method @@ -709,22 +840,8 @@ void loadError(Throwable t) { if (onErrorListener != null) { onErrorListener.onError(t); } else { + showErrorDialog(t); Log.e("PDFView", "load pdf error", t); - AlertDialog.Builder builder; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - builder = new AlertDialog.Builder(getContext(), R.style.AppCompatAlertDialogStyle); - } else { - builder = new AlertDialog.Builder(getContext()); - } - builder.setCancelable(false); - String accept = getResources().getString(R.string.cam_sync_ok).toUpperCase(); - builder.setMessage(R.string.corrupt_pdf_dialog_text) - .setPositiveButton(accept, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - ((PdfViewerActivityLollipop) getContext()).finish(); - } - }) - .show(); } } @@ -1332,4 +1449,8 @@ public void run() { }); } } + + public static void log(String log) { + mega.privacy.android.app.utils.Util.log("PdfView", log); + } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java index a76e82f6bf8..42597ce7ed7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/PdfViewerActivityLollipop.java @@ -158,6 +158,8 @@ public class PdfViewerActivityLollipop extends PinActivityLollipop implements Me DefaultScrollHandle defaultScrollHandle; Uri uri; + String password; + int maxIntents = 3; String pdfFileName; boolean inside = false; long handle = -1; @@ -255,6 +257,8 @@ public void onCreate (Bundle savedInstanceState){ renamed = savedInstanceState.getBoolean("renamed"); isDeleteDialogShow = savedInstanceState.getBoolean("isDeleteDialogShow", false); toolbarVisible = savedInstanceState.getBoolean("toolbarVisible", toolbarVisible); + password = savedInstanceState.getString("password"); + maxIntents = savedInstanceState.getInt("maxIntents", 3); } else { currentPage = 1; @@ -911,6 +915,8 @@ protected void onSaveInstanceState(Bundle outState) { outState.putBoolean("renamed", renamed); outState.putBoolean("isDeleteDialogShow", isDeleteDialogShow); outState.putBoolean("toolbarVisible", toolbarVisible); + outState.putString("password", password); + outState.putInt("maxIntents", maxIntents); } @Override @@ -986,6 +992,7 @@ protected void onPostExecute(InputStream inputStream) { .scrollHandle(defaultScrollHandle) .spacing(10) // in dp .onPageError(PdfViewerActivityLollipop.this) + .password(password) .load(); } catch (Exception e) { @@ -997,7 +1004,18 @@ protected void onPostExecute(InputStream inputStream) { } } - private void loadStreamPDF() { + public void reloadPDFwithPassword (String password) { + this.password = password; + maxIntents--; + if (isUrl) { + loadStreamPDF(); + } + else { + loadLocalPDF(); + } + } + + public void loadStreamPDF() { log("loadStreamPDF loading: "+loading); new LoadPDFStream().execute(uri.toString()); } @@ -1015,6 +1033,7 @@ private void loadLocalPDF() { .scrollHandle(defaultScrollHandle) .spacing(10) // in dp .onPageError(this) + .password(password) .load(); } catch (Exception e) { @@ -2489,6 +2508,9 @@ public void printBookmarksTree(List tree, String sep) { } } + public String getPdfFileName () { + return pdfFileName; + } public String getFileName(Uri uri) { String result = null; if (uri.getScheme().equals("content")) { @@ -3139,7 +3161,19 @@ public void onClick(DialogInterface dialog, int whichButton) { downloadConfirmationDialog.show(); } + public Uri getUri() { + return uri; + } + + public String getPassword () { + return password; + } + public void setSendToChat (boolean sendToChat) { this.sendToChat = sendToChat; } + + public int getMaxIntents() { + return maxIntents; + } } diff --git a/app/src/main/res/layout/dialog_pdf_password.xml b/app/src/main/res/layout/dialog_pdf_password.xml new file mode 100644 index 00000000000..c550e1bcbca --- /dev/null +++ b/app/src/main/res/layout/dialog_pdf_password.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ec4607d7a1f..0da4df89eeb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2261,4 +2261,8 @@ Error. The file cannot be opened. + Type password + %s is protected. Enter the document opening password. + Wrong password. Try again. + The password is not valid. From 9e82993f21fde3149b89ea9a7cdeaf69ee0f6bcf Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Fri, 7 Dec 2018 15:42:10 +0100 Subject: [PATCH 176/247] Bug #11084-When a pdf is protected with a password and it opens with the MEGA pdf viewer an alert saying 'Error. The pdf file is corrupted or not exists' --- app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java b/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java index a960e7f336f..32c0f41a819 100644 --- a/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java +++ b/app/src/main/java/com/github/barteksc/pdfviewer/PDFView.java @@ -720,7 +720,6 @@ public void showHidePassword (EditText passwordText, ImageView toggleButton) { else { passwdVisible = false; } - if(passwdVisible){ toggleButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_b_shared_read)); passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); From d8c7eea99a84a7e30f0037377cbb18782f2dd852 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 10 Dec 2018 16:56:59 +0100 Subject: [PATCH 177/247] Bug #11108 - UI incorrect behaviour when deleting the first message of the list --- .../lollipop/megachat/ChatActivityLollipop.java | 14 +++++++------- .../chatAdapters/MegaChatLollipopAdapter.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 099ba44597f..c5d365e2298 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -3,7 +3,6 @@ import android.Manifest; import android.app.Activity; import android.app.ActivityManager; -import android.app.NotificationManager; import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -82,7 +81,6 @@ import mega.privacy.android.app.components.NpaLinearLayoutManager; import mega.privacy.android.app.components.twemoji.EmojiEditText; import mega.privacy.android.app.components.twemoji.EmojiKeyboard; -import mega.privacy.android.app.fcm.IncomingCallService; import mega.privacy.android.app.lollipop.AddContactActivityLollipop; import mega.privacy.android.app.lollipop.AudioVideoPlayerLollipop; import mega.privacy.android.app.lollipop.ContactInfoActivityLollipop; @@ -4994,29 +4992,31 @@ public void deleteMessage(MegaChatMessage msg, boolean rejected){ adapter.notifyItemChanged(positionNewMessagesLayout); } - adapter.removeMessage(indexToChange+1, messages); - if(!messages.isEmpty()){ //Update infoToShow of the next message also if (indexToChange == 0) { messages.get(indexToChange).setInfoToShow(AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_ALL); + //Check if there is more messages and update the following one + if(messages.size()>1){ + adjustInfoToShow(indexToChange+1); + setShowAvatar(indexToChange+1); + } } else{ //Not first element if(indexToChange==messages.size()){ log("The last message removed, do not check more messages"); setShowAvatar(indexToChange-1); - adapter.modifyMessage(messages, indexToChange); return; } adjustInfoToShow(indexToChange); setShowAvatar(indexToChange); setShowAvatar(indexToChange-1); - - adapter.modifyMessage(messages, indexToChange+1); } } + + adapter.removeMessage(indexToChange+1, messages); } else{ log("index to change not found"); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index f1dee6b6a6a..b02f9ebc5ef 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -7044,7 +7044,7 @@ public void removeMessage(int position, ArrayList messag this.messages = messages; notifyItemRemoved(position); - if (position == messages.size() - 1) { + if (position == messages.size()) { log("No need to update more"); } else { log("Update until end"); From feefcffe907d59526b3583904dff991199961074 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 11 Dec 2018 11:23:21 +0100 Subject: [PATCH 178/247] Bug #11115 - Crash when opening chat from action bar notification --- .../megachat/RecentChatsFragmentLollipop.java | 12 ++++++++---- app/src/main/jni/mega/sdk | 2 +- app/src/main/jni/megachat/sdk | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/RecentChatsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/RecentChatsFragmentLollipop.java index b77abcc9da5..528a2e1202f 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/RecentChatsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/RecentChatsFragmentLollipop.java @@ -348,21 +348,25 @@ public int compare(MegaChatListItem c1, MegaChatListItem c2) { } }); + if(listView==null){ + log("setChats: INIT_OFFLINE_SESSION: listView is null"); + } + + listView.setVisibility(View.VISIBLE); + emptyLayout.setVisibility(View.GONE); + if (adapterList == null){ log("adapterList is NULL"); adapterList = new MegaListChatLollipopAdapter(context, this, chats, listView, MegaListChatLollipopAdapter.ADAPTER_RECENT_CHATS); + listView.setAdapter(adapterList); } else{ adapterList.setChats(chats); } - listView.setAdapter(adapterList); fastScroller.setRecyclerView(listView); visibilityFastScroller(); adapterList.setPositionClicked(-1); - - listView.setVisibility(View.VISIBLE); - emptyLayout.setVisibility(View.GONE); } } else{ diff --git a/app/src/main/jni/mega/sdk b/app/src/main/jni/mega/sdk index cb56427c296..1243ad0bbb5 160000 --- a/app/src/main/jni/mega/sdk +++ b/app/src/main/jni/mega/sdk @@ -1 +1 @@ -Subproject commit cb56427c2963c1edf8c86284808bc17ab9870e01 +Subproject commit 1243ad0bbb537579fc594398395d86528dba2ca8 diff --git a/app/src/main/jni/megachat/sdk b/app/src/main/jni/megachat/sdk index e4b2873f0f4..9513c314748 160000 --- a/app/src/main/jni/megachat/sdk +++ b/app/src/main/jni/megachat/sdk @@ -1 +1 @@ -Subproject commit e4b2873f0f4d00de606686bd795735d59ac1da8d +Subproject commit 9513c3147484bcdb67bc986afbdbe1f1fbaa4ec6 From 84b8b08f7d7246e53f6e5783bfba30007f72d6a8 Mon Sep 17 00:00:00 2001 From: carolzato Date: Tue, 11 Dec 2018 11:48:51 +0100 Subject: [PATCH 179/247] Revert "Last seen scroll v2" --- .../app/components/MarqueeTextView.java | 105 ------------------ .../lollipop/ContactInfoActivityLollipop.java | 12 +- .../adapters/MegaContactsLollipopAdapter.java | 22 ++-- .../megachat/ChatActivityLollipop.java | 14 ++- app/src/main/res/layout/activity_chat.xml | 7 +- .../activity_chat_contact_properties.xml | 8 +- app/src/main/res/layout/item_contact_grid.xml | 3 +- app/src/main/res/layout/item_contact_list.xml | 9 +- app/src/main/res/values/strings.xml | 6 +- 9 files changed, 47 insertions(+), 139 deletions(-) delete mode 100644 app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java diff --git a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java deleted file mode 100644 index 0573d229808..00000000000 --- a/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java +++ /dev/null @@ -1,105 +0,0 @@ -package mega.privacy.android.app.components; - -import android.content.Context; -import android.os.Handler; -import android.text.TextPaint; -import android.util.AttributeSet; -import android.widget.TextView; - -import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; -import mega.privacy.android.app.utils.Util; - -public class MarqueeTextView extends TextView { - - private Handler mHandler = new Handler(); - private long mDelay = 200; - private int mFirstIndex; - private int mLastIndex; - private int scrollIndex; - private CharSequence text; - - public MarqueeTextView(Context context) { - super(context); - } - - public MarqueeTextView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public MarqueeTextView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - public void isMarqueeIsNecessary(Context context) { - TextPaint textPaint = new TextPaint(); - textPaint.setTextSize(getPaint().getTextSize()); - - formatString(); - - if (context instanceof ChatActivityLollipop) { - final TextPaint textPaint1 = textPaint; - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - scroll(textPaint1, getMeasuredWidth()); - } - }, 1000); - } - else { - scroll(textPaint, getMaxWidth()); - } - - - } - - private void scroll (TextPaint textPaint, int width) { - if (textPaint.measureText(text.toString()) > width) { - log("Text more large than textview --> Animate"); - mLastIndex = text.length()-1; - while (textPaint.measureText(text.subSequence(0, mLastIndex-1).toString()) > width) { - mLastIndex--; - } - animateText(); - } - else { - log("Text less large than textview --> Not animate"); - setText(text); - } - } - - public void formatString () { - String stringToFormat = getText().toString(); - stringToFormat = stringToFormat.replace("[A]", ""); - scrollIndex = stringToFormat.indexOf("[/A]"); - stringToFormat = stringToFormat.replace("[/A]", ""); - text = stringToFormat; - setText(text); - } - - private Runnable characterAdder = new Runnable() { - @Override - public void run() { - text = text + " "; - setText(text.subSequence(mFirstIndex, mLastIndex)); - mFirstIndex++; - mLastIndex++; - - if (mFirstIndex <= scrollIndex) { - mHandler.postDelayed(characterAdder, mDelay); - } - else { - mHandler.removeCallbacksAndMessages(null); - } - } - }; - - public void animateText () { - mFirstIndex = 0; - mHandler.removeCallbacksAndMessages(characterAdder); - mHandler.postDelayed(characterAdder, mDelay); - } - - public static void log(String message) { - Util.log("MarqueeTextView", message); - } -} diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index 82fc9919a21..a171a353d89 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -66,7 +66,6 @@ import mega.privacy.android.app.MegaContactDB; import mega.privacy.android.app.R; import mega.privacy.android.app.components.EditTextCursorWatcher; -import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.lollipop.controllers.ChatController; import mega.privacy.android.app.lollipop.controllers.ContactController; import mega.privacy.android.app.lollipop.controllers.NodeController; @@ -170,7 +169,7 @@ public class ContactInfoActivityLollipop extends PinActivityLollipop implements ImageView contactStateIcon; TextView firstLineTextToolbar; TextView firstLineLengthToolbar; - MarqueeTextView secondLineTextToolbar; + TextView secondLineTextToolbar; TextView secondLineLengthToolbar; RelativeLayout clearChatLayout; @@ -287,7 +286,8 @@ protected void onCreate(Bundle savedInstanceState) { firstLineLengthToolbar = (TextView) findViewById(R.id.first_line_length_toolbar); /*SUBTITLE*/ - secondLineTextToolbar = (MarqueeTextView) findViewById(R.id.second_line_toolbar); + secondLineTextToolbar = (TextView) findViewById(R.id.second_line_toolbar); + secondLineTextToolbar.setSelected(true); secondLineLengthToolbar =(TextView) findViewById(R.id.second_line_length_toolbar); nameText = (TextView) findViewById(R.id.chat_contact_properties_name_text); @@ -2534,10 +2534,10 @@ public void onChatPresenceLastGreen(MegaChatApiJava api, long userhandle, int la secondLineTextToolbar.setVisibility(View.VISIBLE); firstLineTextToolbar.setPadding(0, Util.px2dp(6, outMetrics), 0, 0); secondLineTextToolbar.setText(formattedDate); - secondLineTextToolbar.isMarqueeIsNecessary(this); +// secondLineTextToolbar.setText("formattedDate formattedDate formattedDate formattedDate formattedDate"); + secondLineTextToolbar.setSelected(true); secondLineLengthToolbar.setText(formattedDate); -// secondLineTextToolbar.setText("Large: " + formattedDate); -// secondLineLengthToolbar.setText("Large: " + formattedDate); + log("Date last green: "+formattedDate); } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java index e71cfc9ad3c..cde3b61b3e8 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaContactsLollipopAdapter.java @@ -34,7 +34,6 @@ import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.MegaContactAdapter; import mega.privacy.android.app.R; -import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.components.RoundedImageView; import mega.privacy.android.app.components.scrollBar.SectionTitleProvider; import mega.privacy.android.app.lollipop.AddContactActivityLollipop; @@ -108,7 +107,7 @@ public ViewHolderContacts(View v) { public TextView contactInitialLetter; // ImageView imageView; TextView textViewContactName; - MarqueeTextView textViewContent; + TextView textViewContent; RelativeLayout itemLayout; public String contactMail; } @@ -154,7 +153,9 @@ public ViewHolderContacts onCreateViewHolder(ViewGroup parent, int viewType) { holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent.setSelected(true); + holderList.textViewContent.setHorizontallyScrolling(true); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); @@ -186,7 +187,9 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_GRID){ holderGrid.imageView = (ImageView) v.findViewById(R.id.contact_grid_thumbnail); holderGrid.contactInitialLetter = (TextView) v.findViewById(R.id.contact_grid_initial_letter); holderGrid.textViewContactName = (TextView) v.findViewById(R.id.contact_grid_name); - holderGrid.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_grid_content); + holderGrid.textViewContent = (TextView) v.findViewById(R.id.contact_grid_content); + holderGrid.textViewContent.setSelected(true); + holderGrid.textViewContent.setHorizontallyScrolling(true); holderGrid.imageButtonThreeDots = (ImageButton) v.findViewById(R.id.contact_grid_three_dots); holderGrid.contactStateIcon = (ImageView) v.findViewById(R.id.contact_grid_drawable_state); @@ -215,7 +218,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_ADD_CONTACT holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout.setVisibility(View.GONE); @@ -229,6 +232,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_ADD_CONTACT holderList.textViewContent.setMaxWidth(Util.scaleWidthPx(MAX_WIDTH_CONTACT_NAME_PORT, outMetrics)); } + holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); //Right margin @@ -253,7 +257,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_GROUP_CHAT) holderList.imageView = (RoundedImageView) v.findViewById(R.id.contact_list_thumbnail); holderList.contactInitialLetter = (TextView) v.findViewById(R.id.contact_list_initial_letter); holderList.textViewContactName = (TextView) v.findViewById(R.id.contact_list_name); - holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content); + holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.contactStateIcon = (ImageView) v.findViewById(R.id.contact_list_drawable_state); holderList.declineLayout = (RelativeLayout) v.findViewById(R.id.contact_list_decline); holderList.declineLayout.setVisibility(View.VISIBLE); @@ -267,6 +271,7 @@ else if (viewType == MegaContactsLollipopAdapter.ITEM_VIEW_TYPE_LIST_GROUP_CHAT) holderList.textViewContent.setMaxWidth(Util.scaleWidthPx(MAX_WIDTH_CONTACT_NAME_PORT, outMetrics)); } + holderList.textViewContent = (TextView) v.findViewById(R.id.contact_list_content); holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout); holderList.declineLayout.setTag(holderList); @@ -358,8 +363,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ if(!contact.getLastGreen().isEmpty()){ holder.textViewContent.setText(contact.getLastGreen()); - holder.textViewContent.formatString(); - holder.textViewContent.setSelected(true); } } } @@ -505,7 +508,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID) { if (!contact.getLastGreen().isEmpty()) { holder.textViewContent.setText(contact.getLastGreen()); - holder.textViewContent.isMarqueeIsNecessary(context); } } } @@ -642,7 +644,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID) { if (!contact.getLastGreen().isEmpty()) { holder.textViewContent.setText(contact.getLastGreen()); - holder.textViewContent.isMarqueeIsNecessary(context); } } } @@ -776,7 +777,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){ if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ if(!contact.getLastGreen().isEmpty()){ holder.textViewContent.setText(contact.getLastGreen()); - holder.textViewContent.isMarqueeIsNecessary(context); } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index d472188fcce..30cf7090920 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -34,6 +34,7 @@ import android.text.Editable; import android.text.Html; import android.text.Spanned; +import android.text.TextUtils; import android.text.TextWatcher; import android.util.DisplayMetrics; import android.view.Display; @@ -77,7 +78,6 @@ import mega.privacy.android.app.MimeTypeList; import mega.privacy.android.app.R; import mega.privacy.android.app.ShareInfo; -import mega.privacy.android.app.components.MarqueeTextView; import mega.privacy.android.app.components.NpaLinearLayoutManager; import mega.privacy.android.app.components.twemoji.EmojiEditText; import mega.privacy.android.app.components.twemoji.EmojiKeyboard; @@ -228,7 +228,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha LinearLayout toolbarElements; TextView titleToolbar; - MarqueeTextView subtitleToobar; + TextView subtitleToobar; ImageView iconStateToolbar; float scaleH, scaleW; float density; @@ -592,7 +592,13 @@ protected void onCreate(Bundle savedInstanceState) { tB.setOnClickListener(this); toolbarElements = (LinearLayout) tB.findViewById(R.id.toolbar_elements); titleToolbar = (TextView) tB.findViewById(R.id.title_toolbar); - subtitleToobar = (MarqueeTextView) tB.findViewById(R.id.subtitle_toolbar); + subtitleToobar = (TextView) tB.findViewById(R.id.subtitle_toolbar); + subtitleToobar.setFocusable(true); + subtitleToobar.setFocusableInTouchMode(true); + subtitleToobar.setEllipsize(TextUtils.TruncateAt.MARQUEE); + subtitleToobar.setMarqueeRepeatLimit(-1); + subtitleToobar.setSingleLine(true); + subtitleToobar.setHorizontallyScrolling(true); iconStateToolbar = (ImageView) tB.findViewById(R.id.state_icon_toolbar); titleToolbar.setText(" "); @@ -1390,7 +1396,7 @@ else if(permission==MegaChatRoom.PRIV_RM) { public void setLastGreen(String date){ subtitleToobar.setText(date); - subtitleToobar.isMarqueeIsNecessary(this); + subtitleToobar.setSelected(true); subtitleToobar.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index e89ce589520..3a3a513fd2e 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -85,15 +85,16 @@ android:layout_alignParentTop="true" android:visibility="gone"/> - diff --git a/app/src/main/res/layout/activity_chat_contact_properties.xml b/app/src/main/res/layout/activity_chat_contact_properties.xml index 7d40054cffd..27f2f859d1b 100644 --- a/app/src/main/res/layout/activity_chat_contact_properties.xml +++ b/app/src/main/res/layout/activity_chat_contact_properties.xml @@ -133,7 +133,7 @@ android:singleLine="true" android:textAppearance="@style/ToolbarTitle.Secondary" /> - diff --git a/app/src/main/res/layout/item_contact_grid.xml b/app/src/main/res/layout/item_contact_grid.xml index b181c8d0cb6..d0852d660f4 100644 --- a/app/src/main/res/layout/item_contact_grid.xml +++ b/app/src/main/res/layout/item_contact_grid.xml @@ -73,7 +73,7 @@ android:maxLines="1" android:singleLine="true"/> - diff --git a/app/src/main/res/layout/item_contact_list.xml b/app/src/main/res/layout/item_contact_list.xml index 2db68bb2490..5d234701d1c 100644 --- a/app/src/main/res/layout/item_contact_list.xml +++ b/app/src/main/res/layout/item_contact_list.xml @@ -94,14 +94,17 @@ android:background="@null" android:src="@drawable/circle_status_contact_offline" /> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52890caff1d..74828d66372 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2255,9 +2255,9 @@ [B]%1$d seconds[/B] - [A]Last seen [/A]today at %1$s - [A]Last seen [/A]a long time ago - [A]Last seen [/A]%1$s at %2$s + Last seen today at %1$s + Last seen a long time ago + Last seen %1$s at %2$s Error. The file cannot be opened. From 546dfe5ba0c9cb338aebe502aeb85f78f90fd4bb Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 11 Dec 2018 12:12:05 +0100 Subject: [PATCH 180/247] fixes in the chat --- .../megachat/ChatActivityLollipop.java | 30 +++++++++++-------- .../chatAdapters/MegaChatLollipopAdapter.java | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 099ba44597f..9de2f27e9bb 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -22,6 +22,7 @@ import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; +import android.support.v4.app.NotificationCompatSideChannelService; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.support.v4.content.LocalBroadcastManager; @@ -2451,11 +2452,8 @@ public void onBackPressed() { emojiKeyboard.hideBothKeyboard(this); }else{ if(fileStorageLayout.isShown()){ - if(fileStorageF != null){ - fileStorageF.clearSelections(); - fileStorageF.hideMultipleSelect(); - } - fileStorageLayout.setVisibility(View.GONE); + hideFileStorageSection(); + }else{ if (handlerEmojiKeyboard != null){ handlerEmojiKeyboard.removeCallbacksAndMessages(null); @@ -2468,11 +2466,7 @@ public void onBackPressed() { } }else{ if(fileStorageLayout.isShown()){ - if(fileStorageF != null){ - fileStorageF.clearSelections(); - fileStorageF.hideMultipleSelect(); - } - fileStorageLayout.setVisibility(View.GONE); + hideFileStorageSection(); }else{ if (handlerEmojiKeyboard != null){ handlerEmojiKeyboard.removeCallbacksAndMessages(null); @@ -4990,7 +4984,6 @@ public void deleteMessage(MegaChatMessage msg, boolean rejected){ log("Decrease generalUnread:Position where new messages layout is show: " + positionNewMessagesLayout); generalUnreadCount--; } - adapter.notifyItemChanged(positionNewMessagesLayout); } @@ -5110,6 +5103,8 @@ public int modifyMessageReceived(AndroidMegaChatMessage msg, boolean checkTempId log("---------------Index to change = "+indexToChange); if(indexToChange!=-1){ + log("indexToChange == "+indexToChange); + // if(msg.getMessage().isDeleted()){ // messages.remove(indexToChange); @@ -5188,6 +5183,8 @@ public int modifyMessageReceived(AndroidMegaChatMessage msg, boolean checkTempId } else{ + log("indexToChange == -1"); + log("Error, id temp message not found!!"); } return indexToChange; @@ -5269,7 +5266,6 @@ public void clearHistory(AndroidMegaChatMessage androidMsg){ } adapter.setMessages(messages); - adapter.notifyDataSetChanged(); } public void loadPendingMessages(){ @@ -5436,7 +5432,6 @@ public int appendMessagePosition(AndroidMegaChatMessage msg){ msg.setShowAvatar(true); messages.add(msg); }else{ - log("Finding where to append the message"); if(msg.isUploading()){ @@ -5497,6 +5492,14 @@ public int appendMessagePosition(AndroidMegaChatMessage msg){ messages.add(lastIndex, msg); adjustInfoToShow(lastIndex); msg.setShowAvatar(true); + if(!messages.get(lastIndex).isUploading()){ + int nextIndex = lastIndex+1; + if(messages.get(nextIndex)!=null) { + if(messages.get(nextIndex).isUploading()){ + adjustInfoToShow(nextIndex); + } + } + } if(lastIndex>0){ setShowAvatar(lastIndex-1); } @@ -7459,6 +7462,7 @@ public void setNodeAttachmentVisibile() { } public void hideFileStorageSection(){ + log("***** hideFileStorageSEctocioon"); if (fileStorageF != null) { fileStorageF.clearSelections(); fileStorageF.hideMultipleSelect(); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index f1dee6b6a6a..3503ee1ac9a 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -6886,7 +6886,7 @@ public void setMultipleSelect(boolean multipleSelect) { log("setMultipleSelect"); if (this.multipleSelect != multipleSelect) { this.multipleSelect = multipleSelect; - notifyDataSetChanged(); +// notifyDataSetChanged(); } if (this.multipleSelect) { selectedItems = new SparseBooleanArray(); From dc6f8f23f00cd8962dfd8806f1c010ad1197426b Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Tue, 11 Dec 2018 13:07:18 +0100 Subject: [PATCH 181/247] fixes on chat --- .../android/app/lollipop/megachat/ChatActivityLollipop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 9de2f27e9bb..e2678873c96 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -7462,7 +7462,7 @@ public void setNodeAttachmentVisibile() { } public void hideFileStorageSection(){ - log("***** hideFileStorageSEctocioon"); + log("hideFileStorageSEctocioon"); if (fileStorageF != null) { fileStorageF.clearSelections(); fileStorageF.hideMultipleSelect(); From 0a8185af2a89adbd43c9e4e348b7233c19304132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arag=C3=B3n?= Date: Tue, 11 Dec 2018 13:54:17 +0100 Subject: [PATCH 182/247] v3.6 (221) --- app/build.gradle | 4 ++-- app/src/main/AndroidManifest.xml | 4 ++-- .../main/java/mega/privacy/android/app/MegaApplication.java | 2 +- app/src/main/jni/mega/sdk | 2 +- app/src/main/res/values/strings.xml | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a62eb475e8d..90664eeae0c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "mega.privacy.android.app" minSdkVersion 21 targetSdkVersion 27 - versionCode 220 - versionName "3.5.1 (220)" + versionCode 221 + versionName "3.6 (221)" multiDexEnabled true } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f4711ea31ef..c96d99f10d5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="221" + android:versionName="3.6 (221)" > diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index 38922694703..9bd5f47c2da 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -99,7 +99,7 @@ public class MegaApplication extends MultiDexApplication implements MegaGlobalListenerInterface, MegaChatRequestListenerInterface, MegaChatNotificationListenerInterface, MegaChatCallListenerInterface, NetworkStateReceiver.NetworkStateReceiverListener, MegaChatListenerInterface { final String TAG = "MegaApplication"; - static final public String USER_AGENT = "MEGAAndroid/3.5.1_220"; + static final public String USER_AGENT = "MEGAAndroid/3.6_221"; DatabaseHandler dbH; MegaApiAndroid megaApi; diff --git a/app/src/main/jni/mega/sdk b/app/src/main/jni/mega/sdk index 1243ad0bbb5..0fbbaa4e41f 160000 --- a/app/src/main/jni/mega/sdk +++ b/app/src/main/jni/mega/sdk @@ -1 +1 @@ -Subproject commit 1243ad0bbb537579fc594398395d86528dba2ca8 +Subproject commit 0fbbaa4e41fd5c08bb6efbd4c0e966d7207040a3 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3259370d33e..4c9dadfe9d6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,9 +3,9 @@ MEGA MEGA PDF Viewer - 3.5.1 (220) + 3.6 (221) 0fbbaa4 - 9c9b9cc + f5b7c78 MEGA provides user-controlled encrypted cloud storage and chat through standard web browsers, together with dedicated apps for mobile devices. Unlike other cloud storage providers, your data is encrypted and decrypted by your client devices only and never by us.\n\nUpload your files from your smartphone or tablet then search, store, download, stream, view, share, rename or delete your files any time, from any device, anywhere. Share folders with your contacts and see their updates in real time. The encryption process means we cannot access or reset your password so you MUST remember it (unless you have your Recovery Key backed up) or you will lose access to your stored files.\n\nEnd-to-end user-encrypted MEGA video chat allows for total privacy, and has been available through the browser since 2016. It has been extended to our mobile app, with chat history accessible across multiple devices. Users can also easily add files to a chat from their MEGA Cloud Drive.\n\nMEGA offers a generous 50 GB free storage for all registered users with bonus achievements, and offers paid plans with much higher limits:\n\n\nPRO LITE subscription: 4.99 € per month or 49.99 € per year gives you 200 GB of storage space and 1 TB of transfer quota per month.\nPRO I subscription: 9.99 € per month or 99.99 € per year gives you 1 TB of storage space and 2 TB of transfer quota per month.\nPRO II subscription: 19.99 € per month or 199.99 € per year gives you 4 TB of storage space and 8 TB of transfer quota per month.\nPRO III subscription: 29.99 € per month or 299.99 € per year gives you 8 TB of storage space and 16 TB of transfer quota per month.\n\nSubscriptions are renewed automatically for successive subscription periods of the same duration and at the same price as the initial period chosen. To manage your subscriptions, simply click on the Play Store icon on your mobile device, sign in with your Google ID (if you haven’t already done so) and then click on the MEGA app. You’ll be able to manage your subscription there.\n\nApp Permissions:\nWRITE_EXTERNAL_STORAGE -> Download your files from MEGA to your device and upload files from your device to MEGA\nCAMERA -> Take a picture and upload your photos to MEGA\nREAD_CONTACTS -> Easily add contacts from your device as MEGA contacts\nRECORD_AUDIO & CAPTURE_VIDEO_OUTPUT (mic and camera) -> MEGA provides for end-to-end encrypted audio/video calls\n\n\nTo enhance users’ confidence in the MEGA system, all of the client-side code is published, so interested security researchers can evaluate the encryption process. The code of our mobile app is located on: https://github.com/meganz/android\n\nFor more info, please check our website:\nSee https://mega.nz/terms\n\n\nDesktop - https://mega.nz/ From 5d4fbde3b1bb6d4992a1b941ff1e33dc6b5ec984 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 11 Dec 2018 18:40:53 +0100 Subject: [PATCH 183/247] Bug #11115 - Crash when opening chat from action bar notification --- .../privacy/android/app/lollipop/ManagerActivityLollipop.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index 1f6307114b6..a07aecdee16 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -5214,7 +5214,7 @@ public void selectDrawerItemNotifications(){ notificFragment = (NotificationsFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.NOTIFICATIONS.getTag()); if (notificFragment == null){ log("New NotificationsFragment"); - notificFragment = new NotificationsFragmentLollipop(); + notificFragment = NotificationsFragmentLollipop.newInstance(); } else { refreshFragment(FragmentTag.NOTIFICATIONS.getTag()); @@ -5353,7 +5353,7 @@ public void selectDrawerItemChat(){ rChatFL = (RecentChatsFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.RECENT_CHAT.getTag()); if (rChatFL == null){ log("New REcentChatFragment"); - rChatFL = new RecentChatsFragmentLollipop(); + rChatFL = RecentChatsFragmentLollipop.newInstance(); replaceFragment(rChatFL, FragmentTag.RECENT_CHAT.getTag()); } else{ From b33016558acd27df6c93c75aee0870aa0197a2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arag=C3=B3n?= Date: Tue, 11 Dec 2018 18:42:13 +0100 Subject: [PATCH 184/247] Update strings --- app/src/main/res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 74828d66372..3683db07605 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -286,7 +286,7 @@ --> Size Modified - Added + Created Created loadAttachments"); - log("G->loadAttachments unread is 0"); + log("G->loadAttachments"); isLoadingHistory = true; stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD); log("New state of history: "+stateHistory); @@ -970,6 +1165,62 @@ public void showNodeAttachmentBottomSheet(MegaChatMessage message, int position) } } + public void showSnackbarNotSpace(){ + showSnackbar(getString(R.string.error_not_enough_free_space)); + } + + public void showSnackbar(String s){ + log("showSnackbar"); + Snackbar snackbar = Snackbar.make(container, s, Snackbar.LENGTH_LONG); + TextView snackbarTextView = (TextView)snackbar.getView().findViewById(android.support.design.R.id.snackbar_text); + snackbarTextView.setMaxLines(5); + snackbar.show(); + } + + public void askSizeConfirmationBeforeChatDownload(String parentPath, ArrayList nodeList, long size){ + log("askSizeConfirmationBeforeChatDownload"); + + final String parentPathC = parentPath; + final ArrayList nodeListC = nodeList; + final long sizeC = size; + final ChatController chatC = new ChatController(this); + + android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); + LinearLayout confirmationLayout = new LinearLayout(this); + confirmationLayout.setOrientation(LinearLayout.VERTICAL); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + params.setMargins(mega.privacy.android.app.utils.Util.scaleWidthPx(20, outMetrics), mega.privacy.android.app.utils.Util.scaleHeightPx(10, outMetrics), mega.privacy.android.app.utils.Util.scaleWidthPx(17, outMetrics), 0); + + final CheckBox dontShowAgain =new CheckBox(this); + dontShowAgain.setText(getString(R.string.checkbox_not_show_again)); + dontShowAgain.setTextColor(ContextCompat.getColor(this, R.color.text_secondary)); + + confirmationLayout.addView(dontShowAgain, params); + + builder.setView(confirmationLayout); + + builder.setMessage(getString(R.string.alert_larger_file, mega.privacy.android.app.utils.Util.getSizeString(sizeC))); + builder.setPositiveButton(getString(R.string.general_save_to_device), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + if(dontShowAgain.isChecked()){ + dbH.setAttrAskSizeDownload("false"); + } + chatC.download(parentPathC, nodeListC); + } + }); + builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + if(dontShowAgain.isChecked()){ + dbH.setAttrAskSizeDownload("false"); + } + } + }); + + downloadConfirmationDialog = builder.create(); + downloadConfirmationDialog.show(); + } + public void checkScroll () { if (listView != null) { if (listView.canScrollVertically(-1) || (adapter != null && adapter.isMultipleSelect())) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index b02f9ebc5ef..23e9f6c76a1 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -7990,7 +7990,7 @@ public void onClick(View v) { case R.id.forward_contact_preview_landscape:{ ArrayList messageArray = new ArrayList<>(); messageArray.add(messages.get(currentPosition - 1)); - ((ChatActivityLollipop) context).prepareMessagesToForward(messageArray); + ((ChatActivityLollipop) context).forwardMessages(messageArray); break; } case R.id.content_own_message_text: diff --git a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java index 83bbe025451..cb305d25b58 100644 --- a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java +++ b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java @@ -376,9 +376,7 @@ public void onClick(View v) { switch(v.getId()){ case R.id.option_forward_layout: { - if(context instanceof ChatActivityLollipop){ - ((ChatActivityLollipop)context).prepareMessageToForward(messageId); - } + chatC.prepareMessageToForward(messageId, chatId); break; } case R.id.option_download_layout:{ @@ -388,9 +386,8 @@ public void onClick(View v) { return; } - if(context instanceof ChatActivityLollipop){ - chatC.prepareForChatDownload(nodeList); - } + chatC.prepareForChatDownload(nodeList); + break; } case R.id.option_import_layout:{ @@ -400,9 +397,7 @@ public void onClick(View v) { return; } - if(context instanceof ChatActivityLollipop){ - ((ChatActivityLollipop)context).importNode(messageId); - } + chatC.importNode(messageId, chatId); break; } diff --git a/app/src/main/java/mega/privacy/android/app/utils/Util.java b/app/src/main/java/mega/privacy/android/app/utils/Util.java index ce62ff10c9e..8f164690af1 100644 --- a/app/src/main/java/mega/privacy/android/app/utils/Util.java +++ b/app/src/main/java/mega/privacy/android/app/utils/Util.java @@ -114,7 +114,7 @@ public class Util { public static double percScreenLoginReturning = 0.8; // Debug flag to enable logging and some other things - public static boolean DEBUG = false; + public static boolean DEBUG = true; public static String mainDIR = "/MEGA"; public static String offlineDIR = "MEGA/MEGA Offline"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52de06cb466..1873052d3fe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2266,4 +2266,9 @@ Error. The file cannot be opened. %1$s . %2$s + + + Message forwarded + Messages forwarded + From 1f335749a23efa252fedd99efd9fb2de91b4691a Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Wed, 12 Dec 2018 16:22:29 +0100 Subject: [PATCH 187/247] Feature #10972 - Chat node history --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1971546ae34..0d582baa033 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -186,7 +186,7 @@ + android:theme="@style/Theme.Megaactionbar.Secondary"> Date: Wed, 12 Dec 2018 16:41:36 +0100 Subject: [PATCH 188/247] Bug #11131 - Blink on the new messages layout for an uploading attachment --- .../lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index b02f9ebc5ef..494e93c73bc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -1139,6 +1139,8 @@ public void onBindViewHolderUploading(RecyclerView.ViewHolder holder, int positi ((ViewHolderMessageChat) holder).retryAlert.setVisibility(View.GONE); + ((ViewHolderMessageChat) holder).newMessagesLayout.setVisibility(View.GONE); + ((ViewHolderMessageChat) holder).ownManagementMessageLayout.setVisibility(View.GONE); ((ViewHolderMessageChat) holder).titleOwnMessage.setGravity(Gravity.RIGHT); From 47a19da7d599c3efa01b6d03de6f42685256907e Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 13 Dec 2018 12:35:09 +0100 Subject: [PATCH 189/247] Feature #10972 - Chat node history --- .../megachat/ChatActivityLollipop.java | 13 +- .../NodeAttachmentHistoryActivity.java | 491 ++++++++++++++++-- .../NodeAttachmentHistoryAdapter.java | 3 +- .../res/menu/messages_node_history_action.xml | 52 ++ 4 files changed, 513 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/menu/messages_node_history_action.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 1ea31b8d75c..29bd7c4457b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -3417,13 +3417,8 @@ private void clearSelections() { } private void updateActionModeTitle() { -// if (actionMode == null || getActivity() == null) { -// return; -// } - List messages = adapter.getSelectedMessages(); - try { - actionMode.setTitle(messages.size()+""); + actionMode.setTitle(adapter.getSelectedItemCount()+""); actionMode.invalidate(); } catch (Exception e) { e.printStackTrace(); @@ -6614,7 +6609,7 @@ protected void onResume(){ log("onResume"); super.onResume(); - setNodeAttachmentVisibile(); + setNodeAttachmentVisible(); MegaApplication.setShowPinScreen(true); MegaApplication.setOpenChatId(idChat); @@ -7346,8 +7341,8 @@ public int getDeviceDensity(){ return screen; } - public void setNodeAttachmentVisibile() { - log("setNodeAttachmentVisibile"); + public void setNodeAttachmentVisible() { + log("setNodeAttachmentVisible"); if (adapter != null && holder_imageDrag != null && position_imageDrag != -1) { adapter.setNodeAttachmentVisibility(true, holder_imageDrag, position_imageDrag); holder_imageDrag = null; diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index a65ff2ddcf5..489ddf825df 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -1,15 +1,19 @@ package mega.privacy.android.app.lollipop.megachat; +import android.app.ActivityManager; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; -import android.content.res.Resources; +import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; +import android.support.v4.content.FileProvider; import android.support.v4.view.GestureDetectorCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; @@ -38,17 +42,22 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; import mega.privacy.android.app.DatabaseHandler; import mega.privacy.android.app.MegaApplication; +import mega.privacy.android.app.MegaPreferences; +import mega.privacy.android.app.MimeTypeList; import mega.privacy.android.app.R; import mega.privacy.android.app.components.PositionDividerItemDecoration; import mega.privacy.android.app.components.SimpleDividerItemDecoration; +import mega.privacy.android.app.lollipop.AudioVideoPlayerLollipop; import mega.privacy.android.app.lollipop.LoginActivityLollipop; import mega.privacy.android.app.lollipop.ManagerActivityLollipop; +import mega.privacy.android.app.lollipop.PdfViewerActivityLollipop; import mega.privacy.android.app.lollipop.PinActivityLollipop; import mega.privacy.android.app.lollipop.controllers.ChatController; import mega.privacy.android.app.lollipop.listeners.MultipleForwardChatProcessor; @@ -56,6 +65,7 @@ import mega.privacy.android.app.lollipop.megachat.chatAdapters.NodeAttachmentHistoryAdapter; import mega.privacy.android.app.modalbottomsheet.chatmodalbottomsheet.NodeAttachmentBottomSheetDialogFragment; import mega.privacy.android.app.utils.Constants; +import mega.privacy.android.app.utils.MegaApiUtils; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiAndroid; import nz.mega.sdk.MegaApiJava; @@ -102,6 +112,8 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement TextView emptyTextView; ImageView emptyImageView; + MenuItem importIcon; + ArrayList messages; ArrayList bufferMessages; @@ -421,16 +433,341 @@ public static void log(String log) { Util.log("NodeAttachmentHistoryActivity", log); } + public void itemClick(int position) { log("itemClick"); - if (adapter.isMultipleSelect()){ - adapter.toggleSelection(position); - updateActionModeTitle(); + if(megaChatApi.isSignalActivityRequired()){ + megaChatApi.signalPresenceActivity(); } - else{ + + if(position messages = adapter.getSelectedMessages(); + if (messages.size() > 0) { + updateActionModeTitle(); + } + + }else{ + + if(m!=null){ + MegaNodeList nodeList = m.getMegaNodeList(); + if(nodeList.size()==1){ + MegaNode node = nodeList.get(0); + + if (MimeTypeList.typeForName(node.getName()).isImage()){ + if(node.hasPreview()){ + log("Show full screen viewer"); + showFullScreenViewer(m.getMsgId()); + } + else{ + log("Image without preview - show node attachment panel for one node"); + showNodeAttachmentBottomSheet(m, position); + } + } + else if (MimeTypeList.typeForName(node.getName()).isVideoReproducible() || MimeTypeList.typeForName(node.getName()).isAudio() ){ + log("itemClick:isFile:isVideoReproducibleOrIsAudio"); + String mimeType = MimeTypeList.typeForName(node.getName()).getType(); + log("itemClick:FILENAME: " + node.getName() + " TYPE: "+mimeType); + + Intent mediaIntent; + boolean internalIntent; + boolean opusFile = false; + if (MimeTypeList.typeForName(node.getName()).isVideoNotSupported() || MimeTypeList.typeForName(node.getName()).isAudioNotSupported()){ + mediaIntent = new Intent(Intent.ACTION_VIEW); + internalIntent=false; + String[] s = node.getName().split("\\."); + if (s != null && s.length > 1 && s[s.length-1].equals("opus")) { + opusFile = true; + } + } + else { + log("itemClick:setIntentToAudioVideoPlayer"); + mediaIntent = new Intent(this, AudioVideoPlayerLollipop.class); + internalIntent=true; + } + + mediaIntent.putExtra("adapterType", Constants.FROM_CHAT); + mediaIntent.putExtra("isPlayList", false); + mediaIntent.putExtra("msgId", m.getMsgId()); + mediaIntent.putExtra("chatId", chatId); + + String downloadLocationDefaultPath = null; + mediaIntent.putExtra("FILENAME", node.getName()); + MegaPreferences prefs = dbH.getPreferences(); + if (prefs != null){ + log("prefs != null"); + if (prefs.getStorageAskAlways() != null){ + if (!Boolean.parseBoolean(prefs.getStorageAskAlways())){ + log("askMe==false"); + if (prefs.getStorageDownloadLocation() != null){ + if (prefs.getStorageDownloadLocation().compareTo("") != 0){ + downloadLocationDefaultPath = prefs.getStorageDownloadLocation(); + } + } + } + } + } + String localPath = Util.getLocalFile(this, node.getName(), node.getSize(), downloadLocationDefaultPath); + File f = new File(downloadLocationDefaultPath, node.getName()); + boolean isOnMegaDownloads = false; + if(f.exists() && (f.length() == node.getSize())){ + isOnMegaDownloads = true; + } + log("isOnMegaDownloads: "+isOnMegaDownloads); + if (localPath != null && (isOnMegaDownloads || (megaApi.getFingerprint(node) != null && megaApi.getFingerprint(node).equals(megaApi.getFingerprint(localPath))))){ + File mediaFile = new File(localPath); + //mediaIntent.setDataAndType(Uri.parse(localPath), mimeType); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && localPath.contains(Environment.getExternalStorageDirectory().getPath())) { + log("itemClick:FileProviderOption"); + Uri mediaFileUri = FileProvider.getUriForFile(this, "mega.privacy.android.app.providers.fileprovider", mediaFile); + if(mediaFileUri==null){ + log("itemClick:ERROR:NULLmediaFileUri"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + else{ + mediaIntent.setDataAndType(mediaFileUri, MimeTypeList.typeForName(node.getName()).getType()); + } + } + else{ + Uri mediaFileUri = Uri.fromFile(mediaFile); + if(mediaFileUri==null){ + log("itemClick:ERROR:NULLmediaFileUri"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + else{ + mediaIntent.setDataAndType(mediaFileUri, MimeTypeList.typeForName(node.getName()).getType()); + } + } + mediaIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + } + else { + log("itemClick:localPathNULL"); + if (Util.isOnline(this)){ + if (megaApi.httpServerIsRunning() == 0) { + megaApi.httpServerStart(); + } + else{ + log("itemClick:ERROR:httpServerAlreadyRunning"); + } + + ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); + ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); + activityManager.getMemoryInfo(mi); + + if(mi.totalMem>Constants.BUFFER_COMP){ + log("itemClick:total mem: "+mi.totalMem+" allocate 32 MB"); + megaApi.httpServerSetMaxBufferSize(Constants.MAX_BUFFER_32MB); + } + else{ + log("itemClick:total mem: "+mi.totalMem+" allocate 16 MB"); + megaApi.httpServerSetMaxBufferSize(Constants.MAX_BUFFER_16MB); + } + + String url = megaApi.httpServerGetLocalLink(node); + if(url!=null){ + Uri parsedUri = Uri.parse(url); + if(parsedUri!=null){ + mediaIntent.setDataAndType(parsedUri, mimeType); + } + else{ + log("itemClick:ERROR:httpServerGetLocalLink"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + } + else{ + log("itemClick:ERROR:httpServerGetLocalLink"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + } + else { + showSnackbar(getString(R.string.error_server_connection_problem)+". "+ getString(R.string.no_network_connection_on_play_file)); + } + } + mediaIntent.putExtra("HANDLE", node.getHandle()); + if (opusFile){ + mediaIntent.setDataAndType(mediaIntent.getData(), "audio/*"); + } + if(internalIntent){ + startActivity(mediaIntent); + } + else{ + log("itemClick:externalIntent"); + if (MegaApiUtils.isIntentAvailable(this, mediaIntent)){ + startActivity(mediaIntent); + } + else{ + log("itemClick:noAvailableIntent"); + showNodeAttachmentBottomSheet(m, position); + } + } + } + else if (MimeTypeList.typeForName(node.getName()).isPdf()){ + log("itemClick:isFile:isPdf"); + String mimeType = MimeTypeList.typeForName(node.getName()).getType(); + log("itemClick:FILENAME: " + node.getName() + " TYPE: "+mimeType); + Intent pdfIntent = new Intent(this, PdfViewerActivityLollipop.class); + pdfIntent.putExtra("inside", true); + pdfIntent.putExtra("adapterType", Constants.FROM_CHAT); + pdfIntent.putExtra("msgId", m.getMsgId()); + pdfIntent.putExtra("chatId", chatId); + + String downloadLocationDefaultPath = null; + pdfIntent.putExtra("FILENAME", node.getName()); + MegaPreferences prefs = dbH.getPreferences(); + if (prefs != null){ + log("prefs != null"); + if (prefs.getStorageAskAlways() != null){ + if (!Boolean.parseBoolean(prefs.getStorageAskAlways())){ + log("askMe==false"); + if (prefs.getStorageDownloadLocation() != null){ + if (prefs.getStorageDownloadLocation().compareTo("") != 0){ + downloadLocationDefaultPath = prefs.getStorageDownloadLocation(); + } + } + } + } + } + + String localPath = Util.getLocalFile(this, node.getName(), node.getSize(), downloadLocationDefaultPath); + File f = new File(downloadLocationDefaultPath, node.getName()); + boolean isOnMegaDownloads = false; + if(f.exists() && (f.length() == node.getSize())){ + isOnMegaDownloads = true; + } + log("isOnMegaDownloads: "+isOnMegaDownloads); + if (localPath != null && (isOnMegaDownloads || (megaApi.getFingerprint(node) != null && megaApi.getFingerprint(node).equals(megaApi.getFingerprint(localPath))))){ + File mediaFile = new File(localPath); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && localPath.contains(Environment.getExternalStorageDirectory().getPath())) { + log("itemClick:FileProviderOption"); + Uri mediaFileUri = FileProvider.getUriForFile(this, "mega.privacy.android.app.providers.fileprovider", mediaFile); + if(mediaFileUri==null){ + log("itemClick:ERROR:NULLmediaFileUri"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + else{ + pdfIntent.setDataAndType(mediaFileUri, MimeTypeList.typeForName(node.getName()).getType()); + } + } + else{ + Uri mediaFileUri = Uri.fromFile(mediaFile); + if(mediaFileUri==null){ + log("itemClick:ERROR:NULLmediaFileUri"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + else{ + pdfIntent.setDataAndType(mediaFileUri, MimeTypeList.typeForName(node.getName()).getType()); + } + } + pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + } + else { + log("itemClick:localPathNULL"); + if (Util.isOnline(this)){ + if (megaApi.httpServerIsRunning() == 0) { + megaApi.httpServerStart(); + } + else{ + log("itemClick:ERROR:httpServerAlreadyRunning"); + } + ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); + ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); + activityManager.getMemoryInfo(mi); + if(mi.totalMem>Constants.BUFFER_COMP){ + log("itemClick:total mem: "+mi.totalMem+" allocate 32 MB"); + megaApi.httpServerSetMaxBufferSize(Constants.MAX_BUFFER_32MB); + } + else{ + log("itemClick:total mem: "+mi.totalMem+" allocate 16 MB"); + megaApi.httpServerSetMaxBufferSize(Constants.MAX_BUFFER_16MB); + } + String url = megaApi.httpServerGetLocalLink(node); + if(url!=null){ + Uri parsedUri = Uri.parse(url); + if(parsedUri!=null){ + pdfIntent.setDataAndType(parsedUri, mimeType); + } + else{ + log("itemClick:ERROR:httpServerGetLocalLink"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + } + else{ + log("itemClick:ERROR:httpServerGetLocalLink"); + showSnackbar(getString(R.string.email_verification_text_error)); + } + } + else { + showSnackbar(getString(R.string.error_server_connection_problem)+". "+ getString(R.string.no_network_connection_on_play_file)); + } + } + pdfIntent.putExtra("HANDLE", node.getHandle()); + + if (MegaApiUtils.isIntentAvailable(this, pdfIntent)){ + startActivity(pdfIntent); + } + else{ + log("itemClick:noAvailableIntent"); + showNodeAttachmentBottomSheet(m, position); + } + overridePendingTransition(0,0); + } + else{ + log("NOT Image, pdf, audio or video - show node attachment panel for one node"); + showNodeAttachmentBottomSheet(m, position); + } + } + else{ + log("show node attachment panel"); + showNodeAttachmentBottomSheet(m, position); + } + + + } + + } + }else{ + log("DO NOTHING: Position ("+position+") is more than size in messages (size: "+messages.size()+")"); + } + } + + public void showFullScreenViewer(long msgId){ + log("showFullScreenViewer"); + int position = 0; + boolean positionFound = false; + List ids = new ArrayList<>(); + for(int i=0; i msgs = adapter.getSelectedMessages(); - Resources res = getResources(); - String format = "%d %s"; - - actionMode.setTitle(String.format(format, msgs.size(),res.getQuantityString(R.plurals.general_num_files, msgs.size()))); + int num = adapter.getSelectedItemCount(); try { + actionMode.setTitle(num+""); actionMode.invalidate(); - } catch (NullPointerException e) { + } catch (Exception e) { e.printStackTrace(); log("oninvalidate error"); - } + } } /* @@ -649,22 +983,22 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { log("onActionItemClicked"); final List nodes = adapter.getSelectedMessages(); - switch(item.getItemId()){ - case R.id.cab_menu_select_all:{ + switch (item.getItemId()) { + case R.id.cab_menu_select_all: { selectAll(); actionMode.invalidate(); break; } - case R.id.cab_menu_unselect_all:{ + case R.id.cab_menu_unselect_all: { clearSelections(); actionMode.invalidate(); break; } - case R.id.action_download_versions:{ + case R.id.action_download_versions: { break; } - case R.id.action_delete_versions:{ + case R.id.action_delete_versions: { //showConfirmationRemoveVersions(nodes); break; } @@ -676,10 +1010,11 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public boolean onCreateActionMode(ActionMode mode, Menu menu) { log("onCreateActionMode"); MenuInflater inflater = mode.getMenuInflater(); - inflater.inflate(R.menu.versions_files_action, menu); - menu.findItem(R.id.cab_menu_select_all).setVisible(true); - menu.findItem(R.id.action_download_versions).setVisible(false); - menu.findItem(R.id.action_delete_versions).setVisible(false); + inflater.inflate(R.menu.messages_node_history_action, menu); + + importIcon = menu.findItem(R.id.chat_cab_menu_import); + menu.findItem(R.id.chat_cab_menu_offline).setIcon(Util.mutateIconSecondary(nodeAttachmentHistoryActivity, R.drawable.ic_b_save_offline, R.color.white)); + Util.changeStatusBarColorActionMode(getApplicationContext(), getWindow(), handler, 1); return true; } @@ -696,30 +1031,117 @@ public void onDestroyActionMode(ActionMode arg0) { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { log("onPrepareActionMode"); List selected = adapter.getSelectedMessages(); - if (selected.size() != 0) { +// MenuItem unselect = menu.findItem(R.id.cab_menu_unselect_all); MenuItem unselect = menu.findItem(R.id.cab_menu_unselect_all); - if(selected.size()==adapter.getItemCount()){ + if (selected.size() == adapter.getItemCount()) { menu.findItem(R.id.cab_menu_select_all).setVisible(false); unselect.setTitle(getString(R.string.action_unselect_all)); unselect.setVisible(true); - } - else{ + } else { menu.findItem(R.id.cab_menu_select_all).setVisible(true); unselect.setTitle(getString(R.string.action_unselect_all)); unselect.setVisible(true); } - menu.findItem(R.id.action_download_versions).setVisible(false); - menu.findItem(R.id.action_delete_versions).setVisible(true); - } - else{ + + if (chatRoom.getOwnPrivilege() == MegaChatRoom.PRIV_RM || chatRoom.getOwnPrivilege() == MegaChatRoom.PRIV_RO) { + + menu.findItem(R.id.chat_cab_menu_delete).setVisible(false); + menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); + menu.findItem(R.id.chat_cab_menu_download).setVisible(false); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(false); + + } else { + + log("Chat with permissions"); + if (Util.isOnline(nodeAttachmentHistoryActivity)) { + menu.findItem(R.id.chat_cab_menu_forward).setVisible(true); + } else { + menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); + } + + if (selected.size() == 1) { + + if (selected.get(0).getUserHandle() == megaChatApi.getMyUserHandle()) { + if (selected.get(0).isDeletable()) { + log("one message Message DELETABLE"); + menu.findItem(R.id.chat_cab_menu_delete).setVisible(true); + } else { + log("one message Message NOT DELETABLE"); + menu.findItem(R.id.chat_cab_menu_delete).setVisible(false); + } + } else { + menu.findItem(R.id.chat_cab_menu_delete).setVisible(false); + } + + if (Util.isOnline(nodeAttachmentHistoryActivity)) { + menu.findItem(R.id.chat_cab_menu_download).setVisible(true); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(true); + importIcon.setVisible(true); + } else { + menu.findItem(R.id.chat_cab_menu_download).setVisible(false); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(false); + importIcon.setVisible(false); + } + + } else { + log("Many items selected"); + boolean showDelete = true; + boolean allNodeAttachments = true; + + for (int i = 0; i < selected.size(); i++) { + + if (showDelete) { + if (selected.get(i).getUserHandle() == megaChatApi.getMyUserHandle()) { + if (!(selected.get(i).isDeletable())) { + showDelete = false; + } + + } else { + showDelete = false; + } + } + + if (allNodeAttachments) { + if (selected.get(i).getType() != MegaChatMessage.TYPE_NODE_ATTACHMENT) { + allNodeAttachments = false; + } + } + } + + if (allNodeAttachments) { + if (Util.isOnline(nodeAttachmentHistoryActivity)) { + menu.findItem(R.id.chat_cab_menu_download).setVisible(true); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(true); + importIcon.setVisible(true); + } else { + menu.findItem(R.id.chat_cab_menu_download).setVisible(false); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(false); + importIcon.setVisible(false); + } + } else { + menu.findItem(R.id.chat_cab_menu_download).setVisible(false); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(false); + importIcon.setVisible(false); + } + + menu.findItem(R.id.chat_cab_menu_delete).setVisible(showDelete); + if (Util.isOnline(nodeAttachmentHistoryActivity)) { + menu.findItem(R.id.chat_cab_menu_forward).setVisible(true); + } else { + menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); + } + } + } + } else { menu.findItem(R.id.cab_menu_select_all).setVisible(true); menu.findItem(R.id.cab_menu_unselect_all).setVisible(false); - menu.findItem(R.id.action_download_versions).setVisible(false); - menu.findItem(R.id.action_delete_versions).setVisible(false); + menu.findItem(R.id.chat_cab_menu_download).setVisible(false); + menu.findItem(R.id.chat_cab_menu_delete).setVisible(false); + menu.findItem(R.id.chat_cab_menu_offline).setVisible(false); + menu.findItem(R.id.chat_cab_menu_forward).setVisible(false); } - return false; } } @@ -1156,10 +1578,9 @@ public void onTruncate(MegaChatApiJava api, long msgid) { public void showNodeAttachmentBottomSheet(MegaChatMessage message, int position){ log("showNodeAttachmentBottomSheet: "+position); //this.selectedPosition = position; - if(message!=null){ this.selectedMessageId = message.getMsgId(); -// this.selectedChatItem = chat; + NodeAttachmentBottomSheetDialogFragment bottomSheetDialogFragment = new NodeAttachmentBottomSheetDialogFragment(); bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag()); } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index b0077c40dc8..1a926128c30 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -34,7 +34,6 @@ import mega.privacy.android.app.R; import mega.privacy.android.app.lollipop.controllers.ChatController; import mega.privacy.android.app.lollipop.listeners.ChatNonContactNameListener; -import mega.privacy.android.app.lollipop.managerSections.FileBrowserFragmentLollipop; import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity; import mega.privacy.android.app.utils.ThumbnailUtils; import mega.privacy.android.app.utils.ThumbnailUtilsLollipop; @@ -887,7 +886,7 @@ public void onClick(View v) { dimens[2] = imageView.getWidth(); dimens[3] = imageView.getHeight(); - ((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,dimens,imageView); + ((NodeAttachmentHistoryActivity)context).itemClick(currentPosition); break; } } diff --git a/app/src/main/res/menu/messages_node_history_action.xml b/app/src/main/res/menu/messages_node_history_action.xml new file mode 100644 index 00000000000..a52b2823db9 --- /dev/null +++ b/app/src/main/res/menu/messages_node_history_action.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file From fe26d99d6992f36711be632ea30a460f352d57e1 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 13 Dec 2018 16:34:50 +0100 Subject: [PATCH 190/247] Feature #10972 - Chat node history --- .../android/app/lollipop/ContactInfoActivityLollipop.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index 922011da312..2b3cd4f7ec2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -492,6 +492,9 @@ public void run() { if(chatHandle==-1){ notificationsLayout.setVisibility(View.GONE); dividerNotificationsLayout.setVisibility(View.GONE); + + sharedFilesLayout.setVisibility(View.GONE); + dividerSharedFilesLayout.setVisibility(View.GONE); } else{ chatPrefs = dbH.findChatPreferencesByHandle(String.valueOf(chatHandle)); @@ -500,6 +503,9 @@ public void run() { else{ notificationsLayout.setVisibility(View.GONE); dividerNotificationsLayout.setVisibility(View.GONE); + + sharedFilesLayout.setVisibility(View.GONE); + dividerSharedFilesLayout.setVisibility(View.GONE); } if (megaChatApi == null){ From c014152dc40085f02ab425cba4350eeef473bf0a Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 13 Dec 2018 16:46:26 +0100 Subject: [PATCH 191/247] Bug #11146 - On opening the contact info, if the chat is disabled avoid the last seen info request --- .../app/lollipop/ContactInfoActivityLollipop.java | 4 +++- .../managerSections/ContactsFragmentLollipop.java | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index a171a353d89..a6673824ed6 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -1796,7 +1796,9 @@ protected void onResume() { contactStateIcon.setVisibility(View.GONE); } - requestLastGreen(-1); + if(Util.isChatEnabled()){ + requestLastGreen(-1); + } } @Override diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index 8b507ca9322..c85e4895f96 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -1053,16 +1053,17 @@ public void setContacts(ArrayList contacts){ sortBy(); - if(!visibleContacts.isEmpty()){ - for (int i=0;i Date: Thu, 13 Dec 2018 16:51:31 +0100 Subject: [PATCH 192/247] Bug #11146 - On opening the contact info, if the chat is disabled avoid the last seen info request --- .../app/lollipop/managerSections/ContactsFragmentLollipop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java index c85e4895f96..7616c2eac47 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/ContactsFragmentLollipop.java @@ -1059,7 +1059,7 @@ public void setContacts(ArrayList contacts){ int userStatus = megaChatApi.getUserOnlineStatus(visibleContacts.get(i).getMegaUser().getHandle()); if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){ log("Request last green for user"); - megaChatApi.(visibleContacts.get(i).getMegaUser().getHandle(), null); + megaChatApi.requestLastGreen(visibleContacts.get(i).getMegaUser().getHandle(), null); } } } From 00a5eec5e94b2666023e36db43a8ec1927b830f0 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Thu, 13 Dec 2018 17:39:15 +0100 Subject: [PATCH 193/247] Feature #10972 - Chat node history --- .../lollipop/ContactInfoActivityLollipop.java | 3 ++ .../lollipop/controllers/ChatController.java | 31 ++++++++++------ .../ChatImportToForwardListener.java | 6 +-- .../megachat/ChatActivityLollipop.java | 22 +---------- .../GroupChatInfoActivityLollipop.java | 18 +++++++++ .../NodeAttachmentHistoryActivity.java | 13 +++++-- .../NodeAttachmentHistoryAdapter.java | 3 +- .../layout/activity_group_chat_properties.xml | 37 +++++++++++++++++++ ...ntent_chat_contact_properties_activity.xml | 2 +- 9 files changed, 93 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java index 6b647705f14..21458293be7 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ContactInfoActivityLollipop.java @@ -639,6 +639,9 @@ public void run() { notificationsLayout.setVisibility(View.GONE); dividerNotificationsLayout.setVisibility(View.GONE); + + sharedFilesLayout.setVisibility(View.GONE); + dividerSharedFilesLayout.setVisibility(View.GONE); } } else { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java index 68b0271ab77..cdcc239cda9 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java @@ -1938,24 +1938,31 @@ else if(context instanceof NodeAttachmentHistoryActivity){ public void prepareMessageToForward(long idMessage, long idChat) { log("prepareMessageToForward"); - ArrayList messagesSelected = new ArrayList<>(); + ArrayList messagesSelected = new ArrayList<>(); MegaChatMessage m = megaChatApi.getMessage(idChat, idMessage); - AndroidMegaChatMessage aM = new AndroidMegaChatMessage(m); - messagesSelected.add(aM); + messagesSelected.add(m); prepareMessagesToForward(messagesSelected, idChat); } - public void prepareMessagesToForward(ArrayList messagesSelected, long idChat){ + public void prepareAndroidMessagesToForward(ArrayList androidMessagesSelected, long idChat){ + ArrayList messagesSelected = new ArrayList<>(); + for(int i = 0; i messagesSelected, long idChat){ log ("prepareMessagesToForward"); - ArrayList messagesToImport = new ArrayList<>(); + ArrayList messagesToImport = new ArrayList<>(); long[] idMessages = new long[messagesSelected.size()]; for(int i=0; i messagesS } for(int j=0; j messagesSelected, long idChat){ + public void forwardMessages(ArrayList messagesSelected, long idChat){ log ("forwardMessages"); long[] idMessages = new long[messagesSelected.size()]; for(int i=0; i messagesSelected, int counter, Context context, ChatController chatC, long chatId) { + public ChatImportToForwardListener(int action, ArrayList messagesSelected, int counter, Context context, ChatController chatC, long chatId) { super(); this.actionListener = action; this.context = context; @@ -35,7 +35,7 @@ public ChatImportToForwardListener(int action, ArrayList int actionListener = -1; String message; long chatId; - ArrayList messagesSelected; + ArrayList messagesSelected; ChatController chatC; @Override diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 83c4f4b0743..ff38f351c39 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -21,7 +21,6 @@ import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; -import android.support.v4.app.NotificationCompatSideChannelService; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.support.v4.content.LocalBroadcastManager; @@ -929,10 +928,6 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { userTypingLayout.setVisibility(View.GONE); userTypingText = (TextView) findViewById(R.id.user_typing_text); - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } - Intent newIntent = getIntent(); if (newIntent != null){ @@ -1902,9 +1897,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in public void chooseAddParticipantDialog(){ log("chooseAddContactDialog"); - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } if(megaApi!=null && megaApi.getRootNode()!=null){ ArrayList contacts = megaApi.getContacts(); if(contacts==null){ @@ -1933,10 +1925,6 @@ public void chooseAddParticipantDialog(){ public void chooseContactsDialog(){ log("chooseContactsDialog"); - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } - if(megaApi!=null && megaApi.getRootNode()!=null){ ArrayList contacts = megaApi.getContacts(); if(contacts==null){ @@ -1974,10 +1962,9 @@ public void showProgressForwarding(){ statusDialog.show(); } - public void forwardMessages(ArrayList messagesSelected){ log("forwardMessages"); - chatC.prepareMessagesToForward(messagesSelected, idChat); + chatC.prepareAndroidMessagesToForward(messagesSelected, idChat); } @Override @@ -2958,10 +2945,6 @@ private class ActionBarCallBack implements ActionMode.Callback { public boolean onActionItemClicked(ActionMode mode, MenuItem item) { ArrayList messagesSelected = adapter.getSelectedMessages(); - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } - switch(item.getItemId()){ // case R.id.cab_menu_select_all:{ // selectAll(); @@ -3449,9 +3432,6 @@ public void selectAll() { public void itemClick(int positionInAdapter, int [] screenPosition) { log("itemClick"); int position = positionInAdapter-1; - if(megaChatApi.isSignalActivityRequired()){ - megaChatApi.signalPresenceActivity(); - } if(position nodes = adapter.getSelectedMessages(); + final ArrayList messagesSelected = adapter.getSelectedMessages(); switch (item.getItemId()) { case R.id.cab_menu_select_all: { @@ -994,8 +994,9 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { actionMode.invalidate(); break; } - case R.id.action_download_versions: { - + case R.id.chat_cab_menu_forward: { + log("Forward message"); + forwardMessages(messagesSelected); break; } case R.id.action_delete_versions: { @@ -1146,6 +1147,12 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { } } + public void forwardMessages(ArrayList messagesSelected){ + log("forwardMessages"); + ChatController chatC = new ChatController(this); + chatC.prepareMessagesToForward(messagesSelected, chatId); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { log("onActivityResult, resultCode: " + resultCode); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index bb6501f4ee2..05a41763d19 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -284,7 +284,7 @@ public List getSelectedItems() { /* * Get list of all selected messages */ - public List getSelectedMessages() { + public ArrayList getSelectedMessages() { ArrayList messages = new ArrayList(); for (int i = 0;i < selectedItems.size();i++) { @@ -304,7 +304,6 @@ public NodeAttachmentHistoryAdapter(Context _context, ArrayList this.messages = _messages; this.adapterType = adapterType; - dbH = DatabaseHandler.getDbHandler(context); this.listFragment = recyclerView; diff --git a/app/src/main/res/layout/activity_group_chat_properties.xml b/app/src/main/res/layout/activity_group_chat_properties.xml index 52b2ebf1856..326c14936a1 100644 --- a/app/src/main/res/layout/activity_group_chat_properties.xml +++ b/app/src/main/res/layout/activity_group_chat_properties.xml @@ -180,6 +180,43 @@ android:layout_height="1dp" android:background="@color/divider_upgrade_account" /> + + + + + + + + + + + diff --git a/app/src/main/res/layout/content_chat_contact_properties_activity.xml b/app/src/main/res/layout/content_chat_contact_properties_activity.xml index 18ff8ea83c3..5aeaf409744 100644 --- a/app/src/main/res/layout/content_chat_contact_properties_activity.xml +++ b/app/src/main/res/layout/content_chat_contact_properties_activity.xml @@ -332,7 +332,7 @@ android:layout_height="1dp" android:background="@color/divider_upgrade_account" /> - + Date: Thu, 13 Dec 2018 17:48:52 +0100 Subject: [PATCH 194/247] Fix null pointer of PR713 --- .../app/lollipop/megachat/ChatActivityLollipop.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 7d0e6cdc4ca..17b12cfa658 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -21,7 +21,6 @@ import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; -import android.support.v4.app.NotificationCompatSideChannelService; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.support.v4.content.LocalBroadcastManager; @@ -5500,9 +5499,11 @@ public int appendMessagePosition(AndroidMegaChatMessage msg){ msg.setShowAvatar(true); if(!messages.get(lastIndex).isUploading()){ int nextIndex = lastIndex+1; - if(messages.get(nextIndex)!=null) { - if(messages.get(nextIndex).isUploading()){ - adjustInfoToShow(nextIndex); + if(nextIndex Date: Thu, 13 Dec 2018 18:08:09 +0100 Subject: [PATCH 195/247] Add notifyDataSetChanged after desactivating the multiselection mode --- .../lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java index a71bc0d907e..494e93c73bc 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaChatLollipopAdapter.java @@ -6888,7 +6888,7 @@ public void setMultipleSelect(boolean multipleSelect) { log("setMultipleSelect"); if (this.multipleSelect != multipleSelect) { this.multipleSelect = multipleSelect; -// notifyDataSetChanged(); + notifyDataSetChanged(); } if (this.multipleSelect) { selectedItems = new SparseBooleanArray(); From eb58f221ad8373764e609d1b141f64c2bf94fe0a Mon Sep 17 00:00:00 2001 From: Javier Gomez Date: Fri, 14 Dec 2018 13:48:16 +0100 Subject: [PATCH 196/247] Add support for the new overstorage logic --- .../privacy/android/app/MegaApplication.java | 16 +++++++++------ .../app/lollipop/ManagerActivityLollipop.java | 20 ++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java index 8b871609406..6f70a5b0da3 100644 --- a/app/src/main/java/mega/privacy/android/app/MegaApplication.java +++ b/app/src/main/java/mega/privacy/android/app/MegaApplication.java @@ -1310,12 +1310,16 @@ public void onEvent(MegaApiJava api, MegaEvent event) { if (event.getType() == MegaEvent.EVENT_STORAGE) { log("Storage status changed"); - Intent intent = new Intent(Constants.BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS); - intent.setAction(Constants.ACTION_STORAGE_STATE_CHANGED); - intent.putExtra("state", event.getNumber()); - LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); - - api.getAccountDetails(null); + int state = event.getNumber(); + if (state == MegaApiJava.STORAGE_STATE_CHANGE) { + api.getAccountDetails(null); + } + else { + Intent intent = new Intent(Constants.BROADCAST_ACTION_INTENT_UPDATE_ACCOUNT_DETAILS); + intent.setAction(Constants.ACTION_STORAGE_STATE_CHANGED); + intent.putExtra("state", state); + LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); + } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index ddb7fc8c4d6..43e290d7bca 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -609,8 +609,9 @@ public String getTitle(Context context) { public void onReceive(Context context, Intent intent) { if (intent != null){ if (intent.getAction() == Constants.ACTION_STORAGE_STATE_CHANGED) { - storageState = intent.getIntExtra("state", MegaApiJava.STORAGE_STATE_GREEN); - showStorageStatusDialog(); + int newStorageState = + intent.getIntExtra("state", MegaApiJava.STORAGE_STATE_GREEN); + showStorageStatusDialog(newStorageState); updateAccountDetailsVisibleInfo(); return; } @@ -14980,7 +14981,11 @@ public void onClick(View v) { } private void showStorageStatusDialog() { - switch (storageState) { + showStorageStatusDialog(storageState); + } + + private void showStorageStatusDialog(int newStorageState) { + switch (newStorageState) { case MegaApiJava.STORAGE_STATE_GREEN: log("STORAGE STATE GREEN"); int accountType = ((MegaApplication) getApplication()).getMyAccountInfo().getAccountType(); @@ -14991,16 +14996,21 @@ private void showStorageStatusDialog() { showProPanel(); } } + storageState = newStorageState; break; case MegaApiJava.STORAGE_STATE_ORANGE: log("STORAGE STATE ORANGE"); - showStorageAlmostFullDialog(); + if (newStorageState > storageState) + showStorageAlmostFullDialog(); + storageState = newStorageState; break; case MegaApiJava.STORAGE_STATE_RED: log("STORAGE STATE RED"); - showOverquotaAlert(false); + if (newStorageState > storageState) + showOverquotaAlert(false); + storageState = newStorageState; break; } } From 9519d539f1d9d0df2ff83f96bf0c8a4db63834bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arag=C3=B3n?= Date: Mon, 17 Dec 2018 10:47:52 +0100 Subject: [PATCH 197/247] Update strings.xml (based on Babel changes) --- app/src/main/res/values/strings.xml | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63589f19335..a75510d0976 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1258,7 +1258,7 @@ Retry Message not sent - Attachment uploading + Uploading attachment No conversation history @@ -1920,7 +1920,7 @@ Begin Setup Scan or copy the seed to your Authenticator App. Be sure to backup this seed to a safe place in case you lose your device. - Please enter the code generated by your Authenticator App. + Please enter the 6-digit code generated by your Authenticator App. Verify Next otpauth://totp/MEGA:%s?secret=%s&issuer=MEGA @@ -2132,8 +2132,8 @@ Upload to MEGA Choose destination - Show more - Show less + Show More + Show Less [A]%s [/A][B]sent you a contact request.[/B] [A]%s [/A][B]is now a contact.[/B] @@ -2155,11 +2155,11 @@ Account deleted [A]%s [/A][B]account has been deleted/deactivated.[/B] - [A]Your publicly shared file [/A][B]%s[/B][C] has been taken down.[/C] - [A]Your publicly shared folder [/A][B]%s[/B][C] has been taken down.[/C] + [A]Your publicly shared file [/A][B]%s[/B][C] has been taken down.[/C] + [A]Your publicly shared folder [/A][B]%s[/B][C] has been taken down.[/C] - [A]Your publicly shared file [/A][B]%s[/B][C] has been reinstated.[/C] - [A]Your publicly shared folder [/A][B]%s[/B][C] has been reinstated.[/C] + [A]Your publicly shared file [/A][B]%s[/B][C] has been reinstated.[/C] + [A]Your publicly shared folder [/A][B]%s[/B][C] has been reinstated.[/C] Sent request Received request @@ -2167,7 +2167,7 @@ [A]%s [/A][B]denied your contact request.[/B] [A]%s [/A][B]accepted your contact request.[/B] - [B]Access to folders shared by [/B][A]%s[/A][B] was removed.[/B] + [B]Access to folders shared by [/B][A]%s[/A][B] were removed.[/B] [A]%s[/A][B] has left a shared folder.[/B] [A]%1$s[/A][B] has left the shared folder [/B][A]%2$s.[/A] @@ -2175,7 +2175,7 @@ [B]Contact request from [/B][A]%s [/A][B]was accepted[/B] [B]Contact request from [/B][A]%s [/A][B]was declined[/B] - [A]%s[/A] is your current account + Your current account is [A]%s[/A] * Subject to your participation in our achievement program Select payment method @@ -2192,24 +2192,24 @@ NEW - file.txt + file name - Error. The value typed should be mayour than 0 + Invalid value for auto-away, it should be greater than 0. - Show last active - Allow my contacts to see the last time I was active on MEGA. If disabled you wont be able to see the activity status of your contacts. + Show Last seen… + Allow my contacts to see the last time I was active on MEGA. %d file %d files - + %d folder %d folders - [A]%1$s[/A][B] added %2$s and %3$s[/B] + [A]%1$s[/A][B] added %2$s and %3$s[/B] [A]%1$s [/A][B]added %2$d file.[/B] @@ -2231,7 +2231,7 @@ %d participants - [A]From[/A] %s [A]month[/A] * + [A]From[/A] %s / [A]month[/A] * * recurring subscription can be cancelled anytime before the renewal date SSL certificate error @@ -2243,8 +2243,8 @@ [A]Call ended[/A][C]. Duration: [/C] - [B]%1$s hour[/B] - [B]%1$s hours[/B] + [B]%1$s hour[/B] + [B]%1$s hours[/B] [B]%1$s minute[/B] @@ -2255,9 +2255,9 @@ [B]%1$d seconds[/B] - Last seen today at %1$s - Last seen a long time ago - Last seen %1$s at %2$s + Last seen today %1$s + Last seen a long time ago + Last seen %1$s %2$s Error. The file cannot be opened. From 8ccb4cb87de8819b1488a2360045120e54a4481f Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 17 Dec 2018 12:47:37 +0100 Subject: [PATCH 198/247] Bug #10972 - Chat node history --- .../lollipop/controllers/ChatController.java | 45 +++++++++-- .../listeners/MultipleRequestListener.java | 5 ++ .../megachat/ChatActivityLollipop.java | 6 +- .../megachat/ChatFullScreenImageViewer.java | 2 +- .../NodeAttachmentHistoryActivity.java | 74 ++++++++++++++++++- ...deAttachmentBottomSheetDialogFragment.java | 4 +- .../res/menu/messages_node_history_action.xml | 2 +- 7 files changed, 120 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java index cdcc239cda9..498ab725218 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java @@ -221,7 +221,16 @@ else if(context instanceof ArchivedChatsActivity){ } } - public void deleteMessages(ArrayList messages, MegaChatRoom chat){ + public void deleteMessages(ArrayList messages, MegaChatRoom chat){ + log("deleteMessages: "+messages.size()); + if(messages!=null){ + for(int i=0; i messages, MegaChatRoom chat){ log("deleteMessages: "+messages.size()); if(messages!=null){ for(int i=0; i messages){ + public void saveForOfflineWithMessages(ArrayList messages){ + log("saveForOffline - multiple messages"); + for(int i=0; i messages){ log("saveForOffline - multiple messages"); for(int i=0; i messages){ + log("importNodesFromMessages"); - public void importNodes(ArrayList messages){ - log("importNodes"); + Intent intent = new Intent(context, FileExplorerActivityLollipop.class); + intent.setAction(FileExplorerActivityLollipop.ACTION_PICK_IMPORT_FOLDER); + + long[] longArray = new long[messages.size()]; + for (int i = 0; i < messages.size(); i++) { + longArray[i] = messages.get(i).getMsgId(); + } + intent.putExtra("HANDLES_IMPORT_CHAT", longArray); + + if(context instanceof NodeAttachmentHistoryActivity){ + ((NodeAttachmentHistoryActivity) context).startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER); + } + } + + public void importNodesFromAndroidMessages(ArrayList messages){ + log("importNodesFromAndroidMessages"); Intent intent = new Intent(context, FileExplorerActivityLollipop.class); intent.setAction(FileExplorerActivityLollipop.ACTION_PICK_IMPORT_FOLDER); @@ -1931,9 +1963,6 @@ public void importNodes(ArrayList messages){ if(context instanceof ChatActivityLollipop){ ((ChatActivityLollipop) context).startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER); } - else if(context instanceof NodeAttachmentHistoryActivity){ - ((NodeAttachmentHistoryActivity) context).startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER); - } } public void prepareMessageToForward(long idMessage, long idChat) { diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleRequestListener.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleRequestListener.java index c039f484b21..80da9f240ec 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleRequestListener.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleRequestListener.java @@ -10,6 +10,7 @@ import mega.privacy.android.app.lollipop.megaachievements.AchievementsActivity; import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; import mega.privacy.android.app.lollipop.megachat.ContactAttachmentActivityLollipop; +import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity; import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiJava; @@ -303,6 +304,10 @@ else if(context instanceof AchievementsActivity){ else if(context instanceof AddContactActivityLollipop){ ((AddContactActivityLollipop) context).showSnackbar(message); } + else if(context instanceof NodeAttachmentHistoryActivity){ + ((NodeAttachmentHistoryActivity) context).removeProgressDialog(); + ((NodeAttachmentHistoryActivity) context).showSnackbar(message); + } } } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java index 43144506088..9d0cd89c370 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatActivityLollipop.java @@ -3023,13 +3023,13 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { clearSelections(); hideMultipleSelect(); - chatC.importNodes(messagesSelected); + chatC.importNodesFromAndroidMessages(messagesSelected); break; } case R.id.chat_cab_menu_offline:{ clearSelections(); hideMultipleSelect(); - chatC.saveForOfflineWithMessages(messagesSelected); + chatC.saveForOfflineWithAndroidMessages(messagesSelected); break; } } @@ -3322,7 +3322,7 @@ public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: ChatController cC = new ChatController(chatActivity); - cC.deleteMessages(messages, chat); + cC.deleteAndroidMessages(messages, chat); break; case DialogInterface.BUTTON_NEGATIVE: diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFullScreenImageViewer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFullScreenImageViewer.java index f7450162165..a62e0de1242 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFullScreenImageViewer.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFullScreenImageViewer.java @@ -666,7 +666,7 @@ public void onClick(DialogInterface dialog, int whichButton) { public void importNode(MegaNode node){ - log("importNodes"); + log("importNodesFromAndroidMessages"); nodeToImport = node; Intent intent = new Intent(this, FileExplorerActivityLollipop.class); diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index 0d6f71b2283..e25447fbd2e 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -996,11 +996,44 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { } case R.id.chat_cab_menu_forward: { log("Forward message"); + clearSelections(); + hideMultipleSelect(); forwardMessages(messagesSelected); break; } - case R.id.action_delete_versions: { - //showConfirmationRemoveVersions(nodes); + case R.id.chat_cab_menu_delete:{ + clearSelections(); + hideMultipleSelect(); + //Delete + showConfirmationDeleteMessages(messagesSelected, chatRoom); + break; + } + case R.id.chat_cab_menu_download:{ + clearSelections(); + hideMultipleSelect(); + + ArrayList list = new ArrayList<>(); + for(int i = 0; i messages, final MegaChatRoom chat){ + log("showConfirmationDeleteMessages"); + + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + ChatController cC = new ChatController(nodeAttachmentHistoryActivity); + cC.deleteMessages(messages, chat); + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + break; + } + } + }; + + AlertDialog.Builder builder; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); + } + else{ + builder = new AlertDialog.Builder(this); + } + + if(messages.size()==1){ + builder.setMessage(R.string.confirmation_delete_one_message); + } + else{ + builder.setMessage(R.string.confirmation_delete_several_messages); + } + builder.setPositiveButton(R.string.context_remove, dialogClickListener) + .setNegativeButton(R.string.general_cancel, dialogClickListener).show(); + } + public void forwardMessages(ArrayList messagesSelected){ log("forwardMessages"); ChatController chatC = new ChatController(this); diff --git a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java index cb305d25b58..b3959268d20 100644 --- a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java +++ b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/NodeAttachmentBottomSheetDialogFragment.java @@ -411,7 +411,7 @@ public void onClick(View v) { if(message!=null){ ArrayList messages = new ArrayList<>(); messages.add(message); - chatC.saveForOfflineWithMessages(messages); + chatC.saveForOfflineWithAndroidMessages(messages); } else{ log("Message is NULL"); @@ -442,7 +442,6 @@ public void onClick(View v) { mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); } - @Override public void onAttach(Activity activity) { log("onAttach"); @@ -450,7 +449,6 @@ public void onAttach(Activity activity) { this.context = activity; } - @Override public void onAttach(Context context) { super.onAttach(context); diff --git a/app/src/main/res/menu/messages_node_history_action.xml b/app/src/main/res/menu/messages_node_history_action.xml index a52b2823db9..1d6feedc35d 100644 --- a/app/src/main/res/menu/messages_node_history_action.xml +++ b/app/src/main/res/menu/messages_node_history_action.xml @@ -33,7 +33,7 @@ From a0643e7bd5641b7e56b8a93fdd8636df80c94998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arag=C3=B3n?= Date: Mon, 17 Dec 2018 13:49:22 +0100 Subject: [PATCH 199/247] Update strings.xml from Babel and based on comments in #translation --- app/src/main/res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a75510d0976..c8da033c688 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1602,7 +1602,7 @@ File Name Link name - link.url + Link URL SUBJECT CONTENT @@ -2185,7 +2185,7 @@ Cancel Continue - [A]Google Wallet[/A] (subscription) + [A]Google Pay[/A] (subscription) [A]Credit Card[/A] (subscription) [A]Mobile Carrier[/A] (one-off) [A]Mobile Carrier[/A] (one-off) @@ -2197,7 +2197,7 @@ Invalid value for auto-away, it should be greater than 0. Show Last seen… - Allow my contacts to see the last time I was active on MEGA. + Allow your contacts to see the last time you were active on MEGA. %d file From 308ff23baf2021febcbda9fdbdd40c03212a9cf6 Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Mon, 17 Dec 2018 14:26:41 +0100 Subject: [PATCH 200/247] Bug #11167 - When clicking on a previously approved contact request, it should navigate to the user's chat --- .../app/lollipop/ManagerActivityLollipop.java | 1 + .../NotificationsFragmentLollipop.java | 56 ++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index a07aecdee16..8be2803c7c3 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -5390,6 +5390,7 @@ public void selectDrawerItemLollipop(DrawerItem item){ log("selectDrawerItemLollipop: "+item); ((MegaApplication)getApplication()).setRecentChatVisible(false); + drawerItem = item; switch (item){ case CLOUD_DRIVE:{ diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/NotificationsFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/NotificationsFragmentLollipop.java index fa521930258..b658237923b 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/NotificationsFragmentLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/NotificationsFragmentLollipop.java @@ -2,6 +2,7 @@ import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -28,11 +29,18 @@ import mega.privacy.android.app.DatabaseHandler; import mega.privacy.android.app.MegaApplication; import mega.privacy.android.app.R; +import mega.privacy.android.app.lollipop.ContactInfoActivityLollipop; import mega.privacy.android.app.lollipop.ManagerActivityLollipop; import mega.privacy.android.app.lollipop.adapters.MegaNotificationsAdapter; +import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop; +import mega.privacy.android.app.utils.Constants; import mega.privacy.android.app.utils.Util; import nz.mega.sdk.MegaApiAndroid; +import nz.mega.sdk.MegaChatApiAndroid; +import nz.mega.sdk.MegaChatPeerList; +import nz.mega.sdk.MegaChatRoom; import nz.mega.sdk.MegaNode; +import nz.mega.sdk.MegaUser; import nz.mega.sdk.MegaUserAlert; public class NotificationsFragmentLollipop extends Fragment implements View.OnClickListener { @@ -40,6 +48,7 @@ public class NotificationsFragmentLollipop extends Fragment implements View.OnCl private static final String BUNDLE_RECYCLER_LAYOUT = "classname.recycler.layout"; MegaApiAndroid megaApi; + MegaChatApiAndroid megaChatApi; DatabaseHandler dbH; @@ -74,6 +83,12 @@ public void onCreate(Bundle savedInstanceState) { megaApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaApi(); } + if(Util.isChatEnabled()){ + if (megaChatApi == null){ + megaChatApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaChatApi(); + } + } + dbH = DatabaseHandler.getDbHandler(getActivity()); } @@ -240,10 +255,47 @@ public void itemClick(int position) { switch (alertType) { case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_REQUEST: + case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTOUTGOING_ACCEPTED: + case MegaUserAlert.TYPE_CONTACTCHANGE_CONTACTESTABLISHED: + case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_ACCEPTED: + { + MegaUser contact = megaApi.getContact(notif.getEmail()); + if(contact!=null){ + if(Util.isChatEnabled()){ + log("Go to chat"); + MegaChatRoom chat = megaChatApi.getChatRoomByUser(contact.getHandle()); + if(chat==null){ + log("No chat, create it!"); + MegaChatPeerList peers = MegaChatPeerList.createInstance(); + peers.addPeer(contact.getHandle(), MegaChatPeerList.PRIV_STANDARD); + megaChatApi.createChat(false, peers, ((ManagerActivityLollipop) context)); + } + else{ + log("There is already a chat, open it!"); + ((ManagerActivityLollipop) context).selectDrawerItemLollipop(ManagerActivityLollipop.DrawerItem.CHAT); + Intent intentOpenChat = new Intent(context, ChatActivityLollipop.class); + intentOpenChat.setAction(Constants.ACTION_CHAT_SHOW_MESSAGES); + intentOpenChat.putExtra("CHAT_ID", chat.getChatId()); + intentOpenChat.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + context.startActivity(intentOpenChat); + } + } + else{ + log("Go to contact info"); + Intent intent = new Intent(context, ContactInfoActivityLollipop.class); + intent.putExtra("name", notif.getEmail()); + startActivity(intent); + } + } + else{ + log("Go to Received requests"); + ((ManagerActivityLollipop)context).navigateToContacts(2); + } + break; + } case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_CANCELLED: case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_REMINDER: case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_IGNORED: - case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_ACCEPTED: case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_DENIED:{ log("Go to Received requests"); ((ManagerActivityLollipop)context).navigateToContacts(2); @@ -254,9 +306,7 @@ public void itemClick(int position) { ((ManagerActivityLollipop)context).navigateToContacts(1); break; } - case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTOUTGOING_ACCEPTED: case MegaUserAlert.TYPE_CONTACTCHANGE_DELETEDYOU: - case MegaUserAlert.TYPE_CONTACTCHANGE_CONTACTESTABLISHED: case MegaUserAlert.TYPE_CONTACTCHANGE_ACCOUNTDELETED: case MegaUserAlert.TYPE_CONTACTCHANGE_BLOCKEDYOU:{ log("Go to Contacts"); From 7272327217f1a8ce37e91f188c58073aaa2c679d Mon Sep 17 00:00:00 2001 From: raquelgc6 Date: Mon, 17 Dec 2018 14:31:10 +0100 Subject: [PATCH 201/247] fix add to cloud drive --- .../android/app/lollipop/controllers/ChatController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java index 498ab725218..53b14084a04 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java @@ -1963,6 +1963,9 @@ public void importNodesFromAndroidMessages(ArrayList mes if(context instanceof ChatActivityLollipop){ ((ChatActivityLollipop) context).startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER); } + else if(context instanceof NodeAttachmentHistoryActivity){ + ((NodeAttachmentHistoryActivity) context).startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER); + } } public void prepareMessageToForward(long idMessage, long idChat) { From e001a884b8bde08e4d60ecfdfd054a3c75c2e5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arag=C3=B3n?= Date: Tue, 18 Dec 2018 13:37:51 +0100 Subject: [PATCH 202/247] Update strings.xml with changes from Babel --- app/src/main/res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c8da033c688..c2774f4a7d0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2261,8 +2261,8 @@ Error. The file cannot be opened. - Type password - %s is protected. Enter the document opening password. - Wrong password. Try again. - The password is not valid. + Enter your password + %s is a password protected PDF document. Please enter the password to open the PDF. + You have entered the wrong password, please try again. + The password you have entered is not valid. From 5ba7bed8e06be2583239d58f209159deb19f7a16 Mon Sep 17 00:00:00 2001 From: Yenel Rodriguez Date: Tue, 18 Dec 2018 13:41:38 +0100 Subject: [PATCH 203/247] Bug #11140-Audio/Video playback doesn't stop on receiving a phone call --- .../lollipop/AudioVideoPlayerLollipop.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java index 83cf20b8651..63e835133b4 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java @@ -129,6 +129,8 @@ import nz.mega.sdk.MegaChatApi; import nz.mega.sdk.MegaChatApiAndroid; import nz.mega.sdk.MegaChatApiJava; +import nz.mega.sdk.MegaChatCall; +import nz.mega.sdk.MegaChatCallListenerInterface; import nz.mega.sdk.MegaChatError; import nz.mega.sdk.MegaChatListItem; import nz.mega.sdk.MegaChatMessage; @@ -151,7 +153,8 @@ import static android.graphics.Color.TRANSPARENT; import static mega.privacy.android.app.lollipop.FileInfoActivityLollipop.TYPE_EXPORT_REMOVE; -public class AudioVideoPlayerLollipop extends PinActivityLollipop implements View.OnClickListener, View.OnTouchListener, MegaGlobalListenerInterface, VideoRendererEventListener, MegaRequestListenerInterface, MegaChatRequestListenerInterface, MegaTransferListenerInterface, DraggableView.DraggableListener{ +public class AudioVideoPlayerLollipop extends PinActivityLollipop implements View.OnClickListener, View.OnTouchListener, MegaGlobalListenerInterface, VideoRendererEventListener, MegaRequestListenerInterface, + MegaChatRequestListenerInterface, MegaTransferListenerInterface, DraggableView.DraggableListener, MegaChatCallListenerInterface { boolean fromChatSavedInstance = false; int[] screenPosition; @@ -582,6 +585,8 @@ else if (adapterType == Constants.FROM_CHAT){ finish(); return; } + + megaChatApi.addChatCallListener(this); } if (isFolderLink) { @@ -766,6 +771,14 @@ public boolean onPreDraw() { } } + @Override + public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) { + log("onChatCallUpdate "); + if (player != null && player.getPlayWhenReady()) { + player.setPlayWhenReady(false); + } + } + class GetMediaFilesTask extends AsyncTask { @Override @@ -3455,6 +3468,10 @@ protected void onDestroy() { megaApi.httpServerStop(); } + if (megaChatApi != null) { + megaChatApi.removeChatCallListener(this); + } + if (megaApiFolder != null) { megaApiFolder.httpServerStop(); } @@ -3741,6 +3758,11 @@ public void onBackPressed() { megaApi.removeGlobalListener(this); megaApi.httpServerStop(); } + + if (megaChatApi != null) { + megaChatApi.removeChatCallListener(this); + } + if (player != null){ player.release(); } From 79b5e5d5b285481a146fd7db9fdccfddd5b73fae Mon Sep 17 00:00:00 2001 From: Carolina Zato Date: Tue, 18 Dec 2018 14:36:20 +0100 Subject: [PATCH 204/247] Feature #10972 - Chat node history --- .../NodeAttachmentHistoryActivity.java | 157 ++++++++++++------ .../NodeAttachmentHistoryAdapter.java | 4 +- .../main/res/layout/activity_node_history.xml | 29 +++- .../main/res/menu/activity_node_history.xml | 22 +++ 4 files changed, 160 insertions(+), 52 deletions(-) create mode 100644 app/src/main/res/menu/activity_node_history.xml diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java index e25447fbd2e..33a5343c562 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java @@ -52,6 +52,7 @@ import mega.privacy.android.app.MegaPreferences; import mega.privacy.android.app.MimeTypeList; import mega.privacy.android.app.R; +import mega.privacy.android.app.components.NewGridRecyclerView; import mega.privacy.android.app.components.PositionDividerItemDecoration; import mega.privacy.android.app.components.SimpleDividerItemDecoration; import mega.privacy.android.app.lollipop.AudioVideoPlayerLollipop; @@ -101,10 +102,14 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement private android.support.v7.app.AlertDialog downloadConfirmationDialog; MegaChatMessage selectedMessage; DatabaseHandler dbH = null; + MegaPreferences prefs = null; + public boolean isList = true; int selectedPosition; RelativeLayout container; + LinearLayout linearLayoutList; + LinearLayout linearLayoutGrid; RecyclerView listView; LinearLayoutManager mLayoutManager; GestureDetectorCompat detector; @@ -113,6 +118,7 @@ public class NodeAttachmentHistoryActivity extends PinActivityLollipop implement ImageView emptyImageView; MenuItem importIcon; + private MenuItem thumbViewMenuItem; ArrayList messages; ArrayList bufferMessages; @@ -192,6 +198,23 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_node_history); + if (savedInstanceState != null){ + chatId = savedInstanceState.getLong("chatId", -1); + } + + prefs = dbH.getPreferences(); + if (prefs == null){ + isList=true; + } + else{ + if (prefs.getPreferredViewList() == null){ + isList = true; + } + else{ + isList = Boolean.parseBoolean(prefs.getPreferredViewList()); + } + } + //Set toolbar tB = (Toolbar) findViewById(R.id.toolbar_node_history); setSupportActionBar(tB); @@ -206,14 +229,57 @@ protected void onCreate(Bundle savedInstanceState) { detector = new GestureDetectorCompat(this, new RecyclerViewOnGestureListener()); - listView = (RecyclerView) findViewById(R.id.node_history_list_view); + emptyLayout = (RelativeLayout) findViewById(R.id.empty_layout_node_history); + emptyTextView = (TextView) findViewById(R.id.empty_text_node_history); + emptyImageView = (ImageView) findViewById(R.id.empty_image_view_node_history); + + if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){ + emptyImageView.setImageResource(R.drawable.contacts_empty_landscape); + }else{ + emptyImageView.setImageResource(R.drawable.ic_empty_contacts); + } + + String textToShow = String.format(getString(R.string.context_empty_shared_files)); + try{ + textToShow = textToShow.replace("[A]", ""); + textToShow = textToShow.replace("[/A]", ""); + textToShow = textToShow.replace("[B]", ""); + textToShow = textToShow.replace("[/B]", ""); + } + catch (Exception e){} + Spanned result = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { + result = Html.fromHtml(textToShow,Html.FROM_HTML_MODE_LEGACY); + } else { + result = Html.fromHtml(textToShow); + } + emptyTextView.setText(result); + + linearLayoutList = (LinearLayout) findViewById(R.id.linear_layout_recycler_list); + linearLayoutGrid = (LinearLayout) findViewById(R.id.linear_layout_recycler_grid); + + if(isList){ + linearLayoutList.setVisibility(View.VISIBLE); + linearLayoutGrid.setVisibility(View.GONE); + + listView = (RecyclerView) findViewById(R.id.node_history_list_view); + listView.addItemDecoration(new PositionDividerItemDecoration(this, outMetrics)); + mLayoutManager = new LinearLayoutManager(this); + mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); + listView.setLayoutManager(mLayoutManager); + listView.addOnItemTouchListener(this); + listView.setItemAnimator(new DefaultItemAnimator()); + } + else{ + linearLayoutList.setVisibility(View.GONE); + linearLayoutGrid.setVisibility(View.VISIBLE); + + listView = (NewGridRecyclerView)findViewById(R.id.file_grid_view_browser); + } + listView.setPadding(0,Util.scaleHeightPx(8, outMetrics),0,Util.scaleHeightPx(16, outMetrics)); listView.setClipToPadding(false); - listView.addItemDecoration(new PositionDividerItemDecoration(this, outMetrics)); - mLayoutManager = new LinearLayoutManager(this); - listView.setLayoutManager(mLayoutManager); - listView.addOnItemTouchListener(this); - listView.setItemAnimator(new DefaultItemAnimator()); + listView.setHasFixedSize(true); listView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override @@ -239,38 +305,10 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { } } } + checkScroll(); } }); - emptyLayout = (RelativeLayout) findViewById(R.id.empty_layout_node_history); - emptyTextView = (TextView) findViewById(R.id.empty_text_node_history); - emptyImageView = (ImageView) findViewById(R.id.empty_image_view_node_history); - - if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){ - emptyImageView.setImageResource(R.drawable.contacts_empty_landscape); - }else{ - emptyImageView.setImageResource(R.drawable.ic_empty_contacts); - } - - String textToShow = String.format(getString(R.string.context_empty_shared_files)); - try{ - textToShow = textToShow.replace("[A]", ""); - textToShow = textToShow.replace("[/A]", ""); - textToShow = textToShow.replace("[B]", ""); - textToShow = textToShow.replace("[/B]", ""); - } - catch (Exception e){} - Spanned result = null; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - result = Html.fromHtml(textToShow,Html.FROM_HTML_MODE_LEGACY); - } else { - result = Html.fromHtml(textToShow); - } - emptyTextView.setText(result); - - if (savedInstanceState != null){ - chatId = savedInstanceState.getLong("chatId", -1); - } Bundle extras = getIntent().getExtras(); if (extras != null){ @@ -299,21 +337,19 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { messages = new ArrayList(); - if (adapter == null){ - adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + if(isList){ + if (adapter == null){ + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_LIST); + } + } + else{ + if (adapter == null){ + adapter = new NodeAttachmentHistoryAdapter(this, messages, listView, NodeAttachmentHistoryAdapter.ITEM_VIEW_TYPE_GRID); + } } listView.setAdapter(adapter); adapter.setMultipleSelect(false); - listView.setLayoutManager(mLayoutManager); - listView.addItemDecoration(new SimpleDividerItemDecoration(this, outMetrics)); - listView.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - checkScroll(); - } - }); adapter.setMessages(messages); @@ -354,12 +390,11 @@ public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.activity_folder_contact_list, menu); + inflater.inflate(R.menu.activity_node_history, menu); selectMenuItem = menu.findItem(R.id.action_select); unSelectMenuItem = menu.findItem(R.id.action_unselect); - - menu.findItem(R.id.action_folder_contacts_list_share_folder).setVisible(false); + thumbViewMenuItem= menu.findItem(R.id.action_grid); return super.onCreateOptionsMenu(menu); } @@ -368,6 +403,15 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) { selectMenuItem.setVisible(true); unSelectMenuItem.setVisible(false); + if (isList){ + thumbViewMenuItem.setTitle(getString(R.string.action_grid)); + thumbViewMenuItem.setIcon(Util.mutateIcon(this, R.drawable.ic_menu_gridview, R.color.black)); + } + else{ + thumbViewMenuItem.setTitle(getString(R.string.action_list)); + thumbViewMenuItem.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_menu_list_view)); + } + return super.onPrepareOptionsMenu(menu); } @@ -384,6 +428,20 @@ public boolean onOptionsItemSelected(MenuItem item) { selectAll(); return true; } + case R.id.action_grid:{ + isList = !isList; + dbH.setPreferredViewList(isList); + + if (isList){ + thumbViewMenuItem.setTitle(getString(R.string.action_grid)); + } + else{ + thumbViewMenuItem.setTitle(getString(R.string.action_list)); + } + + adapter.notifyDataSetChanged(); + return true; + } default:{ return super.onOptionsItemSelected(item); } @@ -1501,6 +1559,7 @@ public void onAttachmentLoaded(MegaChatApiJava api, MegaChatMessage msg) { } } else{ + log("New state of history: "+stateHistory); fullHistoryReceivedOnLoad(); isLoadingHistory = false; } diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java index 05a41763d19..1f1508d7957 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java @@ -860,12 +860,12 @@ public void onClick(View v) { } switch (v.getId()) { case R.id.file_list_three_dots_layout: - case R.id.file_grid_three_dots: { + case R.id.file_grid_three_dots:{ threeDotsClicked(currentPosition,m); break; } case R.id.file_grid_three_dots_for_file: { - //threeDotsClicked(currentPosition,n); + threeDotsClicked(currentPosition,m); break; } case R.id.file_list_item_layout: diff --git a/app/src/main/res/layout/activity_node_history.xml b/app/src/main/res/layout/activity_node_history.xml index e64219b970e..5dfa00226bd 100644 --- a/app/src/main/res/layout/activity_node_history.xml +++ b/app/src/main/res/layout/activity_node_history.xml @@ -52,7 +52,7 @@ @@ -68,4 +68,31 @@ android:choiceMode="multipleChoice" /> + + + + + + + + + + diff --git a/app/src/main/res/menu/activity_node_history.xml b/app/src/main/res/menu/activity_node_history.xml new file mode 100644 index 00000000000..ccc0945ef7c --- /dev/null +++ b/app/src/main/res/menu/activity_node_history.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file From 5f8c2cfb4aec897b10b8ff04bb125eb643ffb3e7 Mon Sep 17 00:00:00 2001 From: Javier Gomez Date: Tue, 18 Dec 2018 14:39:30 +0100 Subject: [PATCH 205/247] Update dialogs for storage overquota warnings Task #11058: Update dialogs for storage overquota warnings --- .../app/lollipop/ManagerActivityLollipop.java | 337 ++++++++++-------- .../res/drawable-hdpi/ic_storage_full.png | Bin 0 -> 7382 bytes .../res/drawable-mdpi/ic_storage_full.png | Bin 0 -> 4565 bytes .../res/drawable-xhdpi/ic_storage_full.png | Bin 0 -> 9720 bytes .../res/drawable-xxhdpi/ic_storage_full.png | Bin 0 -> 16363 bytes .../res/drawable-xxxhdpi/ic_storage_full.png | Bin 0 -> 15918 bytes ...t.xml => storage_status_dialog_layout.xml} | 20 +- app/src/main/res/values/strings.xml | 7 +- 8 files changed, 196 insertions(+), 168 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_storage_full.png create mode 100644 app/src/main/res/drawable-mdpi/ic_storage_full.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_storage_full.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_storage_full.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_storage_full.png rename app/src/main/res/layout/{storage_almost_full_layout.xml => storage_status_dialog_layout.xml} (86%) diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java index 43e290d7bca..cf12e0248a2 100644 --- a/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java +++ b/app/src/main/java/mega/privacy/android/app/lollipop/ManagerActivityLollipop.java @@ -339,8 +339,7 @@ public class ManagerActivityLollipop extends PinActivityLollipop implements Mega boolean newAccount = false; private int storageState = MegaApiJava.STORAGE_STATE_GREEN; - private boolean showStorageOverquotaDialog = true; - private boolean showStorageAlmostFullDialog = true; + private boolean isStorageStatusDialogShown = false; int orientationSaved; @@ -506,7 +505,6 @@ public String getTitle(Context context) { private AlertDialog renameDialog; private AlertDialog newFolderDialog; private AlertDialog addContactDialog; - private AlertDialog overquotaDialog; private AlertDialog permissionsDialog; private AlertDialog presenceStatusDialog; private AlertDialog openLinkDialog; @@ -518,7 +516,7 @@ public String getTitle(Context context) { private AlertDialog generalDialog; private AlertDialog setPinDialog; private AlertDialog alertDialogTransferOverquota; - private AlertDialog alertDialogStorageAlmostFull; + private AlertDialog alertDialogStorageStatus; private MenuItem searchMenuItem; private MenuItem gridSmallLargeMenuItem; @@ -611,7 +609,7 @@ public void onReceive(Context context, Intent intent) { if (intent.getAction() == Constants.ACTION_STORAGE_STATE_CHANGED) { int newStorageState = intent.getIntExtra("state", MegaApiJava.STORAGE_STATE_GREEN); - showStorageStatusDialog(newStorageState); + checkStorageStatus(newStorageState, false); updateAccountDetailsVisibleInfo(); return; } @@ -1636,6 +1634,7 @@ public void onSaveInstanceState(Bundle outState) { outState.putInt("bottomNavigationCurrentItem", bottomNavigationCurrentItem); outState.putBoolean("searchExpand", searchExpand); outState.putInt("storageState", storageState); + outState.putBoolean("isStorageStatusDialogShown", isStorageStatusDialogShown); } @Override @@ -1694,6 +1693,7 @@ protected void onCreate(Bundle savedInstanceState) { bottomNavigationCurrentItem = savedInstanceState.getInt("bottomNavigationCurrentItem", -1); searchExpand = savedInstanceState.getBoolean("searchExpand", false); storageState = savedInstanceState.getInt("storageState", -1); + isStorageStatusDialogShown = savedInstanceState.getBoolean("isStorageStatusDialogShown", false); } else{ log("Bundle is NULL"); @@ -2873,7 +2873,7 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){ drawerLayout.closeDrawer(Gravity.LEFT); } - showStorageStatusDialog(); + checkStorageStatus(true); //INITIAL FRAGMENT if(selectDrawerItemPending){ @@ -4164,7 +4164,7 @@ protected void onDestroy(){ megaChatApi.removeChatCallListener(this); } - showStorageAlmostFullDialog = true; + isStorageStatusDialogShown = false; LocalBroadcastManager.getInstance(this).unregisterReceiver(receiverUpdatePosition); LocalBroadcastManager.getInstance(this).unregisterReceiver(updateMyAccountReceiver); @@ -4585,7 +4585,7 @@ public void showOnlineMode(){ // } updateAccountDetailsVisibleInfo(); updateAccountDetailsVisibleInfo(); - showStorageStatusDialog(); + checkStorageStatus(false); } else { log("showOnlineMode - Root is NULL"); if (getApplicationContext() != null) { @@ -12865,56 +12865,6 @@ else if(dialog instanceof ContactsBottomSheetDialogFragment){ return -1; } - private void showOverquotaAlert(boolean prewarning){ - log("showOverquotaAlert: prewarning: "+prewarning); - - if(!showStorageOverquotaDialog){ - log("Storage overquota dialog already shown"); - return; - } - - showStorageOverquotaDialog = false; - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.overquota_alert_title)); - - if(prewarning){ - builder.setMessage(getString(R.string.pre_overquota_alert_text)); - } - else{ - builder.setMessage(getString(R.string.overquota_alert_text)); - } - - if(overquotaDialog==null){ - - builder.setPositiveButton(getString(R.string.my_account_upgrade_pro), new android.content.DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - showStorageOverquotaDialog = true; - //Show UpgradeAccountActivity - drawerItem = DrawerItem.ACCOUNT; - accountFragment=Constants.UPGRADE_ACCOUNT_FRAGMENT; - selectDrawerItemAccount(); - } - }); - builder.setNegativeButton(getString(R.string.general_cancel), new android.content.DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - showStorageOverquotaDialog = true; - overquotaDialog=null; - } - }); - - overquotaDialog = builder.create(); - overquotaDialog.setCanceledOnTouchOutside(false); - } - - overquotaDialog.show(); - } - public void updateAccountDetailsVisibleInfo(){ log("updateAccountDetailsVisibleInfo"); if(isFinishing()){ @@ -14980,11 +14930,20 @@ public void onClick(View v) { alertDialogTransferOverquota.show(); } - private void showStorageStatusDialog() { - showStorageStatusDialog(storageState); + /** + * Check the current storage state. + * @param onCreate Flag to indicate if the method was called from "onCreate" or not. + */ + private void checkStorageStatus(boolean onCreate) { + checkStorageStatus(storageState, onCreate); } - private void showStorageStatusDialog(int newStorageState) { + /** + * Check the storage state provided as first parameter. + * @param newStorageState Storage state to check. + * @param onCreate Flag to indicate if the method was called from "onCreate" or not. + */ + private void checkStorageStatus(int newStorageState, boolean onCreate) { switch (newStorageState) { case MegaApiJava.STORAGE_STATE_GREEN: log("STORAGE STATE GREEN"); @@ -15001,155 +14960,219 @@ private void showStorageStatusDialog(int newStorageState) { case MegaApiJava.STORAGE_STATE_ORANGE: log("STORAGE STATE ORANGE"); - if (newStorageState > storageState) + if (onCreate && isStorageStatusDialogShown) { + isStorageStatusDialogShown = false; + showStorageAlmostFullDialog(); + } else if (newStorageState > storageState) { showStorageAlmostFullDialog(); + } storageState = newStorageState; break; case MegaApiJava.STORAGE_STATE_RED: log("STORAGE STATE RED"); - if (newStorageState > storageState) - showOverquotaAlert(false); + if (onCreate && isStorageStatusDialogShown) { + isStorageStatusDialogShown = false; + showStorageFullDialog(); + } else if (newStorageState > storageState) { + showStorageFullDialog(); + } storageState = newStorageState; break; } } + /** + * Show a dialog to indicate that the storage space is almost full. + */ public void showStorageAlmostFullDialog(){ log("showStorageAlmostFullDialog"); + showStorageStatusDialog(MegaApiJava.STORAGE_STATE_ORANGE, false, false); + } + + /** + * Show a dialog to indicate that the storage space is full. + */ + public void showStorageFullDialog(){ + log("showStorageFullDialog"); + showStorageStatusDialog(MegaApiJava.STORAGE_STATE_RED, false, false); + } + + /** + * Show an overquota alert dialog. + * @param preWarning Flag to indicate if is a pre-overquota alert or not. + */ + public void showOverquotaAlert(boolean preWarning){ + log("showOverquotaAlert: preWarning: "+preWarning); + showStorageStatusDialog( + preWarning ? MegaApiJava.STORAGE_STATE_ORANGE : MegaApiJava.STORAGE_STATE_RED, + true, preWarning); + } + + /** + * Method to show a dialog to indicate the storage status. + * @param storageState Storage status. + * @param overquotaAlert Flag to indicate that is an overquota alert or not. + * @param preWarning Flag to indicate if is a pre-overquota alert or not. + */ + private void showStorageStatusDialog(int storageState, boolean overquotaAlert, boolean preWarning){ + log("showStorageStatusDialog"); if(((MegaApplication) getApplication()).getMyAccountInfo()==null || ((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==-1){ log("Do not show dialog, not info of the account received yet"); return; } - if(!showStorageAlmostFullDialog){ - log("Storage almost full dialog already shown"); + if(isStorageStatusDialogShown){ + log("Storage status dialog already shown"); return; } - showStorageAlmostFullDialog = false; - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); LayoutInflater inflater = this.getLayoutInflater(); - View dialogView = inflater.inflate(R.layout.storage_almost_full_layout, null); + View dialogView = inflater.inflate(R.layout.storage_status_dialog_layout, null); dialogBuilder.setView(dialogView); - TextView title = (TextView) dialogView.findViewById(R.id.storage_almost_full_title); + TextView title = (TextView) dialogView.findViewById(R.id.storage_status_title); title.setText(getString(R.string.action_upgrade_account)); - TextView text = (TextView) dialogView.findViewById(R.id.text_storage_almost_full); - text.setText(getString(R.string.text_almost_full_warning)); + ImageView image = (ImageView) dialogView.findViewById(R.id.image_storage_status); + TextView text = (TextView) dialogView.findViewById(R.id.text_storage_status); - LinearLayout horizontalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.horizontal_buttons_storage_almost_full_layout); - LinearLayout verticalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.vertical_buttons_storage_almost_full_layout); - Button verticalDismissButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_dissmiss); - Button horizontalDismissButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_dissmiss); - Button verticalActionButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_action); - Button horizontalActionButton = (Button) dialogView.findViewById(R.id.horizontal_storage_almost_full_button_payment); - Button achievementsButton = (Button) dialogView.findViewById(R.id.vertical_storage_almost_full_button_achievements); + switch (storageState) { + case MegaApiJava.STORAGE_STATE_GREEN: + log("STORAGE STATE GREEN"); + return; - if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==MegaAccountDetails.ACCOUNT_TYPE_FREE){ - log("show StorageAlmostFull Dialog for FREE USER"); + case MegaApiJava.STORAGE_STATE_ORANGE: + image.setImageResource(R.drawable.ic_storage_almost_full); + text.setText(getString(R.string.text_almost_full_warning)); + break; - if(megaApi.isAchievementsEnabled()){ - horizontalButtonsLayout.setVisibility(View.GONE); - verticalButtonsLayout.setVisibility(View.VISIBLE); - verticalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); + case MegaApiJava.STORAGE_STATE_RED: + image.setImageResource(R.drawable.ic_storage_full); + text.setText(getString(R.string.text_storage_full_warning)); + break; - verticalDismissButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - } + default: + log("STORAGE STATE INVALID VALUE: " + storageState); + return; + } - }); + if (overquotaAlert) { + if (!preWarning) + title.setText(getString(R.string.overquota_alert_title)); - achievementsButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - log("Go to achievements section"); - navigateToAchievements(); - } + text.setText(getString(preWarning ? R.string.pre_overquota_alert_text : + R.string.overquota_alert_text)); + } - }); + LinearLayout horizontalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.horizontal_buttons_storage_status_layout); + LinearLayout verticalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.vertical_buttons_storage_status_layout); - verticalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - navigateToUpgradeAccount(); - } + final OnClickListener dismissClickListener = new OnClickListener() { + public void onClick(View v) { + alertDialogStorageStatus.dismiss(); + isStorageStatusDialogShown = false; + } + }; - }); + final OnClickListener upgradeClickListener = new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageStatus.dismiss(); + isStorageStatusDialogShown = false; + navigateToUpgradeAccount(); } - else{ - horizontalButtonsLayout.setVisibility(View.VISIBLE); - verticalButtonsLayout.setVisibility(View.GONE); - horizontalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); + }; - horizontalDismissButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - } - }); + final OnClickListener achievementsClickListener = new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageStatus.dismiss(); + isStorageStatusDialogShown = false; + log("Go to achievements section"); + navigateToAchievements(); + } + }; - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - navigateToUpgradeAccount(); - } - }); + final OnClickListener customPlanClickListener = new OnClickListener(){ + public void onClick(View v) { + alertDialogStorageStatus.dismiss(); + isStorageStatusDialogShown = false; + askForCustomizedPlan(); } - } - else{ - horizontalButtonsLayout.setVisibility(View.VISIBLE); - verticalButtonsLayout.setVisibility(View.GONE); + }; - if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()>=MegaAccountDetails.ACCOUNT_TYPE_PROIII){ - log("show StorageAlmostFull Dialog for USER PRO III"); - horizontalActionButton.setText(getString(R.string.button_custom_almost_full_warning)); + Button verticalDismissButton = (Button) dialogView.findViewById(R.id.vertical_storage_status_button_dissmiss); + verticalDismissButton.setOnClickListener(dismissClickListener); + Button horizontalDismissButton = (Button) dialogView.findViewById(R.id.horizontal_storage_status_button_dissmiss); + horizontalDismissButton.setOnClickListener(dismissClickListener); - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - askForCustomizedPlan(); - } - }); - } - else{ - log("show StorageAlmostFull Dialog for USER PRO"); - horizontalActionButton.setText(getString(R.string.my_account_upgrade_pro)); + Button verticalActionButton = (Button) dialogView.findViewById(R.id.vertical_storage_status_button_action); + Button horizontalActionButton = (Button) dialogView.findViewById(R.id.horizontal_storage_status_button_payment); + + Button achievementsButton = (Button) dialogView.findViewById(R.id.vertical_storage_status_button_achievements); + achievementsButton.setOnClickListener(achievementsClickListener); - horizontalActionButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; - navigateToUpgradeAccount(); + switch (((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()) { + case MegaAccountDetails.ACCOUNT_TYPE_PROIII: + log("showStorageStatusDialog for USER PRO III"); + if (!overquotaAlert) { + if (storageState == MegaApiJava.STORAGE_STATE_ORANGE) { + text.setText(getString(R.string.text_almost_full_warning_pro3_account)); + } else if (storageState == MegaApiJava.STORAGE_STATE_RED){ + text.setText(getString(R.string.text_storage_full_warning_pro3_account)); } - }); - } + } + horizontalActionButton.setText(getString(R.string.button_custom_almost_full_warning)); + horizontalActionButton.setOnClickListener(customPlanClickListener); + verticalActionButton.setText(getString(R.string.button_custom_almost_full_warning)); + verticalActionButton.setOnClickListener(customPlanClickListener); + break; - horizontalDismissButton.setOnClickListener(new OnClickListener(){ - public void onClick(View v) { - alertDialogStorageAlmostFull.dismiss(); - showStorageAlmostFullDialog = true; + case MegaAccountDetails.ACCOUNT_TYPE_LITE: + case MegaAccountDetails.ACCOUNT_TYPE_PROI: + case MegaAccountDetails.ACCOUNT_TYPE_PROII: + log("showStorageStatusDialog for USER PRO"); + if (!overquotaAlert) { + if (storageState == MegaApiJava.STORAGE_STATE_ORANGE) { + text.setText(getString(R.string.text_almost_full_warning_pro_account)); + } else if (storageState == MegaApiJava.STORAGE_STATE_RED){ + text.setText(getString(R.string.text_storage_full_warning_pro_account)); + } } + horizontalActionButton.setText(getString(R.string.my_account_upgrade_pro)); + horizontalActionButton.setOnClickListener(upgradeClickListener); + verticalActionButton.setText(getString(R.string.my_account_upgrade_pro)); + verticalActionButton.setOnClickListener(upgradeClickListener); + break; - }); + case MegaAccountDetails.ACCOUNT_TYPE_FREE: + default: + log("showStorageStatusDialog for FREE USER"); + horizontalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); + horizontalActionButton.setOnClickListener(upgradeClickListener); + verticalActionButton.setText(getString(R.string.button_plans_almost_full_warning)); + verticalActionButton.setOnClickListener(upgradeClickListener); + break; + } + if(megaApi.isAchievementsEnabled()){ + horizontalButtonsLayout.setVisibility(View.GONE); + verticalButtonsLayout.setVisibility(View.VISIBLE); + } + else{ + horizontalButtonsLayout.setVisibility(View.VISIBLE); + verticalButtonsLayout.setVisibility(View.GONE); } - alertDialogStorageAlmostFull = dialogBuilder.create(); + alertDialogStorageStatus = dialogBuilder.create(); + alertDialogStorageStatus.setCancelable(false); + alertDialogStorageStatus.setCanceledOnTouchOutside(false); + + isStorageStatusDialogShown = true; - alertDialogStorageAlmostFull.setCancelable(false); - alertDialogStorageAlmostFull.setCanceledOnTouchOutside(false); - alertDialogStorageAlmostFull.show(); + alertDialogStorageStatus.show(); } public void askForCustomizedPlan(){ diff --git a/app/src/main/res/drawable-hdpi/ic_storage_full.png b/app/src/main/res/drawable-hdpi/ic_storage_full.png new file mode 100644 index 0000000000000000000000000000000000000000..35cb1cd8590bcb71ac5718f82bc136e22b49e984 GIT binary patch literal 7382 zcmV;{94X_8P)9q5YoQ4RdfV*1%c-I~nMfo9@x0$N6h5aR)H` zfTO?jwXLr^;qcNTNBg1J<^R^jjbyzqlC>UBR=aw#5~u*m8~#znFkL{$NmD6*B{ zT&#h$uqM{VHE^wCuqLjJd%(Q_tUHj=oBPbvZr_%rPds32>x*3N$7&P`NvrW&E3)Ywl zL@Zh8@v=RRcoaVyz`BwyTX^!offw#@_{?HgFTq=Ejht3Gxunzz-)Ilgl}>h(8W@YB zi#$<^pAkPRz`BAiS#*u18OI%-TZdvjb+L_vON}cMDjXq2ll!c}a~eb+_l?{&mM{R; z*>vh+^Wnx>;PCm_&gwkgDybEoNQD-bh^e6qtl!nOP=tILVQL5>nJ*`@YXDSdYPmDCZDxRVkxN!N~(!8 zO3P9wT)dKODbaz_@oX;h#BXqXO$S&<(C!8Ay6diUa%}y>Dlgzg1(KFnp^#KlqEYT} zb)uy!$d*MDExZbTUj^fHT=5}3JAkz(?ON;&)4Vj#8oHEd$%I@wv2OWaJx|bHF#Y;_R8{c8@nVqb%&AeT<9s#r;;OsZg4CLQT?x+T$c zqGQ3g?Kpko#&&(sGxp=N1z1~X)8vPRxU9et+mwEE!AcT{m=|o3KM&jwU z>w0)0lH-Vv7-Off&idJG>(i@Ipt4-LB}-!E#7a^Lp@hIHnX&O^Dg%(D6S67Ma+>9q zO-n|CzCz)v&CRx$4lq@eC#*8HzGbfdTQ!PQmrJKsNvtH4mPj)$kqZ79Ek0bfESgSp zlw=~!`2M=g7r(7?L|=fZpfvcyAw#Y^YHKC6UTfqkrIt=CEtV2UGd{ZsQaCM|PIQ|j z6JMWdVa!pNmwadrxej3IlK#LRJx^g=PmK2~GX8VJXPc zW!X`p6q1}DqZ5Ed5k0^(PlNBf(3-h|Ttrc>e9p>Z!=)0k zR2h*1B|94-(oDAO)=Nf$TD8L$q8osP5;b657Uz|&{$E9VCKts9$|c&dELN5}F(84B z0?+*yP>BUkwXICIL9Zh+GSlVO(WhT^LCl3QkaSZ6{q`%eo_d7zYnS3VW0_Yh z0x2YmC777`1qwBv5-v@DAiaus5$(W+m4 z6(aOmD(~L|p$S8I`7&H67Jwx8E>v%0WKO3gxUg5Z>qE95R>lG8Cx znsLn%azA>Hf_x4qeJmCVdC~AR(h62e2IEt3#ItN%mwWrje(gm`^kPOOx%TmRzItnM zdwb?)pe2#m_{6#Y`fX2p3rBD5g_T+^lUymwa^;wZopDCjl zu#+`y^O}GrBOeHkbhLbc4TWUEQuM0iGSlVaHs0_;%roDm&^D{$h9ed{MMWk|WO@Yq z2lir~`z?j8!(%gxu3a(;Un70RC1l=x6Zv~~R{O@r&y+kiDJ1iKjJs~azqyp0_uit= zFskG4=y>f@C`gW1#rRr0Mrc^%A3Q+L`)`wR`wfWX`Fze|!9d<#R94h#!ACnY>)9pH z1o4e(dhTec6gyjHm7b-|gqaH~%x8naJ~=hdy<{eq8RUkr2=P3XmR>~W19y;r_y9*M z_X+s6e{jE8Z!Rsni0n6Bq9C8=G|gh`pC=~?ADgVoX6cm?%nXi^g*9)kx{Ek}IA^s- zaqOum(sXNuU7qnfSzFti7aNLAg_@%m?fl~WZ5z2tR>-Y0UCVIQJr2?Ry<|QAI7DAa z){_rX`P50VR&71;fM~N{cnX#L0H0&$!qOL1DHH+2j%`;#{huSUqKO(08CC^Cr+3 zaq)Ldkh|NPdyTHv`lA=^TrFBJJW1u_hlQ|cY(ydVS4`LAV-ySxaJuH=i6fU0#hCs2 z3lwCB;$_dVM9H8rl9?Zf%H7?l1uo;1U9(^VHB@&;rk9-pP2-F2+M516*wH#stYhvA z!Q6-FxE|xnp?IMpVj=0J)+<>ahx0jd-g=qzu}%8$oc3U3Qdy>Etd2@ zlN@0K!+QErKF`ymICV8`ppBgZ2*w3|?DI)yLGt*kTz6*TB1*r01%;L_PlXyInaA2O zh_y}3J3l0S^%Z2?yo$Wd>v_?G`&jDq4T?C0Pl&}0Z__$5Zd!#s<}0y;`U!=O8;c%o ze7c_e2?gm^DzeC0$6@{x)b`Ai0MjI*|3iVb!R}Jbf7R((JdyL|$MQl(VhFd0$6sR`0C6z{;V`Ke(62T$a%|$q?*(@CNDEED@U*p>4%tD~jqm zK{CSv$0x^v!QR1xTxfC8T9aTMxBEIXS$3;E(A4y&zVn(Y zB}s7F)vG+7Gz)TgQup9KiekYHmF&BSG->l9)f7sx)yNUc5zWzC4p?eKtLq3;CVl^Y zj^OFjrPQlhB^HcDs|U_*`jfVPar<9TLH}3~a?=aWFN)>jiL(oFymPxGxPg*cU<6W3 zpHfQ(u}HpM=U#Gp$7JA zKD$#0o|3Fyf98~osFekuOQ#_C{)(5wTz#Q9DdU zMD1XqNJGUEWzD$}Y$BrBt+r|YxrcO!l?8)D!8u$@f+3d+t|@ypq=2nHerj7u?CT z{wz2LRD$zD@KlOsPW7K=Fg_k)*?2<*%9l!rZj(&gCfjkyb%E!SS2x}-@n!sUl*=;^ zBoLApOyQ!9CE8w@Ovj@V7fiY-(r;fjkF1vaFMDV4-?(W_3xuJqVeRXZ0P8Y9`P2hl!9u3gxa`>-9 zGVmjq&%?e?c7UFxy{)WT+Uvt2xMvY~O-6$fEFSc&!u1tgPEI_v;Uc(eX`)~v7L4Ff zaL_3l3{TPNlau{ThhWHc6+9i2&B5af4h08aWL-FUaGBKQ3>7?aEd+;x&x|8jSSIlk z9X&`jB67iEnsy349}4y(cvU8NVScdLV2ysFgT97a`&8vF{Q~5A7R=9RT}8p6V7m=@ z{8N?KY}ghA13|DLImXj81Or5I@Pfk>%_A6sA$R1>hWW{_P21arv{ZVlClTzNhs7v{ z+&=w>q2S;Icf|-k!^ILlwhPzzcHwU#U;aWP{>|sH79K?~qBs;Btl-s|OQK-N1*2{F zqphQ1M!Fj=f`KQ&^mY01$5^E^j^I#mcY|KHcUj~7x&4+M2tF;!o%GzY(@qXrcF>rW ziL2*!rZiD7@Fh6^-~+5o0z<*03&wtMwX??Bm+S}@(lg*<2|rDDG$=(Q^84MSq|lO8 z(u4oF@bE({RjNQ{D0l?H*kLNyo2)|bQ6KBzQxd_D>$Pnb!z0J_Gnap_9iP+#l22=00*v<8Av zWG$q#Y$26lyVsWcBtcQnV-DER|oe z1w(juV@q5IBVy&zn-n6~aq(GgN^c#w_za{??f-kp!_H`lJ4;t2L%7(o1Id+Eo6>cG z%`Gjn`Q4G2ey=0%o6@T3R9V)RNb z9|bdU_4F1bj<6o)f}P7Go}vrYIu43Nr$~5;&8O0ADVt*%`T*pLWtJ;d@CMw};25&S zG96QqrE(-Pvp-egm@#eP!(Jq*5RQlik~3Kl%H*)f1yeicdJ`6a+bHcqo~d#?rD=R$KNog%$nh`OU9L=UjLjI)?-L3K!vLP9wP!aV zR2IctFqa$(zHWlKTwFZZw)AJkJL~`q2goI~+xNsMwlpA*;-pT3&xYrsgB8r>dP>i@ zfll7kZzmKH3M^!T!5*R)#nqgt{hCnRz~BlV)lxUqjV-r=%l=QILdsTy7aR)q7QLo6+GBOVY(o3# zj$|%|WPo1}PH-r=GdqK-Si0^7cxc(k55@v`Y+A|CiaQW0k&IufhCNw<^khMB^ZZ#n z##fq}ckRkqFOKzSJAj8%(tq}Lf5==6!T7!W1NVo5$1Jk2;orobF`DkC^r6cl$j1Xi z&ypKLk%2)99$}iL$IHqJu60wh1!t@EuqSK82*!qgYpu<v2h<%|ar?4lS&5h91o0 zWdR;W+%(la6kKkC5y7>ykF)t~9($ucd$K~oXt=9UP^^?Ith2R)A`60t7FKvz_y6PC z=LzL7FnHozT>CZ}0^CwHFS3fQ4x3$C#^yfc%6hWG6g`OC7X5mj#M*M#H*lXU2!>48 z)QpC@i$?U@gyIDZUchtw-%F|bPS;dzL@rm+m1f)S)|g#fMz@BYuImG-x4K}6<={h) z_XmvvXbcdGtS$tbDwlg8HD}G}op3=YUclg)KgT1VsTo>l+gVi`-(+=4(GbjgvWm4j zT2&yLgy&hITEp)-Kh5B1i5#-=-{|c3WS6;gG!@?hCB2pK{man(X(W?wiK&%93(!$_&Y}d zWUxU?QVl&?`~6wz4DUm;({a7sfmozyp^A10HX`C)FU}ag{Gb*4GNJeZgKy3!^dE1C z^Ks%ET(Gn!3%`zoM=ur{e6Z1(8MviraO4Up2a+mUE*LvSX+!@D-g83n z3x<)1A3OG;Y$9^s6Oim(a9BnA5d5UQ-c|3zdrc^#fMH~Q9*ccs#nfl^EHz-kq2MQ` zG*+;pGkA{)WmGVX#b2ir@eE4 zm2-=t@OdxJvst$>8rN-5M77rCh) zX=)a=cK3!1{z`)#^sY;-SS&`L66|Y1a0zGP;{N4}WlcDy`!a(=7aJV(5>u5<&xuIN z{*Pd;0KsMK-@pGiu2510lW`3EX$FT3Mt|APUwkA}s!EO?J^DMrTm^zl8BTkA%>qFL zUI-3C27h=J-O*!v)M;}(63Y}(=sSYB5(KwUQCqu_u8`bB5g~)$ZE%;vNlS9)tp*Nf z6JzWf=5JGBY3W3|d}wL!vAuDzA@qcQFAX8DGh3`>m6ekS<}MK2%CTc%eRyI?=JUBW z*bT<^7Bf6uY{&`=3+qELcY@${X!^FQrf!ASWU*m;6Qt&1bQK(7*z1~`SD;T=piL>+ z*@J~rc@7G0@3jYwxu_KeOBAY{w6wG#1oIRK9;c|ZV!BFakYm6Ktg-^tSk#6Zl{&qm zw4!1dzr1`1&Cre-Pz&AMu;nn-Mlf%J;1lfJx%1D4X6|~rK(0n-b=sXcobY*Lp%Gf4 z8QM_;Y9W{}fZ$W$8Q0>n$|)kbB1dPkT*fvGt2?U?nGG$_1Z~g=t0YNR*tT`OGBlhg?}mIex1O{}lg&Z0K|>O)my{w0wo}mRIgqMw@6GIgkrEksBJKqM`;7%pXATJI0M0 z_kCGe_0W>a%4Jfe`m|6gtI`@xZCaE0iq>R#h*c+cc3=+7dj0~kS9gf;JNykhM$cEb z_$=B$TWAw)BL{LJC&By;gn(dYSlIVFckUdVpIcU84@()6sHtmO2}z4cuFe0+B2fdhll7Qq66$4fThXheaG>d%w+0uUo&Yt$)C`U``|t#56(m)RuUvG7EzWPIcYmh+!;HzI_xxwlg5#4 zrBlaJWT#5fEEA=!Hfy0Il9DY-q__aY!VMsZeJ2)Dq9~iv>F;|0O*G zUq`af-Z6B>wD)angKe=7_SJma9vjNF4J8#wBiCFb4?J%*7 z-N=$Q1B=mnv_(mA6528jBevn~*a!RK7&sP=iDU0dXfK$}pBd`XJ~L_6ADy%6{UHL7 z-AAwpM$%5O2u>8hnn^&Vee~ED$Kc1pG3RW0|D@G;bg0Yl49>aZ!JRW}zu=biF9#&O z8yB5(z`FG6un1xcQiTejIf5CbzXxmvx6fvL8GYDs;7(Z#f9bR856?@wOqQUfU}2Ju zMTC?kHcmDS$o_$S4VJ?YA3U zy%zmbTLN#`qPK>v`a;GovpSnPI3+ZwLk6x>=vkTe%Os#SfZ5o+GnBEzc4Og|)o6RH z@W#4yFH)hqs)%*ySW|EUn8MmPtS%Nk&{zVj5~w=J`VbT3Ju$m+bxhK|_*mdMCH<=j zj1&YsRd*HO>bj_aK+s}U9k8(2bC9GI+7AfHfHnpxTw4wi012dtIc>&QKXG^|j2u+z zIROr81dd}^q!j)A6N5O?se7qxc>ig)=CYi!Yb=QB&la=xO3cYS{=6Ot(yXGz@q!>kfbjr z)&WmgT&-(DN@#!*uhsJop>OP4^FCIQfLaG6&Z}^3vvBD;5K(l8Y{nw4eM9h0QlaUm ziGZ}t&>-fSgv+)74i~M2wGXgV)Xn1Gi>@at zcU{1P9FRyDP2e>E_bl4*cm6*4^0!#}$d6d|*C*J*#rIi$@IzK`j}$(|Qk{GSfsTos`E)vU3hC90P=qR_@H&bZak^GNW{oA&%g zP}1j+b=9q}9TM4A9iH6kiOz^wG!kOj?0H zVvF}kD-haO+0w@kApX9TFS5eaG|Qbm#gaeh!H0zNwgOQ-9twb%Q^dq<4s4nNbam<8 z$YEzOtI{a$$zq-=Jd%iWXit6b5X)chXQhP&0&<@KkpOS$4(Tpiyi==XneNfHHCn!3 zf%=f|n;#oxsW*ODIY0m4)FFz*(!iAkL?jfKWO$js<0k0OKh>0RQ ztGTkO6$WjF+y$HI^YzENow`>L`x+(=G4%vcqEx{%wZ;GCn=EtmCv4%;IhG$CBKM*g zHiP&@@yt02Xk{%f5-8F#0l9m(b%=lkw-yjmUlW?;@i)2FAxx`iKUuUWLDU% zZiV21Sm=}tuc*R%lWqgfT6Er&t(o<8$Xr)Kwa=|A`+vV@rFfJs;4WLbw~S}HpgRy= zm$g^|JcvUpO#4_V8i6YVR5OSGL@{!e6{9g$n3=(Qb%@w*m9d4(mslJL1`r{2S8i^F z8g034)ysTk{ux=$Yal!>D{ct;j2jNfKUD|8V{1gKOLTCA!h(;~OTh5pMd z_1bq??$k+EN~Z)!IYh)r0$0jpS@zT)Sn9{$V+#~VVQqk?ZiyeUQlZ3BKl(09{PWk# z?tFlM@S?<$l{Ss65O@2)1FRGPy%=?1!^YMpi+vJr%lz^^ntdvZ$ z?0diCP;wW}Ai2Ojh2`Bxw#~EL`7_vt0G$@5k`>~rpu#Ud>G zyI--?;qOze*Gu~?krvs))k|ojlIMRYM8si<1ZG9V!=@0C=}`iq{9(NODaI4@VVz@% zSH8_+-R;dYG5}U?-utck;F@J5Hze)T1nyxS_f@w(dXLzbIP?M%23^1+psg3807))f zj73@I#4(oo{=bqAvCJ=iMi(3-a0Frbo+7a{ho}^4OTa8G6j|oCzk)&F+LU#n(v89A zA=cvj5#WR*vTw7}B?b$m1E+r2!}3En*kV3Q9a<8=HUJSB8Hpu-`xcEdUT2yAKFTsb zKg!Z?z0UF@!(~t_JVtH;L;-SXF=+1Xlu> za#k%0Q0s(P&DMpn+XU_~OCS4BR+#j{t+@(55861?f^!V+3y_-!5oHh6kLjNt!8HS- z!i{SIVnLISR)ukR|4wV{0v4TL5&x9#i#9sRn`~+MjvUN@<#^Yk?w~ug3E4ao` z7gntig4;s)8*TFjOH-YRG4iIlGejeq{LMjJZ=-B1;-I7tfSqQ*tou^XqFatxo5w%g zKUlbVU6wG`4-tiQ?%aDciSQpZNpKS|0S@k5TPq6P!^JMswzpV{_CZ$OG>Bw@`H>M^ zt8n8waS%)Ef|6l*z-<1Krq8VXN>n0fP2yjK0EVyta(ECH2pF3Jv6Q5&TFh6#m4s9w zLU%BBMs~&ogn+j}h;ZTLt($;`Y%Gt1%6gEV`y}I6G$ZD{&+*j-4FE>ypdkRH_rd8_LQV^+bYI4I^glbDGn}J?~@y z&Z1RKAQ9R*ysr!}Os}VUFS0qRp^Ak(K`d^TB?4fp5CIQbH$;FdQF|(zXQ5PP4Z!A! z#K=yY+TPLh+uBEyl2#R9!~u9^fMEcn=jq-{%sUriGr@V5Bo`_c0kXhhE^Tv&OB`BR zMH(We7YZyKPqJVnRs*n8Hmp+zh@?B<`q>7WoTHqZnl-AYsjFf5U5hDQcCJvR>lAUel2vk?Vb zRj9tuADIAi(*RC5+LQ4Lz%T&}ktzU5WQC5F0d8k00Y*0H!UL5g5+;BlNCD8a7GUq6 z0Io?Qr%ij_Ny8kw+Uf&@6>@;>I~*Y3HF048YYtG9F~d|yr_=ya8wY3?Zu}_$2zZZP zNMk4m_YF4#h!Kgyw2J^LU3h+=A5(Q@fZg2snh)hLnGon~TaH-TV1+V(h6+HQjrjq5 z=ig_(`CSGOr4QAH{>#0vz>4dd0S;%i* z2Z)o@_h5e?EKnZ%8c%28;q7cYn`)j&_yMLaUSLCRFPoU0CTPJO3viC0LAVAFEe#1! z;T=H?1T;ncXH=h16*tt|UP(7kBpm1r#Xt|iy6tp9bn=;6c<9`=EL&=YalCiN&s@Gq z=AE7`kA>4&N+JVT8zbVMqXN*z;jNw0x7AGP-!N;RrbO~E+|@V^;`MazMI;e!d2agT zMw}CDc-+ZGCp=`8Q_MH(M|><><`!zIBJ>5Y;4$MKANAAC#>j&_(=)I}9{)rZ9sn>A z{{YZ#6abMt_=Jn>rV?(^&30*naY?5Z2ZbA33E(9T5FLa0!}@qEbdx1Iy_0O5IyXiz zM_ul%7l-8mIDEJO3G1uGznDrHGk{p9a9<9vvR()UwBM==f|+7DZ`Mw*08ibG@mc^B zSy=AE+gXk4z-s_#1U!ZNRsmwkvscm`S6SMjeFhuwF|h)mfg}L##yU_5(4=%QSZUNAqqMvY_eZJ#!*VOM0N{n) zJCwWDj}eBd^#LFjA2?|df~MZ%Jz8K%_lR>bNhctR`9ZXm0nYDYfL6V#^~LEKOP{d_ zwdoRHo=gNlA!^&z7C68G0-kE}a1)zHTx70dg-}=9t_Bzy=p%r-GCW9FAAabk!6I{I zEbPhHYOSzxuY>?jT{ypMU3l)wWro`uYOxPr{b=cnHk6U4l5_w85dgK!efktxU}#qX z4AD5)PZ0fdyCP=M$uh5j;Y&wgqG{#vA$`@0;=u#dg;j`{^75WN!$!Q5)se^!p3)cA zH;p0RdqROt8*`#p*nD!2H-sOzg?$UZtKyrZQJ#6~o1^Toi%tH{X6A4a_593Tg z+_u9x^b7s-5v&Q{6pfF)9G;)r;lgEreJnyo0(faVTvxxbue;)LwM+Xq^OC-ZiH0)3 z^J^v(&>RaeH}0Cqcw`Xc&RUXdVNSWyRJM!IV+l`V!<{4UPs z{?JZm+e-3|zlqoAd_?SU$E>0mjH}=faWV(CyoH%~m|l_x3(T_d;CZL<;bB3_!q3 zWEK#DCazo=_}i`h0mgUVeUj>{V+8LZ7By~nfb?Ml;6sDq8VrdC zSrGtQosz=7I0lY|W8&C22hN3a?#_Qk@Y-viyL#=~-wivRhg@FYS?{!ecG4fbQ_YaI zP^-XdVPPAzVIS;^W8hdgCXTK7v^@?UJowoQeSKfNboJ_&KfF0~;18$IzSG;+KRPnu z$x(6s02-y&y;u5%{`b_Gx3LYj#Xi_~tNZ`|>-eMpHS{%^00000NkvXXu0mjfjqHdU literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_storage_full.png b/app/src/main/res/drawable-xhdpi/ic_storage_full.png new file mode 100644 index 0000000000000000000000000000000000000000..f7b29c6e99e705c2087e8d6c74869c5e9170a98b GIT binary patch literal 9720 zcmV005u}1^@s6i_d2*001SwNklHEHt$!UK3eBbW3UXwSSXWsYi4n3jYs&7qC zpYL>k=J{RkJ7a2Y7j4&F_mO-3{!eb}^8Ux0mao~KyXl6dYaHfP8~q)xZ=dfxe6Z6I z==Zm0$Go`Ht~z^IhGqcpV#_Z)<&u9(y021J8x$#B-aP zTXU;ye|@jt@yWN{wlBYG|Hk4SKF7)-mu2U%j(G#UZfktRV?CSj*+krD6)~?>L_HP} zp@b=+N~Vy?YhmF&tVRDmh)5B3fFh<(LAW8d*J zn3~%x+HSn@nvL!A=In6U9`AFS`^P<2k*a*aQ7?m{0fK$RzNRSH_dd6!e}|{-@r~`) zIi}Cwc#WyKHRkr5)ApI|PRsIRE_2Vg+k8HSCXYT$3>2o2h6Kk~$hd;>JT=!n+ugS1 z_*qTOtpT<#e(^)=IxMZ-F6;VHw>g{i5jym_08Wk`fP}YBG1QL)#$=~mjC!rvZjWvK zI=7`2?}4egUD?gyaD4nv4)da3m-U?heK5)LC>78y7vsVR>mN5YxB6~YtM#LsoYp(3nH>bU1SO<`#v){Z)jhQVi2)QPK@g)9YMux2 z-rzklHMiPspK~}qys5){E4|6br0EQ%+A&S9CU7C2-Dr%UoN+e+Bj{MCohqWO4;Arq za~vNwH879|hT zI7Foy62y0XZJVC3wY(g;M=2%oEl zgI-${pTYZ2-rTt#*y(6_IOw&WVW(D%!{flonIXCkCVFAA7_~sG0#iMA81&iC>~yw1 z{I7GDeBgayZ-ry-C-&1iCJq#cXsLQUJigkg!Bq(ZjfrNUJVw0`S%i_w+~IzI+xis_ z$0x38d=ItU@R>f3^P+L9*?ei^>T{vEiS#$fRd?&h!vD!uPyOAf5%N%1-^~GjRR>qYR97s1Dh%`K(`1l&=74X8H_AMt{Q4Wi1SuPe6|8UyIGCz55Bez!dHrW zG~i>Z9s^Gcx@y>}2e1}$VPNtgHA2);4gGc&A`X5X_1R0W`P&_{65j@YyPd(uG`URG z>r_$|9*?dHw5q8f^Hd3klLe_2qMmA~8Q})M(?09^d?VEC>cPiXJ>&3ra7+~gHtk_R zG8h?%Of}Sx5Y4gIo`2cvoI5M<{ld|D{jl4TNNB^yR6VA-Rl(DQPCK$&5wDh11Ic6L zA!@9K+7Tuy1Cw7kY}Yq5zDH>eY0%j^fzht^{+{lt$HU{%RfASNi@e&RM#*C2A+ptw zM~KV-VG>Js9_z%TjXF>GG_7#-xGde5o#*56>8pB5Q_H|pp<}Rl`7H8rVL+-dauAt5 zBHJYEMu>UBUZ1`D=|)>IxwdQ02eG`CtQS7Mx#i*U==1|y?7v)ClxmE6AZluobvMUA zxZm5p{@OWRA8Z(a+uB#3Tvb>F^x9<4(CRZ;!9pG-( zo^Pt6#;C50Du~*uA=58p5bEg<;{1{$9^2cnQFnk_+Re-2wZn&Kz^A9`@$h(Tz@t6N zV{eheVAKcEI6@;;Q2CP}TRN=E>WXib!}9NRgi9t0WE%Q?^}(kHUe!v+W4rSf?NJ^t z17t8VO|t=nd~zLy;4mLN?y zhxIqTDtri!kMHmCRZk61jSdhLY*D%&FvXVLE#g1^kw~t5Qlwt^l}P_#gUIaIDzXRn zi(Jo9kslfo`O#64pO_H&;FQQu2I%`SksBBk*>?|%?7lrBv+WI$-mq3Af4y2Hp8AQ1 z{b-qpe0y>E^=^~)8Q6f4gQy)LUkRB($;<(UDM6Z`e#v2Psqw($#%qqcEeDfc4NWgU z=wL>>3_ewps}CNo$77|ccK2ctU-6(wt@)+M?A%7U21Owj6NOw(6sJ#$(wTFjc=~KP zr_Pjf^7KVHqvRCsOOK()mCpWI6p`c8qL9vr{8U(E4;>PzjjxErFP;$5<=?@+$v=m( ze`HL`+U9IdM^@PbpAO1Lk?@av_ltxuZu#YVGeu?2#X! zBI9SPGN-6&lC>i=J}9aF=RfGauRAS^Yl83F^tXq5-Ik#^kQr}!jp5__dwkVHlXurb zk$B?AQk5%2B0vUo_*w>5I$jB|DKUyrol}+k1;{h!MIm1jxnsvfk}7fZ{=4XB1jJ6J zNv;_}rYYtDVnp2Qu@1qG@o5)l>k?+##c0zDe24*j>LynWkNS1rx|OQk)AZr?h+?rs z=WwguV8%= zvJi`B{w#9C!y^9EhvjO>A*?=6$T!7?t6+@o3qyMU7srQsT;@Xw86aEzG&a3_zfV2Y zLf1v;zL5oP`W^@+bd@=~1qd$VI;pQ0``&j%?npNV6J=no_H#J666^Unl zMkB=+X)bPy$R2q|9&}kYBn?$ReN8X$A-E0K#U8jvq+a?B_21qVg+xq( zQ#v(G9{_#e(*)u~3H>=ri7p>6XZi%1TU?gGU400r%kzxMmtG)j=o6}@XxRQB-xM3K zf;gM*pxd@V6Tasi=1&j1%z3Q&YN&q3nqK8ik#3Lu;JYHT{S8q_#zkowA6x}fAzx1M z;uNao@(8B^m2zbUCIALFG9bg1uuv$8_+t+P8-tK(ikSh4o+^l7jd;Xk%dc{`{oBkB zHg#H-Cw=v=e(E(|`ksE9Q@>vWc&KCm1aPX<0wIuP-`OV;tDlx8qKo-F`ip>AdxSuR z6_k7tuSKu<46TH81ClX>7?||+iO7j=BuFbz915!;4C`WVgc@S*`7%m8GLj~(Nz5~%8f3)iy(wmmG4R* zl%W--f+F?uZ)nA2p)}=_c>1TbYEqfJo<2EqgeS|(dYJf5JoP9&mzxfBSR_*a_d8LD zL;(hC!g7VI4MOxOOZ3Z>&5J@TA#wu))Q8?GlD~akI+`bX*R6nv_ZsiHt}4jS3s!H2 zQ&a`t^4OkX{&@Y|f9!L$4#pXP8dp8|>PPp9KlKxgXc>IMe;Y#(VQZx zh)*O|Jw?+!1E`jlg@|Sw!F?0YK3N`}F1bY{UwB^RgF!UKGCVmoMtB-gj>I{0zMSF- zkq<>^?Ry99*V7_$&mH&-fKf*k)Y%OC&wXk*WYUw$Gb`lgvX`vieb_!F>`x ze+<(m0QTM@L{5~aaq=TWBDwmR%7Fm$>3F{X75VW|AiDq}F5@~J7nuCjv&#LSUrBS5 zql5t{RPbtqkdKTK7y+{ojf?b~Z-^NBqvh_8j8MzGpsr^4kFI%hsvmgZvaUe$TdS!T ze&nmn`QaeVVmbjd4S-PTA0oMdW6}h8gqkf>G>p>o!9WGpX^{_1isXyGs#Hv`NUVGk zRS@V9W{Rd>2>JD8RL1Oq{UWyF!OG|3R3qe9M>I9VFm`Eu*IoB_{Z8|KX6a4q;DaCe zc6H!;bk3<-4AUE51g^$GSfWs~jH;MBdRWAt_#Z%&_BXx$WszR@5<30Tb@3;Ej0tlf z0n7{FH5fvrGFBj_-`FG~cP~bFh^vCSo8bgq-|sT-hc%VIl|J962dYdy*Qohb@Zo#9 z4ePdX>ZE73Z=s4ZA&R-Q46DHqA|+Hj1pA9>M?X^sB2~rAu5HRu(#oKuQ4sPF&z`65 z#iWQm{D270cjy?5@Bnd8^MKo$hcy+zKiR(Fiu28{vB3vQJneLpI>D)ze~XHTQ7@)m zRHNU8TGD-%3G{mn03hgA-YE(@Um&@s(z10V#vX@Zx{&$lNN|if~;BvV-ZhB3`mVOKOl~z2mZ||koE&?Jz%^HO07v_3sJwb{ z-#6*dr&mNF9wTh3gBFm=%Eu|XPh6xouEih)kEQ19A^OF8hwdXmoi%;J(&@7_HTE+R z_P42;VWa)PUbi*zfW!Yulf3QiFn=ZJAz-y`erad%TaLjcfZ(~XB7&6>d4$~X2vG$yyLO=K1b|3Q z`hg)zkZyxHlf13Bwk$~+@BgWrU%D;+>{FtoOfWYdLfSXL%Juis`MKq}zUW;GMCwJX zUQA*_8n=;gbj%heL*beNv)W%exUm37;1*s+gp?q zmUj8uSJ$%tCztCf+PU=Joif12Ls%+Elg!E0Kd03TKb=P+uU-tJVgn~LI%W`Fuu3u_ zlD}Mu6%wqJNUxI{9s<zBoV&&r^KiCI!GCVnk5y}ve++aUd+Q(@sicXe#b)5{b;Sd5~y0=#a z5UB;gVYlTi*fU)_XU<2DIp+<=H2~!1|AJD=0MmUvDu9ht2~h;ME)z}A`eRHjZg;Guq!4d8U<%c(;|5I5aE*m)^s3(Q+@k9wiN7{b}w*zVccyw z7j_v3I7JE2<-lK5z>$6XM3z3}Qjx*YI0KXVBUI9m2y?VQQ;C!a9O{+5c+3DONAn06_=2661~|BPkLVkl6oILbDCD!E z)I`{@2s8PTn2N?lfC@%{0cdz2Lf5al>4v4IHErfqakqYeQz= zqhdT56q!t#n&W&EVS^wmw1io;z?f^09UE{E>GHvuZUXLpHl&}B^ zA0=1~;LXkp0QQfJQO3m(U5>_MBA?3wViVzef)MadN$?Vxya+^MVj>g~lL!N_mP>LQ ze2z_~?VXMz5j8+m!OH@a@cHd3fEWc&RRK6KIxeN3GCEm?n9F7W0T`PI>xdBG5M0g{ zN+Om_6TGMxp9&K`L^nW0Gr$OC`+VmS(;*6 z63K+fW9%Z~;K1CIG{f?oMaG z)bF)rLsbAO3&<6ONN zzK#V$VjNKb0$&w?uDSpWQ3m|&S<{%?Iz1DB$du12f*Jr$%@800fXE=eB7|{-f;ViO zPzLBtnuj;vXbec}lz0u2xOC!rle|RA&lw_MK?=~w&}3}*g+}D-WPECXNUZ_# zN5zc!Y$r`q&UpaG0-T}*z4ZquS3)^>BavZbLQbHWi-Y&6N@@fUsTn{7#!M5g*0W3n zq{|i&MCdXQUSWXE7zzL)4GM73W6M_uSb^6B*aTRwCitkoEmmz59Hay&Du7-an&KwF zMhxEsH`XBJpx-fmDS$yrpc+60p$>pZ6JVoNz{&Sw8m7w`powTFCZg5&GytSD0X6~Z znut~{#RX|p96)4*96-OF($;K(ugWI48-KW{u1j(9!3YXI9RL-CZ8AWl32@c`M5+R0 z{)oB3gArDJcGC~F5o+iMn2q4fIJR({-B!AD%uK$!yO6qZ$Q<#d; z3=mNOA_~CysDh3rz*!40DJI`J2!OzMAwcC15a>QB>6piseyFSKQ_^XfJ?%FQMggr3 z00;Ior(tGe9}oaX-`)p+3O)rO;32vI;uUF6GOXq%K#O83P6CK z*$12jO>ltl4bkV)J3LZe3F+!k0R%n;Aj1AHVdjq$b+mkC(nZLCu9p2kG{HM}iap(j zaaLRt;QzOGwy{lKR~*0FzLd4<3evVOd|(wH3e~z#`!J1d(KM~1iC;ou$99O+4;yS! zH3_MjVC^IXq8l30Iv6Q5Ox3#4mMkQUyuXvgvE#S+HMaB8G$C(x0<4`P?E{Es=kMgI zjviZ&?Kp{__#SlRmzc-TJp&n<8O5qiTEsXYE5LNEsq@F@UzEFFNEm1ldi z#_%1#Q4`-}PgtG@(qq(Wm7IZ)G-P*3W8+hRO#oP603z(-F%XVOZl6E#x7pb8+As{D zOPBv814s-&Ie=Les6@Hcu%UEBp(B!Y9*D=pFbsiYcaKWjy=*X;{Py#qti zh0>Etta2}oy08+^ojjn{u0mCESwB zV;+dt$pg^)I%7>Q!h7lF5! z3P6CT7=Gmd%E99rr_Z(%YbiIX8KaGA=FPG^FvsygIe_qjfDoR~Hx?!k9a7(*75O0& zUwj4tlF{xLJv5v3bWpqp;6l`+b$R{Lu+v4h9!Z4TF?w%`zyow?2BOyitjs3-LQ})X zH>$DljcQVE)upk=EV}%S2g(8Dz2LR*OB#$$Bn&cW8zHYaM2~j*WqJT4{cW6wXPGyg zELztRF9Dd*f!?uKN9b{vFIFk7M)LQ35=}rg$1aQgTPYFP|_akPK z!|#|$X9sI(HY?P=69-uN>J1~|92!)-7tBL1a*|OB4W21tur$p+p~81{f&U?12CHj{RA3@21U6>`H|0R(VL zy!xrAR?!TS{|>oQ=%mi-D+ zZ_xZSDGYPXB@E+H0H}TdbLo7@!*8|z3D{yv^7ERSXKAjMpNHWMiUTQzVFBQdYW_p; zraK=o@_s>+)(^H=Cem4@dn*p03qn0zeerbEK|8&p?PV%O8fZ& zAWP*1p~_wmuLXdr2k_XYydQR8oiOV@2U9E?ahPtQwRoZ%H9u}+WS%X zb(qQ$()M*H?r}t9<2vzigP@NPR6acCmz?{9`94RsJ6fCi9#b7Y(@tL&lSb8tW zp-b-tEdoH*hv1rWnfJ>Sz&Lq7zgg!7ODq>@t|`RX%2!-pH=9EE+%q6%}JIod6RCTcuiVo98f6(2o(UT-2=v!u`nF~ zW(6O{{k#^v6U?xDO1(i_`WaQxLPhtE5df+TK9328cl>vy-98pXPrX>>d)%uLR-va`5#H?!oD{L#| zxrTk%Sh4vM; zmC{~Wc4jHl4haDm?Ca&FIYcj51*JJqQQzYaNK^EB*5!l~$#~eMvr>D8ZMD=;a_KSY zY|9yp4dO9MZrl+FVX+K_VNsf+Ah&6N_apcs`c1Ie1(VYLVyJoGw(uLdcbu=8yv@54{AR+fv>O7T8Y6rK3j=M@-s9 zew$9NWdz`WY#5d*|J1I?Oy%7V{^Qj=L;sB;D%>fNXC$Wk@vBJNfU>q1; zFU=7Mp)?2I&Oa%X%oY6_;Eg)>WgVFHR0ptO0l&lJ1#Ai14zAaP2}Z{8S>E}Oj|0j9 zl)<-PSzG1SWUer>LXe(H&4rZtU{xsq%&auW`e3y;xMnz%p6IvovK)34)gg6AR)>>{ z?6}vfJ9&y$ZDa%P&0rS*Hej>EUMSN6`@xQ=pa8oflJNXb)(ch!P@ea78Oz>bg(3%D zfBhM|rTq4CwO#?hEJ|~b;yFH#JP{!qWhoG<(V21i{P3K`stBjZ<6sX!hN48U6YM3c zC;{M-o@WPORhcaBvzyBsam`sF$z{XQZ~9GI7eS~1AXJp**dkT#1?LVR;6r&`H?B1+ zM7db{vqRx3%`|4sBmpR9!>DvR76*{ea-k0AG_El#WVve49EqB>aaznI0Nf=2qDaBG zMIXntWonR5swIxFH)&Qs72CC{7QjW1 zo2nXUS82GVf~isN8udos(9r6{?3@5lWdJU$Jd!3no>g2!re?X-)Ko!(%3n~U1%N7< zkh-|?KpLN#{%=cHmx1jD`QXEwuZ;$R@lWR#1b_t&;L?MK*tllpRzrh^?I!ul)vHHn z&~%D!dJ6yxGz7;UJi_)3)7Ng?_%Yj!a{m1JLv%mVL2e%RfdzmCv{&2`!50WeT<89H z?q#-{+&l0CyO`8Jc`LA77Si4%eLv@4owORt$3Bz=3DlI=U{< zesPa!?=k`44gq+7DGmr9clY-HVgLU9dswka{hd2i)I(mRU!mA5ZkuOBFD^g8K5>6U5ltJSwXwI+)5AqUDB6uZXS4}zLmSan>xk<%+D&>^lFr`#KaU1OV|3wg0oQV+ zxq=VVI7gf-hfYEp&=#}_ZDT^zBM0~Gd%mf;xum77! zgq>c0JP;Xw3{d#^8oxhHFv-eb$cjIr)*k&o4jhh!W4e5S2)+Z~h3~|7;~a1}B6Lb^7#+?L9r;Z*FfdfA4zT=^G#X{r&oe#ig|b6dgV~MoKzYOko33 z(V0;sGZ$T>Lf1vX{er))ZTgJ6)1BNzona=E!{(wAZ}V0HQ~vb%X0(FMDrQ-Ro74`m zm+4|>rDHskP1<;L7Dw#crk{Ar)~baxb~E11%m9D zJW#t0&C@q8Pe|EaTPV_s_F<~A%;{pWP0(i1;yF-NG^XKhUXTbHQBMS;&9x+l}oDnRJ;Zfae5Ycz}F6IeO9fq$xYJOf@Ety^<8laE= zawZwscL|E}5W$kVliDRGF}aBz_lMy9jlf&51~-eUH-ozYk9c4qD)j`<;`M?fGvN1K zU7Kkzj_+Ti-gP=p%`Au8snF-XcCu5Y}?YmjuD79Y{kG7YikI zM|Ms=3bdkyTa;N=3Og%%<*!2Izn!PrO(1On@<1fcK6OOQh0C;Rtp>6^lb}Be9&nHf zm1%QarkrEd@a9ps&wIe5fsWJ9nD9VGAbfMLWEsb)l`SU~T_YYR1xt!UaNHFVB6~{I z>B{hfj;YfUV`u;YN%#r5C;Xjd&zTdSaBIo8_!gQpz0>F6hvgKIFChkRA9f!Gy}D^J z1s=7j|GieG&*-L>FqgfpktY$`S0SWv!3S0+GU(*EX10v~f5{1DU>l4hH8bzwGt1f^ z^`ID2aGlh^sy;gXoYJiP1>>t<$s6qJhMo#ngT+zzO)vBo$rZPWhpBel@vbu7b=>~i z1__9YlHhLd#<}{hf%@uUE8occADv&J-=##nS-DQ@fSo< z^ZH09|JIJI;*^ySak9cE;QdG_A95KE4UVscDaP-RfUD)AsqGH_R`+B66%&{Af{(&L z9W60Z7c5E`KH~^qQ7?T-fuEUW2|XVk-xz;IvU!RyX-b>TCAVd~rRgZ|&a;{Z8!P^s zvH+0~MceU25nKeUG)ZE9wv~lFPydMaE}Jp=+VDf~Ic)c5D!GbI`SNEwRq{KrpPHo!@s#Zez!_vll9M3EqpJS^tPVg zaSW1AE2it<*N%=^@hBUUXeGe^!K$}*x_6l9IuZH0|83NcxAn>JtsJ_k$j0K%#Lf#5 znUPAzVxxga<0J|-P8Pp_>@UheAWbB0V&jUQLNolEXyoztwRor+ zkDQKLje)ih%>0;K#fsR42AGUvoED(%0j);qW;s+Q|y@bQzB)#WtcOdOTXxB0twx8VR zshuFdl{kdS#<@67)RbB^eR$VtNlLf-$$02)AOlQuY{r_avD)tKpj-FlP%X}LKQXWQ zE{Y$jz;t2|VB9t%x@YFj!EUBlSsiq{?qJ0wKX%&#QI%?$i~nO{DnD!Uk4??kl6rqO zVNbEbz%quIoKwAcI@m7TBoPZ>xLBs=;>UD)%4py z7*5x-F!>-uR=4bvND=e)Vb{pl&5HTx_3;K{#K<}*pm{MZGjG@Pp-}h6Xil>Ve=K=_ z$(XFPUQlZ<%CtnRly&>?9eYiY{iB$T4*XH)#%@^&m%-x@m4CmA#!goXL%3#fkMF*?Po=6XL3RXS53XmrZOX0AQ+? zn_8TdE(l{fv>3f>c>Y%!ze(KZq-O2CxA!rIP%UJYmStSD=~;t@c~b=f|6XPi((dd& zWf_x*ZVr%Goa$=PniMWJo#%y}s@gC*boyE3VTHbGoc+fk*bQg>`}UX@zt9(KV-HGB-0J%=iFWF0I}Jb6D_r>FYd zhwDJaBDJ5nYFFY9?;lnUtGe0I-Z7bQ8a91n+$Za5-q>iOVyE9r{mbYkD26{N>##Wm z;Qak7OY{t!B5w6GqNVk%cMC%(Dea9??wJx1s`d8=7f%F*8B(Ht&fDO3qt%_IERt^F>w?NuOEx z^e;ncCP~i^5FBI$d{Oe2ZG2=7*Do(DW75)%0XhqV;L0`3wFkbZ4&G6~0O{vR>Q?9n zX+TM$#!UOt%%Aa6dM32vUZ^){D(QKxo>poayEABm%XGbCvFUi^>;>B75)W=FcpBT> z@!l&X##Imu@D#gb;v8PnW0T+O3?&rxf;uA_C8DFTvFL%pfg~LI=HjfX=vr1KlFYUO z^JbHR(~qCufRb}p2+Kpa{ysexcPXJMu3pd~ZA?GhuJ1EQsu{uQnboe8$k1mqv@7A! z$Tz#(0us(qO|T7Piwmgpr#IfmUhTTVm9pUx)b9FIf6AsWqy;9pRp~H8wZV&`qh;z= z0NPI*kc9){-5P_1@8Oa|z$Oauu*}Ofw($;L}eEOZ8BDptG!UmV~A$Hy0eIGeyNSR8mVk# zlA^7_`#JO)EP|3n!fNEtkcdO-*pCK@@OI{60Ye3=soU>fm@D6{Uppa7nbR3HATbh+ zjm^xcrkhm6loF zFsO5Xen7TTSHV#9is@G->X)&(-yk%6U5xwrn){<~`j=rfQxe<<9rNrix@RRuvwfXV zXURfRqodH!Ny~F0^>(K;`=Y9uQqdCzNgOuNYD3WChJJ0Tx49G?$Xu?RC`?5+gJN-R%6$18;@RJjOY5o#--<~_aL-wv7?~FoVMVn2h zaJ;)2h5nx1IvR2=N`j5c=<1nxy`b%fwnsTAR2S;Gu2Os7?zunk1{FK1Z;(~y8aoRfHoq|bK}=eNzyL~7n_ht#j0=IK1}+@6*tZ+H=Qp!^DsT@ zFg!aqZ`Jw^Ps*oASbB5Vx@F^G()da`2ihI?w3e!=9H50a$MI1+X} zbJ3DC=_-|d(!6vmA=8}qry&EF4Ax&nXG#3XC{sM>$=C+jGdFQ@;`;5amLkWU9_Yu{MOtQtXw0@Bz2qgQd(a{NCuArwG z8B+c(*@Yl#{)^0{^2>#0T#S?Y;Q(fc&s6bW30$)kf(4UB4Yqyb5L-=Tn8Rrp-xo~A z?t5^Y#^UO!#0+9Rgx$4!d>^pn<8lLQ4{3(Wn}Ujqj?GJ+jMwlt<#ja%ng{ zt)U4xJ-qUn$l+D9YTWv@e=WXwfJp+BksaY3wraKx93CWkPO3b6M?ZvoEWkH79~%Aq zu2}!W)qBRRMkgw1nVFemo#W#=FAi1}DfT>?MW$nE3@bmsA>2-qKNCH+x*e=*#5KgZ zOzz=O1Xmdxwz0W5gmf}C)J}Ut`iPR?;z)JoSFW_3wi2(w>G^V2qyw44CY{`VDzwH9 zg*d-{qp?7saUvWI2pIV5>)-v>JpZw30Xhkjsn|`&<=nyk z(l)A}cOPBjW^o03je%`5HB{r9F02ecvi@ZblZqGL`OU3#$A!wQeOH*V$AuTV=K&d6ldXmfFk?h43L1U;7*pj>Inu7ihW3QRZv@1b$q zJbHv5NwX%fBkCNi9{wVOQZ~6l7%xd)7(Q1_Dz!Zf2(B7fhio4$C}Kn?KFd}Wan-(o z2W)c?+r}g?Vhj@MvwWMgv#w}U%{b91yf>l)Qu@-foMTdY4vqqW6WT^b023}z z1$O!K)njqRHFny+EN0zrSp}mIe7!7jvBV{jKTo#n@R&(DiS$2*mr|aya4wif6tYZX zVQ3b5a+8QV#jd^L6TAO-Oo z4iyLIjdz}!5QYv$H=jp#_w>COvYAyFnYmb;3%TsmE8L}N{k&sR23Bjj%dE2E`pk}6 z{O;mtv>#w%W9}H!rE?})O4MLvRZe;QAVxoo2jI^14#9GG51Ec)()9?{Y`&)Gs=Nl9 z?_}L=T>s_>O7{iZ?)L@PO z=^xp#Va53TB%1bmJsHtXXk`S-jDXJTv(Trn-d z?e4zZZOYX+(JL9{=Mt&E*N^;9Elh)~=j+ z%}%wAc1&Q*gY7?)a4=hxU2Z*kHdMH_&i*_S>u(KpCC7A%zGW13Ul4R+?>~Oz9h?|z zNG-W4Pc5{mjxILxd*1$yVO-eRHTvGQij=N; zmZyW$7n5e-U zB@HJIi~zSVimy;VgB>sBMSLH1OFJ2GfX>V>aae{w@(o%SI5?ze=BbFeu2iTqJU_{;z!?Q%LPz7LOYqlEFkr5=OX%i(HI=;Lq4+9_<8Po8XU zYf`wzdN?z;`(?GM?-P@j7-R}3(kKCMiY)sI7Nokg`}HWSyX4xj*o`Qp^e+inDl{Fl zKuxj&N_b$xzr@Xr6_)b1<@k3vS)PJUPS4`53XkII2c=?D6NAWpwE}Mk!A_LsqZ{!v z0N?QX8~n;oJ#lRijOFbOKHYRdnN>D_RV;hsso&Rjc zJ`=v%DULWZ#%V{|MeXv%R7LUu-1i@elvnU{ieBKz>RTa=u*8hsaKAVXs1< zuVlMt-~dHhQYAjPh=(QS1eFec}#?^J0GJt(GD*j({B96Wv9mZMfQkhi~FdI zT*g7Men49};{Kz;D{S2sJmb#@lMN(IcPZFlhLVJDLceJ~kE&mindIHMNM6!tZqG7X zZ#4Ca1j>rG2hxjfLjaAL;$(Elx?U0QEpwcdTmHF<pq@C1IxzB1=q$>*7Z z6tH#3i8!|bs7|V{4@upoHLARSeM08(nalQJFBPnExvy^!Xr93hN3I>q5_;en^Vw#D zN+{A(Hvb6Ss{px=|M@r_4G4ACcRA&5k`ntJuuVbp)$kWF+ctFjf|sb8>(4Xd_itkH zvdFx!jY)SMlGRAG+(s^qXx-e>T)(NBA|Xd!U(c@`!^gP9CvdQf^Xh2a*9#sANIXCN zS<(}IxmB!hh%|H#k~5a&Eiij{jK=E*!<;^h52q{ydW5I>N@@#!D>`*DliK424y(jb z>k?=n=e;opVE-%slxe=y61>#~?v1iJg}yhg)spjJ-A8mz-_^|l$G}$ba0~nCr`S5z z6(W+)s?=3#yE4!eng5zB!>pwZD?qLXM?6gu$Mz@7uFx5TJZ^Vl-;dtbZG$Z?L9|9h zsAlC3a^uhk;#6uReZ0+K9AV0`*U;>%gYiI4a23+RYMr8s`6?*PagY<5L$~8~dtdE; zKJleF^Y84odjIJiTbBrAZ%F3@)q3@`_q z@11!Th51KW-zO4?_-tM_aKryEP^S9@B6v*cuFW0>#iWIDs>(=L;Y4< zQ;Vtlct(l@L?(Vx2_;lhW$o&3*{{ndTf5=Wzs$ zghY+pxDYe4KnEGM6x( z)LBeI4ABv+hcH_CCYS3?KjylpDTvzxz&FESkrCCdzg2o|zpO2$D>LBrI#cUPN^l==-a)-pD9)1l-@z9(}`aMMj8UD}V$} zZ=pp{ukaxyRAb}^R<=>zVZjQThF|kNEc==Icjghd7~A>*csv?Bv@B)*__QD#kur!+`)LF~$sCvWB~yq2?~AIRgD{QpVv8tjS2!Gu zm+puc5$su;z$!Ak+v#Y%cSJWF=QIMUaN_3Miu2JnkJv>&sB~{B;H3!OlxU(h083pc z(!g--vYui;Wl#;+VHfd^bP|;{3yUdmLrrXpUinTYUZ>7JWYe4*Q{MPECwWVxh7g(- zQfeMf^?2#pPh~*S6#&oN{^V#{wmitz!ZTM%8gd!M$)6_6uNyyJP{wa^R^D0XFYVE*L zUt^K9g}O|dBn6AhYtBmIucJQCR?T4nW`bl-82D>n%Y=@t@fKHYM)h79S+t1z{HpD# z9tP=Yo>y;e0qzNesvCJn*K&e^sa9pTq=K#yZW%+pr_x;~5Ma^fFmOxCQsy@AKUT>b zn%143yN|z&=H;CAE6y>`C|26}XH4jOExb*YVtaOYFO4i}pM(PS`>O%DuB?0eAKDRRjdK{l^g{lkyCMy`+?^HQmwZPmw$EEbg{(U>U#mgxY?X4ce8@6okfr`E7pCQZO)rL?`vB?4ALXfe>;O&W2H4- zMQxUW19s=#Ys1S=i8^$6vSVxeGQc_9md=pLs{L$cK42j@qzbc8y4^Ov%=wyFMOQ~_ z7=QTX=@^IAx?|?8!S`xu3T8Zwb65Y*rn(Eh40eFaG^AnqojhSY`@HU?N=Obu0f#{K zrMO>q>!n?Omjz)HFP7xN{ht^ln_-1PTBK}S*&rQocWqZItwffV?}B50;lBQfk&YJn zjN17SEFVGmPunen{5Ai|8q_5e;$ZX1#QKt(=Ym6O!I4_jUTrT z_pxTfjP%D_ARanJhvJwVhBdsG@APl$HE-5b|li#2i4o>C$_3EkM$;g$If z#SEX@w4?UMx@Y-&EUeXE8;;n~nEpT(mx${6L=c&;Wu|x~F&;Zujmw(ulw&3p8QWRi zn@l=z6o)+9a!NN;2(3^Rq4rqZ)aBH?UKOi{dZvOy?3_K|V?X@zRYM^OO7q|y^uO*g z=(m(T&o98_iE~1pOFb^wE=pJ=wwc)IbE%bx=D^n8W-`iL2VL`eyZ(4BpQ>wVTajx2 zj(_&rca1~7*Oq+Q85xEw?qgb|jNn$kT=8)ZoCoulT(yb`Rqc3uLI8%ua(d%gDc)LD z_EwSkf9&7Q1?=3WWeMyZ4Udw^Jd> zNn0R%rS+wk~aG$Y3&KP zh`RVD2ke0#TT8UpuE5nc%A0R8S0^~lr4XwO`^`!}vE!uJVRD+W_EZ*JXw=$VLa#Sj zW&&1xtMG#CEaGxuK)p)WdRmm$l`+@vYkYV}EMqDdy1vemLqEy&kPM{OY(`-mX%HN( zKlQ<{5CgeGKMv0DGzk+La^!d0FfWYVarPiYpY0jFBA|1OW2-DQ3?qq!5shLQ7+_dj z&e$35KHkk>xkvGi^X~7D#u;Rl9qYP3dR|pF(Dn?N1H0C!ao4c|Poqei`@m5%&7t~- zDTc85cU@H|^}X>J6A>@C2mcDT=$RLbgz1G{ZC>>hD+LeU@wp5=;3nrv2Dti~{sLq8 zmDOz-@8tNWB~tLubFGWkH~)`I*(T}@2L&>~fdHW3>EnpR6$51M_zR4mjU-H<8PPQ} zvfKXIJRa>+N_+;<7(XoIO(-}^;Jd1+BOI96jo*wQn5{Dz!g!G00d{tF&t+=bDt6Kh zJj3x9rGS6JM4-AIQusi6e!g5)p0mbqx}FvCV2OijMCiwJ=0=sFln05ue8$dI?MJd@ zwaNCkDq@3;l};WeozK*N0pG8~5w6Y&I(Y)6JTB?@K&e8}w0msBsT+KDW>ho;vPy}V+h0!+)A1j=k_1>cIz?|h5cA8SQhqB zRRlGxWi|V^rGSeVh*gLi8yK{0MyzcCG4e(W$BdxBR=mhcckgecl6~Jy^yQ~|>Az-! z%dqP0-!22re_e2&r&N+r!f;c-vtYo58kJQlw_2B#^()}3hmmC|!1e_$p&OPnfJte3 z%;z|#-dNh~6(ugt$wD|rY?&&3nX@Yy((@6-fvwlKc!r41(3Hsit((up zMPi{qa9mJ8sAM>EX0T%Y4aW7&vA`HCZ1mez)a2q(iiY=^APqE#6ge9Qs1X7S;Xr+bL8ewv}`ok zW);2?H4Ij!8CxT5T;tC$^@ZddHFZ790u&5dQjiinxVhbl9lla)5&1qgi1cTm7#dgy z9_Faz0SPp@@{log68w@mIcr&2fNRaFl~*7eA{~^c>amkd7Uw`RZB##c;4BYw7$hl3 zM;XlF*y=mI428_4;DLO)l=1&q^L7Rc{&>lGk_bvb1`FRO2ZB9m{uqYTLNYHH#ExNx(>e$KQTa88 z(xl}SRkzzN_?}8r+)t5mr|w+O8kOQDT7V$4x3qKzCBc&v*2GN$Ef?_{LQa@2U2$+aq5RJRSu5PxIQ2|1bUU zKOGT5S`}>H+P8AOw|XAuc?gIEC{ z77)(vh%(9++ZN#Dj#%Ere}4$XfsP_J$~7*m`+q=(b#7p1I0-OewlUr)Pc z`soluziab8GO>vE8StI5O4W#7n1>L^$IDnaK#<%J`IWyE zRC7xRUt0+5U@R)!NH1B-$=3xBR7cHiu+J9JHDXeuZW z+T4B|?@0u8`o1A?{y0Ql@t?-cD%yWEFX0ib^jt&(=44NVznUMb0l0j`4Ruwd^yX^> zZ+J;q;OOw6VSI5S+v=cT8qMXItYLGy$~PJ=T&9)*iJcG7FkN&ke<6Y|^wqJj!v&RY z+-0^=DeLM$IihS#HGou5g1V8IAwIVI&^hiRd0ze*9z0?Ubn|Q^CnnBaHwY2I_H&U= zN9=?6Xjl(`PjL_i5&oKsg|qHFhWQ)n5F^Ve9Q29>9acq%_QZ0S3fPyad-zr%kk$^=4;n({h}TK9IEC3fq`Xj6wi~^z*5=p z_t;4UNJ9$Z20ahGHn0OCKJw$0|4e4whJl3z8z%z}k)+m%P%1`i!I9jd$vjnK9`RyqHu^Ku!wof)4p7nge{3BT2;YPF{j&aXE~MDhGDAz z^rE^ktqrSFWS0G)opi8q5Yc7yvmuC;es2)KZ|3+a-BFN2g<%Umo!Q->UZ#qDb>0tv zH1|&=Gb_tI_Dhq9UQR|&v&QoF3)UEZMWsj#l(lYviMgZOJ6~l4T`yc7SvbIskYeu3 z?XPl&WB&cKLQn*#OodFaLCO8q3_v7g z0G~t9Q=U2Bi{);L3gc4D}=_yQ(kD7AAT9HyCtm8hJ!X$aPxyY8%Mqpskc_N9ns2YYI+~GphT5aZczn2ya zp+fwFyxKYv^w1_c>xhya=XEm<_9Bdd(@l}3FllRMpx$L;O_VFb3j6&v7=D9bUu+Jn zHAN2F*$kJ=?Jp)32DW)`Tv>C>H4#&$xU2OZ*yRQL)21bZ zOtlW8+7hP_`5Y*otwbhXn2hjpom8HOk^dt)@z`@p=uTR8uh97JH}g9ZB+OBtAUSlD zd~=$t>P%MJ^giu?$53ZVYpC1n$3r+9ibfJZ}tSDN*0Q?U};e5Xyk58zp$(zlAKe> zZg2pKvp2hFn>x(&2)?Hfg%I;Ccb`XhO+oKaZL<&(tHn8mDu_2^yT**i@>N~!OpS~H zSOUx^n#0uA=x+p+A)>?>y9LPap^DH7J@2egA-^XtqhSUi@Xz{HI9PZW$_+}<$`h&Y z%lXqMjr&llNr73qSgqlq&>3qdqj(&G*cIz^C#PUt=1O1Ao@#&+ptaUtOAK+Y{mlI@dm-OP#c@gj$4F7ghpFS13nPeNW~@ zRUE#q;QlUR1aaIJGma&@Joe|)?_Sv}Hnf}6a{LeQJBk(pg4zoh^Qbso(bT=Eahf*; zyx#?SLbGn~DkxtBsVYQ5d&3+6YYSJk&w=F`-zpvODF?h{AU&B0_tyWx@4Kcl?{h!g z4&wAM)531mf_VG zjP~?yLL^+Oxp*LVc=Hl|HSQ}j)u_Z8i?+v}pMZHA-91b&VfOH~d|P}=JrTFQ`8G>) zXrt3ecKbF(Fr9sCL4)7%sX3%viumMtZtd>Vn#a}qLS-BQfEjl=s)8nF*l`58B&Ee4 zuV^G4yNVmj%z!Az%^CSSZLn`zs7)m280+a>5lxk?0R?^N6ZPl)_&2}r<2wEYqE^mG zw~;A0w`&;+d|t|Y!6rRv(41*4sPEqhz_sxHWrt_~#}qFT8M#~e6M@u$kTY8g291y0 zv1>S%BUxtbSHF6IhaHkFi(V1wp31E@SG=3D+Dvby3ey_@gN>eH@zfI^8u<d&{SfRe&z?8j_4#2Bb%C+Uhx2)3I3CW!1Ygfl6FzzO_?j2;+j_!+pcQeSC=?n9J5 zJlS=3K(9(KGz1&NRkt4CT*|;v{Oes;7|H}_Iz=P5b11jDXfr>LEv+?_cUgLu2sOh9 za8CTnQ4_H9Yy45QRXW1l&~ntoIR1HJrd-G$Tm?_o)=xFOuKxo2tLB=^Ke!CZt>_=M z1Pc(?L;c1*KmV)$O~C&UArC#igMFV33rAS{FO98%VK*7=oK+Kx?cUay>jpP8UHX24b#j!`z7cO z-tx1U)N8+F|1Ei|RKzK%+}0Iez^l$eghjOkfV2V{Aj13~>RK$i6zpm)e_q@nBCSDy zVcX=`_SqyAZ=$Qak82!*HgAP#?zWq~sWX@$-yt9!2N{l@3Q&JWx(EB3Yz2WpB;Otj z{}-O^5PXGyg+puwx`ePm2Gf#ZybMesKlDI*ury+Zeue1&>5jBUEZ4%(ZJD`8x~7*$ zGy_mTxrutSo!DLzzEKA}&JP z+njVtRY|=ByxmwjCZJRY6`1|Ij%LdWaNaVO(soj~&2%gFVrJjlgzIcPlivGAU`fPN z1WmP*;dpaB+x_ZgIkeEE4h`c5K_BU0_?0`j4eh2H+CW$PtMo4l-f%|Hh-seNkODnF zu&({?>koO{F<{)L?i2n4ZUQg*1&^^(Zw5Zwki<{;AwUS2u};Qi4`a1k|3{EH9TFae zdo2iY2_!3Px7Fw*U0Xc>vE@h2BLP=w2pqTDypA&%R%$te=;zA=!6Yts{Wq%Bs}~oC z5gd^ork_J6yPqEPTL%WHgncIL~@Lp?x2yz zL57*!u7F>z#W57mNRlo6l!L(5rTGG6`RPr%lcIMV*f?d!{{GXioT3ESh(nXwc3<3C-ZTB+)|>zN=-&>{DmfB=N8N2T1P+AzmF2nqey%Zck>Weq z(IpdsaA=b>471tRlgYAP|Y-4l;~R7uZGZQAPCmc5ZE1 zQd(+iW=2@=uJ;Ak!#XP)<7A>`ojaO~_nS6a=_EQOTE*b_41p8bLEQ!S5l7)Z%|*a` zva70`sY6mzZ0IlV8TN^I+%>mpOmpAAxRKGp)4*50MBYNVK|=3i!ddOpoc~nT4RRk+ z5R3LFU9eRcOr~82$w=(PA&fgB#mwVgjwE-sdc92+bSD-;d&NR;QZgCO!L*4+xCa(6 zB5r+t1SH3KYs6i}u155a4J3`L{c*OY0`N^cL7AV)*yQ&Xh zm=tf+k3SzzTU3Z%6K23gJhWOLXeWfeqyQA?ZR?lx@Zw*5o}h;Co6}WuI&bH7w^p#( zkH;$Z9>m)9;r>SlyH2c2r*zgXFG#AQy?mboW!d8z5*mIICJqF+?Z#?@Ko3$-O=6|Y-o|2G;Fuy@rp)bGo)3-6m7+rJlN=Z+id>AQuC z@E*RJ_Iz%^&nU1o=6c-c`=b2xY6z`ix1?j~A6FsYIi>hJh^lLkV; zre*8aFXTuY#oo82V{|!yZc_*#>ch*4HRW;Jq_&K{nz+2l^+h3FMG9-aJu0An8^vw{ zy~bSyhcQYR{q34YnD5IkxVT%QE;aSF*T*8gS*2QiMM;G=mxB&#HH=*pakB~~vyU5X zEFRyFMrli(gJ&G+kRovlLkP+t5nt=whH`)p{mA&Pt}$hk);=3%L0%!LZdF(MIorc2 zNLyxcWE!?>rzmk(S+}4 z-`Im-LqgREP%wZ*z_4NqO_CcgBVnx0q>y2~QzGFkZgLe3sJz+b-}-W59mhZv1wgN| zAOV7a4gE>Uua_81fX*g@-i&GiMB$G}enu(U0m+cTANS0FOX01*eO>$>)k-sqXby~$GbbV zJ@qHFw-sYNKFdTpstbHTCUtfvNzU9wI`SI4W{QKgp7zB%FOQkwmsQ@T75_02^hmg00hn7j8PVjMZ9O^4Uam}ufLgd4P z2}VpSOsogdHS{O6k?eTSZ(nTeK0;6wf(yv`%?!8g4an&hil_* zsX^J``x>LxHa%o}FX&TZ z0=S>BPF1zk=z}1(vmG8+a(s_%REOVzVQCFp`Y`Z00wenQAaVUTwEEw^Ne|n#yhyf) z^B6n#S;DoZ>Sgyq^Gku}SsMqX1;44s_Y2RHE}vJ|V+MWL>dTuO$8v}G+Rgh z_&C$+DF#iHiDdX2HFepLrEq%)#b2N={Kni>-$iV-k5z7!ZEjiq7J5hmI$XWUV2l^? zY@;yzh#4fCfYo+svmd*5>1YaV%cY7$`KY0>zIxiRIpkh_TV2xx z1|fcBrj>~cHt9ZGknQuoqWGG%W|zmP`V+j2c%*ekAixGMYxUCWQCza-JqN}LMYM)w z7;l!c=lL%Z*m`#ask~D;Y@Zm{+R* zR!gx|^^L9*&(}Om+JYp;tAvwm_$%9(cBfIbQgy4_S?2>xZfIOLtTu zD#A(_4dxTxjI@mM(GGGrDM)V)hLC?dTel_>D7tcUH*`Xj(BPtq9Jac-E@v$J>Mk&& z{=%4lj0mtaBM#(C3=A=!E>tcthA82|MeT3;Ty_~gx4UsRE{u};M&I;ZjBl-Im(;Wk zr08h+dTx};KX`0<9fgJ{k-_&BehyXvRw&3YYT;mE}PY@{jQgCvA`g;-cT zEz{HuRF&7J_1QUD3?cWbbYv~`s(Ur@(a;3t;G6&nWtz#$A)AB8U|di-k*kV zvyp0!&bB)3UBtyiYDp>LD`v#nK3^SLG|5jabKZ&n(tT@pnk(Iqhm(cw-MvPF!%3k$ zZhTT79Q~H|ykkaJ(d;RaQaxw&4gm>^-Zv`({C3gv`C+qEwZ$!a(4f_VuyRUkUWd)jS9l|N z5=}}@PEO)k!9Hs{`;WSpG|tT{9g*Ma<+#@2c!g;pKuMG;tl7`B8r|nOnd%jFB^Aj> z#e3GC#zR@N`SRb5;~1!f4Mhmv{qTizo3s?tg z|E4NOQf#z%$9#8KIa#Qk4NepuFyeypfVv9+b3v~LQ+DQ7YAwvs2+L2 zK&=y_VVP4O$Cj}3--@e=q4&sMKqRQ{WAT*I7MAoD6g<=j3L;XXlkoZ z#@Xg}6Pv`94zejD`W;@aKjl2S}Jpv)fUlYId zOz?c;G%~8)Bb`Hj zr>nk7#dwM7CWjq{b`DyX%i+F;+?N^FWLOMsrHF}=#{v4!r3q&(YFc-@LZ!L3#R|Tu zZ%td=5%LIs@hK3l)BHq6M(zP{+W9y|h7Ym3xyp(A|FmkV`)!$D2Yf;tyj^T++!6WC z#9{WniEAf@Kcn7=YbQlKoz8!f%u7WTw7H=02oL88?surH!XUdqX>fmXuVN@YoFaGJ z!Q$s%z)Q(CmXJu!k%-IU3EsHHl|`-VdbEN!#HxrPj6Z%ZvNkQ*h-oLeHWSX={r+Hf z_fxY{v+A^_<3dtLXN}s}cvnbih$=>_!+$TSDVwu;r9_3Ay2L_#HYPinMNMmn@(*st zIrST+%LmjOu~30YfeQh`P=DP_SQ9=Mvq<(dXCtZ|CDhz42@7k;9r12ofmpbHoAE#t zJ~}Jwg{#Z0x821$G~^ipp@o;H&ua*CS!x}Z-D3H?GLO?pg~aiSN-igtLw>>Ue=Ll| zu8X$XZv;KzLVveF9vP3P8EHUPZ^W4i0>X$+2z8T=l-LHSQyP8xKHz@!B0F}0u+I;{3i2m<_k`n(J z#FxGU0F(~3)l?q%0XK6=8a8xpMXgRWy5vl0*H!{)ys~Wf3{A~185U_bK$fl!U8w%qfv_mq>7pr8J z#xy=BWF(h=gMCylArs92jpuPU4aH^NxE@Z)TgaF3c}D6?;tV6$iZR2!Kc4RhQ{8tQ z9x~O{y$%f-d2u>(Z^c8PkMLGqYqL`wbqCN+lWByW*h7-Ksgw>aG zu{!k5mc+aW*P4GnKqsdyvj1wDbb@JuZ$f55b7FibGy<_sm5G1iy*=Bi`s=;9Tp9VS z7l-l6>i8E-24!gvJAGY5a5QxxYz_Rm2+kecL3dNGHSqY~!ob&EYo2IV^S3${0^H*U zM_Ngtau}HrTJM#iue&NQ7{>fmY9cg9_4fx@Bqc;CAypA%aO2bsCX_>OJ42De8vJv_ z-69Jd!S+O_J>>GNOaD6h(YNn`oNdDseblAU8BFhpl=oev*0XS)5`MAErA_Q{vAW08 z9HmZGB<9$ia^B1kni^nBe!IKIt}CjG>OAsY(+BzGd948cu1F7mLDrli)##)`IJZ;> zoh+Hihr36ghb;?ra?k-cWf|BhJX9=a!M&8CX}fgH;sAXw&AU+>Ute8#My_3yyYB9W z{E3!$kDpOiVllOjvM=8UK*9->9AdT;5adGKAno$lpZLsOlqf(5fcPp?b&O>$nVa2sWX z(Ixp{D{ix=W&saR7}(-!^L?s}R5SQa6&>ft_jW4WpQ_Ha1(R9cCUyJ$+OK_twm@z( zGjFjr`$y&@l8wn*N5TH3tS#g{q>qQ zw~G|YPudKkPAG%sC;A6Sof(S#fq&z7&NsTotYm9%@?pGm9kctpI}XWs#y>X38^mw^ zvGEN0mU3urhv`>*>(}0@M`=AgXk;HmkuY-Svf%Z>TQ<7|)jx~%YvEt4eJ{FFDCw^C&N}cmwEia{D)@s_vU*q1bo@+xPdO#Wb0Ps>$q1ziouc+#+KKj$)F-4jLvz<$P;0kQMb9 zBhHA}AEwdaA3G;X@n^)!A?44NsRmn{bQGOXQW%iEsiUWyw(ETlZK3>JPP@%Wq_U@IyW#jP5ntsr=Z51puGC-h={tdu_Tf(fiU zA{Kad;J;B!pg8~1s}?{i;uHBJIs<+q*pGHWUg`nRJ_mCJ4CCO3>hF7zbe8T=1d#68 zBT%ZH-w9-ZKc(~z0Iu8FOq?XN5_m*Q@pX&geBHz9)!zAvHJf`YQi*CoJrQM*tUdrvUkCppmx;$&jd_#n!+az99~q)hdJlcGDX>L1P@Df9U?JCKB6 z3T?+R-`=OcXW27C?6*a5mNK9D0msR9cN^`VJb4nekaCCpYw}a3Cr|$9zsh3ym`uFv zdfGBH^WUwH<-R!ktZ8DJ=S~@a^>?~aSP2+3LQq;=>WU6GUFY$~YFiw>rsm|p095{# zwmhckvldIN|Hi|Vot_gfX~DsPf*c6Qy-v=RNK&M{fhe(AHg^3xi(s-57L5t$@z5-g zl>9V*3($^Vu*dNs8=Ivu4fnueKO#oDBCQ-v9=4^l+S%W{ow%=&csi~wtZ$kcGFk-W zDB1!}eCi@3a1fk!@RrlRJTo?L7*$~^6Z5r}#t;6p9(=%EDX5AzP&#AY zL;i3HH+a1Jyv|WanxbY|Vv)o2wMWneC_I_exlURVT}FTNoXtLL|ckw4*GIl z^dLvUy+wiGX(o(Nm@Vgztyj*JIp16H9O|f*ug)|f)i*&IO3GC}(kctepFJto> zFt1;FvweE9-r1`uD(d}dG3xE_p?HCWAW9#^GM8*~#cANAuJoIj+sirMh7`RDr<3mc zFY^$3-2%n@l6F$KB4~;+f?&i0_Slu9+`2Mnz0vzkGTu)uzDucmL;;jh0RZ3SHy_{s z9+mXbOi4!4t4KtkZ>6_7*vF+Ww$R#N`B;qYq5&t7Fpi`=$^N>G!u4K`xCK=+Ca^0V*;FRI4%>l7pMHg+bZ1F+ z>>E+2po_*{$S^q-H4>=@XQ{-~Als=rp(tg9zrm61SHs|6QPqz}d;gv+R3_7KB(c*f zkYP#u@1co$nJ^)@mbp$mrB2_rWG7rbyk5C;1?@<_vp2So2H3ebN`m(S_ueJbVpV0u zoFu^A!j*uQEb=%9`X3h8d`YcmT-72$B_52r!uM(6s07)lhwuQl*jD5TM#{fkk^Z3l z>iqG|)*`IU$C)5z&9|?UR*ET^|hf zCM)kPRwh#tBMFm7VS|`eDA(bOE_h|S@3iT+YWvw6#fx|+n0z~C1347=+UBEcc9%Y) zScw);z8+VUchBf3)mc>qh$+pC!g;0s;h>&-G1uj+7el_M{@rV*d*Gzlh%PWi8GGqL^a@ZB9(&K!h&8QFMP`F=YfX)$ zWMmRi`+v7CuHy8-Va-p4Fg9mFdPUrIi{IN_=W1qJQ6FN=X^?g8!rF?(99uJo3y z1=nSpKDX#GI6vCv?WUzF$+S1s@!=d#r&owb7abnu;N+kmRP>e<`BX>*ijx!+w&~CR zD1LbN(grJjDo?gpF05K@}D87~I7Xtz6lY_Kik;GoX-8>7VSe z;I3B(*#{+7C8ZJWuFosOe(scECTmeO0H|j*Uz2A$YJyG4&i-%KXO#c=dRf^elXCFM zi3<%GO&1k!Kh&AY_xs4^JK^FxeV`<9w%EP}+4=4kJn~i- zJuK-vgZ9Kg3$;4n%!xmz5LkpK5E8_YKlAhAva0#t=jOz6&AV z(F;ApH4QK45g6tufE^U7qXi9-Kx83!Uul@jyl9+D3q26tHHsKk_Wjg>5g&*x7Kz}& z$!RQD6b}WuB>4U)*ojc3meX$A?o~ei-c7^qPrjor8w3adPn@viU!~dklh{Mi%=8Gb z=A&Tn)77xO%MSV^*=6oquUUTbO*z*OHZo7mG?tv4>{@WJ5mS@Y`rmvqp_jO*bEK+j z_>-?Y6YuR~neFTw9^EO}Owl>G6Y|g0@&Zb%V;TSrHnD)#{I1>%!2${E1ROuN}Njl1~f$R~F5&(2_iNHqy8nWdLj*NI`L$-C|X1xv@8exVAJTQyKFw zG_$k6Q@qFhpF=(NpQjkd0}qTlXgK^&cXmg(I(mk605c1AL?GaZHKzTcOv9SyE5s=2 zoUqND$oEOgwY|NY#yQyagj*~K;0Io_v_&QxS5i?ta)pLTVy?7UMQ|U&Xj?v1T!!3Q zQkX56?<1j>eRQu^E)*NV<&G?`=MEO#{s5Cje2f7X_|Bn4mw!R3d@QvR#`Q=ldJ>}Ldj)C9B5 z?or2-%f}h&{nz`UJ;0KJbJ`se)H)k8kcdt+ku-p0>`Yt=NkCL&@oT#yMkuC`3Ix@` z8pL>jclXgUIA-jA+M9webhnncdd5k{r>9gc~k_J3P}j+V5fEPT^nB z_)zwf$C)jz_CekK;p{Ia?D*by8+396?|QZ88y6@XfmVaj8~xV{J)b`)T~8!Fq?eBa z&42sx2-=8|!O^{^0@Nj()sC_SH>AXeAiDRP1AenCUMe$%XRvg4f(WDU4`k4!bpx5PV3=r zGtzJC^lMnk(AjuoSKgNJuUYz+1@(EYo>ob&P=D5rlPkkh_>D=f4m;K zT+?+6@Usbtc$X}oWaO9g3mb5{*lRqa+btk>tv!M(aw?qtL^ZmVgS_M8TnAtOS$NE& z=uSP_~GdxOED;04~>Xfz!8*@49Acw1#U#vVZQs>tp^d{ zO6J2t%g@lg&8*Gg23XO}%~uJ%+-r{*TyX$Fn8g)1Zz)SR#l%}^`cKW-YjvB|{gA4! z$?X2?i?BqNRI|88eG+No@!WqS!Q^Yk#_*ZOSoP(QH&F7F2?uid0-6#{yNYRv%=x&x zkyFg6M(*z2%5D2YWzKg4cl{51R6>6AJ?BDMzALttr}5}QFO;fi;p2+FAbl_RBYLQ~ z)E>Fg9au29?mZP>V~<(}v$EFKmDt9UoFcCh+q_RlxvGPII^LMeh=(Wl-t#QSuZmKJBf~k6fs2|S;AJ2rkSDbl;&L)4nSTpAE_4269 zPdssk(|ITCf*xs7KkABT2e-;|XjOwMU2DogqbiiK6x5Fy8CR=)igpQnXJf0EvVF;B zhld*!qf`}yn24-|MW_lEgPZJxY9i_awY(^rUmz3uL9E^{$qnCvMth*2h>uOz-o%${-haIr;G(r zbH7<#9rP$V^Wr=E-B0789>R~}uJfa29*wz;LaNZ{j2L=DtId`zaS?A~9E;s)3-}dV z#oVY>i_rn}u04SdC;mcYfS#^FJ8l8X8X?U7_UFEKFUA@2@rBVmG5mbVs)eDZpTVax z>ax;mS|BxN$jL#gwCISo+!SoO-8jBzu;gsN`hwJ(?6A|kVlx7)B&xDSAaTYwiK<*b z2;+Uq6La^GmVW8F8@|M*MZPP=^^lWfW+r4bQ_w3}ON8$M;H{}B?r2_Q zZKc$D=NJZUubO&B-|s( z5m8yqvwO(k+fH#uJMg90XYIwyXNO-z8}~yGSG{M4twa0}PJTz;FouKi~5>cBlIA(gKq**>g`??+`%bY*)(j8H|ht2yAz#)0#p8u;o)k)fz%f!)@c}L z#YrZ=l!wdhbA|Q20zYJ{yz9-ZPc81}m7U zyz*1Cx#(rOa*}^5l;30gML-Fuf+SEHiddt8V?2Ed6wQ{9VudkVbLPw6&#PO%;3Xi@ z2`uA9TMg5up)RRAS_fO^lnV~~DxpUc0&>K$Dj+|%IAdJNo0#)^O-;yd0X#Qhm+iNK zqgGbxZn!MLuer&p;}hW2G*q#;`nGbGanRX5pWc&)bpJU#G*15L^?-oNSrFnQ|3E7- znRa}&t+Be2%NEy{b909S(;URcMboB5i|lxuH@^Cl)(EseHcH>Smv`j(^Xy9SVRm-+ zu5oR6AR(qaKdmrez4$gdVwRyu)9$XZZBDL9*xYGn=m%S^EUc=Av&e15wd=phjKRA} z(ARIq(yi)KZ8tkapw#Q+VY6&DqwO#?nQDkCwbU*0n*_Mpujd>bsQOP{qbgD9_#8ikIxel7(H27m+4Ygz9?hnXr(#kl(~X95D`0HyhB^_eZhnM-Wd^sqkb^UPV8m1U!M=} zxP|ytpBcGX^TZ8bC(^dIPeMItLs>FH@j5vE0e)opUZHjK@;mUZf6E5<9Xmgr-AJZE($@C_;biZ|MoCl* zx2Nqg{vl(8Y!Z&~g$ypmH5SH&=i+{tkY*Ojuhgv0pB{`Y$f;o4s;<)Mqx0gb%`54D z{F}3@b@tSu{U*tW^<8~3#PfExg|z6Yz0q~{lVQNtE>}UGfIivFgSQ`DdETk}pMe>Q z^%;&FZfMcXuOzYQu%xmz+Fbl7LmkS|NGr>lghrAd?5!5SU*QqOvrQC5<@RG*j`C?k zU7I>JvvEf|ZLJC0v#!3H8%B)A6{giSYwh6Uw^M3%?8b#3vylbYL`}o^u`tz#8Y>^N zmLFgb{*cZ69e&aqJy^$tRJmviShqZz__V_{(x2~Wg*&S+6G{rTrSGkt4;<*x@=8PG zG0l-|T?NNDn^A?SD7h4iwF}^9DLq6wMz^N!KG9n5Knfqt*f8aA47~`RVD}{gmO=_S zdGQZQl60e9#GL@!?4B;pkqSXJUBl|P9l_(iR4hh8ycpcN*k6@T-n7ed^);Lgw20sr zF$#n502$dWrdeCjP-*40p9P=hOhp4TV+SI@wEE!_DVI+(^S!V9*0rtDcw#K}IG<;h zTBk}%)N+&YIMWv3ZJ(?e|Ad==q%&aVdk}W@EUIN+CUjp~RR=l?yvPR6) z$}?4*YJjR`EL|xtcMNlwe9U{BF!2e2hJ|2rXVlKSR3oYBXVE|NPJK2Altpm6q6Rzy zQrSR>G3xbr3z~@~td;E*n<%5pw6ogUjtZ`ie8!hVTTfN0ukf>Z2t`NUwNeANIDIYn zXoUc>?vdSJ-kvp;rY}PRZEbn(y6i(F@)rEU+*+s%Uf%<;D!zsXVGU1W&c&JYdhjT6 zYQ{H=%fZWgi;e;N;qHqtS5)ua*PgqS%%kp^D@1qKN{10GJE{zp4-HeBAO_X^2ARaY zS$FM52AoylhreVuNqq6>Q_A(Ud0XJi_7ml+-=?7xr=5@w-zMqhVwy3y6H3=SSkg_r z3AU&--3IJ7fV? znPY!JMY$PP#zD_0M^8)FUFp%JE>gPeuFK|HX;f{E8!1UC&nJX4yOYJ>3pM{hx^!31 zObVWrM5bkGub9wg;|97ez(>B(P1Ad04H8-bNCV$1f`NTK~A2aZC$DTl_Kf%qn_E zWGYi3E`>rc^3M?g=h8!E&9}nI_puqoNa2#~wRmF*%kkG2!!`#$E;x`^q@;&{tt*$S zM|5;*5_78dBeBVma`yr+;O{<~g@y~Bk#<41Q*!cm6nBM7lusRIC=$AS^Xxdk@^wG< ze42*073mQ6vdrvqm*;}Fekd{;MMXVMW!7_L{8-IHF*0*9#lyigxks0bFC?~+f8SnC zh8o{s-1Q(zzcoNC&O*KJ% zJ6M}(s~;nVKB`pt^3y?9;>n3Nd^8^wwxigrnBhM@9gqV>khdnp&->v2EP&H^C3n$XbaK{iEBx%p5-(8R@ z)XWR~cI+d;z~T*NI-DvltkQyd_48G7*M*JnISEZI1tRc1EnScg$#lsNi7avUhAEl* z(C@+IoK49SS7UE9F*x&C&S;QY(;$hb8I5eAOFS(lIRQyXUBn%RWM5Y}Jdk|knB=I! zjls#!0u|j%bo}Q{qz?b82esc;8rFfYUeUdPB!7(ET5%vY2k7|M7eO*KO(jk4N~#!l zE%z2Lf_^(x4B4J~L=JqGG_*xe*FEI#w?2J`Dw0r`tMrt%V3j9^*~9QITdyS9_dBkP z;nqgN+-rc>jYBU%ild))7*#QJB!QQU`<*7DmtxnB--a0qi+UmeY+8o-D3LFzsUd~A zvS1JW5A^xRJTcrNF7kNK^`wi@JNL-t(dFgpr>Cy$JO1}JUal#A4QjnQ+i?3+1H|NC zSJ)Mv+=LqT4QGLUZlr(LMBedGTYQgF6z8kzhA!?Co0XPm?#36Ii^t5_5;xQL9o@a! zU(tJ``QN$AvJ1*2;>WE6w}hj(7tpdG_!32Lshy)|K@>ANm*&=zlewZX*EHD5gdJk43Z68&kb~2U|pzx8;&;&Mr;` zGp9y$HQJa2mM1?e*&7KMTNo0fjWXC|_We$_sdE74w9URPi2 zbLOA?sI)t~;|%j@W1d5U@c-C6Qbo!-IWgHAq!#p@Jj86;n`GE{dg-2I{TD ziD!YbJ}-aM1gV(=YucWvV&tIjPe|o=2LRFZBq_TNFoq;bz zS9j>Y`m>(hZgC|G(FTfjxCJsOD`ELfg}!Q0a^ciQ1VU&5YUFH@yIakwgTsS^IUpw# zND?<^2b`t>q&Fcj;MhV4I8b$-Z!Hlx5`^T=yvICIc6ToLc%2r|>*x=e*d+F8I9NCi!e(b26g|sMz7A4J({4BQX?cR-|ialF$P? z0#p({|FE#CUNdRs+=(Ye=qO@q43s=i7k^FwD3|yEI;4Q&pz?vplwDdC&bO5cP5yde6J_jHRw0Ta0Jbm#iUmiCd5-Hpt?m2j)sxTY6gl~6RrJF*KDIoo;M!pU zy}J0%>->Q#<<~&N@In?WFvKGMCLrYr_zxVQqu#qRil9x8nQ!_&<12%$nm5r0sFeeE z$_Eo2f9fhsjwjzl_tKm^1*RVWp6$YpP21pOg6#ayZ z=+^8+e;X47&43dVz~XGU0V(y(alEAPg~m_q!O)7s$w)kujxf9P+0>G3Q!UxcA8Q-iw zSSy>1lgA=xSx?#ST4tG^P15mGN+XK`B0Ix-HkDUQA?@3N( zhTc_N4Tw-X1J?kk$3S$iG?weqiXVbtWF7aakgA?__S?EUb@o(}=*;DUPxW^WQo+Uy z4cHDq;vz6TXcI4a6Zqp`^=Pbv6-^Lj4FRG>1HbTMwZi8PfUNq4YA2eJq1>*OjJcTc zn^e`K&qytfNWKlJ$foMun{hhyKBU~xtZ*B%?TjL$I`9byFKoQtaP|qb{vJ)`Y9xyMm4)2K4BT zml6OLE-e4L#Up(hG{J320+?IQ4CKb*3IP1%IPgeF0#pNn2V7;edd|Sngk-=Q0Sy3o z;jVx?iwgqO_X-7i)ufIuXw1Bo27=D(T$K$1mj%S^#Q}ZduiP3<`{@DvCv4Omg^*YP z@$s2Deo+W`@^k1JQUL4FAwvh$vq%8!nKU^y6QChiWr=`kN(bsfAP$V*WiW%;uAG2k z2I0j-75X3qCpMv!y2HMW?UzE}Qd)u`NJt9ys91L6UkpuP!8 zz^fAB-7XsSu?0t(jvZVdKh{YRt3`ugQh9aR1oga@2lO@#z;=uCz03jWU`vhX={`#|pq*9})h(Qqt zy?WmYFvyklDBDvuY=6wuObcj`gE5o;=X^X%N3arBI|r!N?jri)GQE?GW4r3|)dK)T zWqI>`AspL6+V{#BAQ%Op@FpkO`F=St9HO%jZt5%P21G02#1lI&dS~U(U+cI-Wv?x# zUJf_9Ja>;)vYaA*m)0nk-#9p0PyK7Q^}}vOv;W88x1Z(f#oUUAP9G(B$)9h;^t~VW z08(S@13hL=hQt(@TV1*Gqs5*q#j$BfGtocj$$9UVUQ{TJ8n?pz7jruYD*f zkoe{2UcD%KeveWtsVib%ZU3-;H>_a;1dany_NED;nf_BcX(o_ZFv`_IOFs^l-7P7) zg9PBd_G*yW{EiFmm^AF>|H)*AP0+0Yd_OI|_x8bVo6fa?K9=IL-5`M~I13ISET3Aj ziO$7=5=!eegfi@a5+WTSwe?%N*^_gbH|F;P<*n~Rv9_Ko{;O7{2=p*7hT;Hw;rZ-l zJ)wnqM1?sYTrMPZbHQx-t+0qn2-*dtCNZXW{4nZ}0$#-hMvM7RFR>q+^|@6X0+B7J zPSdaA)y%Qfgc?A9V$|*Spii7DWDm|m8TY==U55h}Bf2 z_^Q3lynYQwW{ayz=DoE3JRAj3vZ1#Bz=6ZJPgSN)EkP;!u^C+TK7RobF-ioO7hu zD79%9!+L*Q1zTe&VQ?Ew^IQ77qfBIE-7g16C#+56m?pmLy&zdI@2BZdIL~21>%xDD zNukV|)Y;Sj`E$VE!VEK8{SI?-VcB$Qq3(~KFkWKxGN&EEeKi2_%+Wm+H<~RDZ85qo zRLBX-B#E~fR_QYYS~STxKafTmA7Mt-d2^O-EmRcD&+`_6F6*Cflu;dI=;x0{s*qFR z@%}Q}Mfa!f6OkxEy(Oks(%j3^U}%WN$ZH>vK_g8?5UL(xD+;S$sr~@4XuI61>V5|Qh21L7fvhb_n4KDOQ^v_sCEfl;fmCsR58!qDGcXmJ`bkmx;Z6pCC6g^+%4tC@ z^|qdEVJZ;L(Gg&#Me{M1lgs8g!x%umGouqrYkYTpZW3iwF_ z<*xt%Rte?D*zW`}?g>iL3`>qkiR==y-eFnkJ{Hm?m}ncnLv6Yss{z{i&02_*63G=8 z>e~UPHX`L4llZKa96i|2@ai|?{FwW=O$3~V!MDmSk>;{a4hBXEg|jIz)=!&>kr~DO z6>Cjej_4v1d?A8s$L{5pKnKCI zkv}uK`zg#iCbvHw7F7>MaB4(^km|O6JA@cetAl1U+kb(&$J-7|7HsGqDZziOu&~LX z+%f=RN zvGPs7ANVvSz&FBbL}aC&Dgi-m{kFEMSn4_0wB;LweK$JsJ`3C3l7ZC6sGB6reN)V& z=f>Y^u^zy3yM*pB79q3-Z?t#>CGFDBckP=7z$E{BR}W!3F*D6HeBA*EXRUqDSH?}o zq$C^^cs>g3906W;jRs8;HmHB|!+iO$2fFjP}e9yZ;I0 zu1=N=8sP{-{%~VnRWodUR}J7NpYp-Wb~?|I+r1p26i8{1ol&R#B~>Np!7wOT5FKR) zJo2-?(&4lxfkjMEM(F!r+HOxxeFf!-h67|38y?_vL%7hXg9h`>uz zr;KOWY9*V5V6-;6$|h*GNU6268$fR zNq%()kfcc(P1<5(xbto$AGLl%4g}+R^FP}k#T3bl@t5m1XM1^kRQm8vYG~uy=gm6n zzTrxt5e!ZU?M9pcK7X}U847phj9`O1hmqPpYS?Ck06~XBBiBSgU@VNh@Fo`%|Mdbk zttK0)R9&&e^UfS$I1Dn!QZ6~sjObudU$5r5F%uAiG)-BB{EyQ>b)ZiA|DS+pefw|2 z@ojDGrU)ze@5QaKD;lRhP}qGU?>S&6E}_HGaU(Othu^WxAq1ZNBa3+u(4X#AHun693x6XddL6LywKtHfFsV2q$>?^lC8eJF*2}iHoqS+0>m*=D;|DmT9fw)}hB?SjZX^afdB8c~N-)IUUUpTv2NOj2`)x=Gyd+MaR4_18nLL z_T^z7WDQ6O6SEL1f7vEor`!|?msc5~u)0=_E?+GL+1i&jn+qU_TaSLf3@FpJI{@%K`9ma-L>Sr)k;su8JLOy^V-*dy z86Ce2z{o;y_9KVal1n5!Jiv!q@XnlUnwu$Vac+_JtPy-FW2ZP;{gR#f`&j8^M;mPY zQaF#Sn)AxWdm{s-@g7(4jz&OzY20qTjXv`_CI!;xL|l(y)sO{0P<%n@1=fC&!#7aw zINfN7D(4b4Ldx@I z>*qrYVKnrePvNYq;>rF4;U1YaB&9X~(YsQxIW~?s>BoViYM!d6Kt7$hWwW`;1Jr$fdOxz8Np(_pDb#;y ztL9EW&E(uqCTl+>0p)@@>T^0pZ+|c{^$)jR7y!Tjf;m7QBN*} zPFQ&?;x>?W^5?bqW9&)GO4QrW%VhUo2Y)2cM!3Vkrk@T5Bt^?u@-IK@EDZXF$2xlU z4D<3LG5adQ4>p9*Z^#+vJHHKT2$;$u+T6kB9RK!Rd^DY`N=5U(pI6JS<_ba=c%fDM zN9b#^h655|Fci_cZrgVv7rVohX7poRt5EL=P-5yK);PeGyUyG`sYHf};?{y$C;!iz zz8|~Ce;tR@Ll>l>RjT8cyalqaevZ&M`)fK)i$p7Elt4#0gwly^(32@BeC}oSgG4Pw zyMg=n#dH@X3&=8VmP`y~As(KEEaO;n5slw{e%#Y!GlF?vsnl{f+3NLoTo!%hX6buh|x12Sugj?B=RpsLz4ryfhIC{X!6gaq(z2-vT$>K>BnKlm{)CFdbybSJAgHjY`x z97=6p%d+nUw+4$2Mbh=;=a9Xg%H()U{oJ zhpprQI2L}tJ6@1+Yblb^p2D0>0+a9|QILWL;^Z|(GVFmlfq>`GVI{v!)Ije;Jni6>r z5K>D#PuJ@qF+I^J7vn-L|94lD#<*&6uYwq=PW$S#L!OxEWUMw+K4j#<2eleZ-hNCAFQ#6eE%! zZ40D(S`WAvBKfTX$$G_ziWX{gn|;lwUcA5kU*vNq!NqW39Zwqy3=w*T(-W zjA;OiFN)19a^M?kcGb%Ao3SX&<4&M*}J zozNaS@5hKRXNS3OPSk#n7^A2B{Jqw`*R}5KpDH7w6~#C|6PkAYkI==g6mUSV<0iIt zzf~hKJGa$uU4bZ%kr(n=mWOIOilO@l2^PAeR$*y4nN{V6cz!x7=`0>uLBt_Z;=L23%zyUS=&7q zLTh$|6oVF*!=tEf1yHCDM}=7flEM1fiau?Y2>))7H$VtI(64D!W)FiE(+GBQI8VQ+#UzFNWfN~w6<-+txkj4Jb* zuoj)q#;?lba<5h84_`|7IxV|$zYkCiQl?o;xK2l8d4}xpJ=Y8191tE5ADsQ(dk!Gi z-5Gu*)z7_+Je{OV%ZGZAdkHuW<@!f(_7l)1cu|`+kk{&5BP(s!6=S zUh4dHD9T1vvn1v1lG{dqtXn*{6#jDvGC)2+RpcBkHUTVsd9Wd4`%0+MJ(Zeg&j4mk-d?PcwV@3aB#58&+Q)9 zKk)r^o}tvLndajxxxk}NpIb5ATOXQpe?vjFxl!l6EH#Q9A9V49A%fvB>b?U zDJ?Bc_xl@t3*YU@`cSmtNW{A2lZfJoV*90!h4`Jt{LAR%X_V*UkH9if%QH~^2X5vo z_A8e8xi6vN*S=dliP2oeuVrlQ428&)-FN1(M_W@bTo$*sHiQUU=o6v8RGnf5K-Ucm Wk$dsVEyQ!+0B!ZVYE>9p-2VY){bL&d literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/storage_almost_full_layout.xml b/app/src/main/res/layout/storage_status_dialog_layout.xml similarity index 86% rename from app/src/main/res/layout/storage_almost_full_layout.xml rename to app/src/main/res/layout/storage_status_dialog_layout.xml index 9c92e255599..2ebb8ff8aaf 100644 --- a/app/src/main/res/layout/storage_almost_full_layout.xml +++ b/app/src/main/res/layout/storage_status_dialog_layout.xml @@ -13,7 +13,7 @@ android:orientation="vertical" >