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/build.gradle b/app/build.gradle
index 51039012ac6..2d879b094bd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId "mega.privacy.android.app"
minSdkVersion 21
targetSdkVersion 27
- versionCode 222
- versionName "3.5.1 (222)"
+ versionCode 225
+ versionName "3.5.2 (225)"
multiDexEnabled true
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8ae3cddfb7d..14bfca811f3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,8 +2,8 @@
+ android:versionCode="225"
+ android:versionName="3.5.2 (225)" >
@@ -35,8 +35,8 @@
-
-
+
+
+
+
+
@@ -248,13 +254,6 @@
android:theme="@style/Theme.Megaactionbar.Secondary">
-
-
-
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 +839,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 +1448,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/CameraSyncService.java b/app/src/main/java/mega/privacy/android/app/CameraSyncService.java
index a01dece64e6..06e387fde41 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(false);
}
}
}
@@ -700,6 +701,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 +716,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 +2221,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 +2229,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 +2326,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());
@@ -2458,17 +2465,15 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isImage()){
uploadNext();
}
}
- else if(e.getErrorCode()==MegaError.API_EOVERQUOTA){
- log("OVERQUOTA ERROR: "+e.getErrorCode());
+ else{
+ log("Image Sync FAIL: " + transfer.getFileName() + "___" + e.getErrorString());
- isOverquota = true;
+ 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);
}
}
}
@@ -2489,7 +2494,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) {
}
if(isOverquota){
- return;
+ log("After overquota error");
+ isOverquota = false;
}
final long bytes = transfer.getTransferredBytes();
@@ -2500,6 +2506,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;
+
+ updateProgressNotification(totalSizeToUpload);
+ }
}
@SuppressWarnings("deprecation")
@@ -2530,10 +2547,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);
@@ -2555,7 +2576,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();
@@ -2568,7 +2589,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();
}
@@ -2581,7 +2602,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/DatabaseHandler.java b/app/src/main/java/mega/privacy/android/app/DatabaseHandler.java
index fa05f101ac3..30da2622e2a 100644
--- a/app/src/main/java/mega/privacy/android/app/DatabaseHandler.java
+++ b/app/src/main/java/mega/privacy/android/app/DatabaseHandler.java
@@ -2927,6 +2927,19 @@ public long addPendingMessage(PendingMessageSingle message){
return id;
}
+ public long addPendingMessageFromExplorer(PendingMessageSingle message){
+ ContentValues values = new ContentValues();
+ values.put(KEY_PENDING_MSG_ID_CHAT, encrypt(message.getChatId()+""));
+ values.put(KEY_PENDING_MSG_TIMESTAMP, encrypt(message.getUploadTimestamp()+""));
+ values.put(KEY_PENDING_MSG_FILE_PATH, encrypt(message.getFilePath()));
+ values.put(KEY_PENDING_MSG_FINGERPRINT, encrypt(message.getFingerprint()));
+ values.put(KEY_PENDING_MSG_NAME, encrypt(message.getName()));
+ values.put(KEY_PENDING_MSG_STATE, PendingMessageSingle.STATE_PREPARING_FROM_EXPLORER);
+
+ long id = db.insert(TABLE_PENDING_MSG_SINGLE, null, values);
+ return id;
+ }
+
public PendingMessageSingle findPendingMessageById(long messageId){
log("findPendingMessageById");
// String id = messageId+"";
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..fa655eaa56f 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(false);
}
}
}
@@ -2195,20 +2196,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/MegaApplication.java b/app/src/main/java/mega/privacy/android/app/MegaApplication.java
index 6d9648f013e..41e765be4b0 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_222";
+ static final public String USER_AGENT = "MEGAAndroid/3.5.2_223";
DatabaseHandler dbH;
MegaApiAndroid megaApi;
@@ -676,6 +676,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);
@@ -1315,7 +1341,21 @@ 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");
+ 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);
+ }
+ }
}
@@ -1508,6 +1548,7 @@ else if(msg.getType()==MegaChatMessage.TYPE_TRUNCATE){
@Override
public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) {
+
log("onChatCallUpdate");
stopService(new Intent(this,IncomingCallService.class));
if (call.getStatus() == MegaChatCall.CALL_STATUS_DESTROYED) {
@@ -1533,6 +1574,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");
@@ -1573,129 +1615,129 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) {
log("EXCEPTION when showing missed call notification: "+e.getMessage());
}
- //Register a call from Mega in the phone
- MegaChatRoom chatRoom = megaChatApi.getChatRoom(call.getChatid());
- if(chatRoom.isGroup()){
- //Group call ended
- }else{
- //Individual call ended
- try {
- if (call.getTermCode() == MegaChatCall.TERM_CODE_ANSWER_TIMEOUT) {
- //Unanswered call
- if (call.isOutgoing()) {
- try {
- //I'm calling and the contact doesn't answer
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, 0);
- values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_ANSWER_TIMEOUT:call.isOutgoing " + e.getMessage());
- }
- }else if(call.isIncoming()){
- try {
- //I'm receiving a call and I don't answer
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, 0);
- values.put(CallLog.Calls.TYPE, CallLog.Calls.MISSED_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_ANSWER_TIMEOUT:call.isIncoming " + e.getMessage());
- }
- }
- }else if (call.getTermCode() == MegaChatCall.TERM_CODE_CALL_REJECT) {
- //Rejected call
- if (call.isOutgoing()) {
- try {
- //I'm calling and the user rejects the call
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, 0);
- values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_CALL_REJECT:call.isOutgoing " + e.getMessage());
- }
- }else if(call.isIncoming()){
- try {
- //I'm receiving a call and I reject it
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, 0);
- values.put(CallLog.Calls.TYPE, CallLog.Calls.REJECTED_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_CALL_REJECT:call.isIncoming " + e.getMessage());
- }
- }
- }else if (call.getTermCode() == MegaChatCall.TERM_CODE_USER_HANGUP) {
- //Call answered and hung
- if (call.isOutgoing()) {
- try {
- //I'm calling and the user answers it
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, call.getDuration());
- values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_USER_HANGUP:call.isOutgoing " + e.getMessage());
- }
- }else if(call.isIncoming()){
- try {
- //I'm receiving a call and I answer it
- ContentValues values = new ContentValues();
- values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
- values.put(CallLog.Calls.DATE, System.currentTimeMillis());
- values.put(CallLog.Calls.DURATION, call.getDuration());
- values.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
- values.put(CallLog.Calls.NEW, 1);
-
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
- return;
- }
- this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
- } catch (Exception e) {
- log("EXCEPTION:TERM_CODE_USER_HANGUP:call.isIncoming " + e.getMessage());
- }
- }
- }
- } catch (Exception e) {
- log("EXCEPTION:register call on device " + e.getMessage());
- }
- }
+// //Register a call from Mega in the phone
+// MegaChatRoom chatRoom = megaChatApi.getChatRoom(call.getChatid());
+// if(chatRoom.isGroup()){
+// //Group call ended
+// }else{
+// //Individual call ended
+// try {
+// if (call.getTermCode() == MegaChatCall.TERM_CODE_ANSWER_TIMEOUT) {
+// //Unanswered call
+// if (call.isOutgoing()) {
+// try {
+// //I'm calling and the contact doesn't answer
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, 0);
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_ANSWER_TIMEOUT:call.isOutgoing " + e.getMessage());
+// }
+// }else if(call.isIncoming()){
+// try {
+// //I'm receiving a call and I don't answer
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, 0);
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.MISSED_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_ANSWER_TIMEOUT:call.isIncoming " + e.getMessage());
+// }
+// }
+// }else if (call.getTermCode() == MegaChatCall.TERM_CODE_CALL_REJECT) {
+// //Rejected call
+// if (call.isOutgoing()) {
+// try {
+// //I'm calling and the user rejects the call
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, 0);
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_CALL_REJECT:call.isOutgoing " + e.getMessage());
+// }
+// }else if(call.isIncoming()){
+// try {
+// //I'm receiving a call and I reject it
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, 0);
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.REJECTED_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_CALL_REJECT:call.isIncoming " + e.getMessage());
+// }
+// }
+// }else if (call.getTermCode() == MegaChatCall.TERM_CODE_USER_HANGUP) {
+// //Call answered and hung
+// if (call.isOutgoing()) {
+// try {
+// //I'm calling and the user answers it
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, call.getDuration());
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_USER_HANGUP:call.isOutgoing " + e.getMessage());
+// }
+// }else if(call.isIncoming()){
+// try {
+// //I'm receiving a call and I answer it
+// ContentValues values = new ContentValues();
+// values.put(CallLog.Calls.NUMBER, chatRoom.getPeerFullname(0));
+// values.put(CallLog.Calls.DATE, System.currentTimeMillis());
+// values.put(CallLog.Calls.DURATION, call.getDuration());
+// values.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
+// values.put(CallLog.Calls.NEW, 1);
+//
+// if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
+// return;
+// }
+// this.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
+// } catch (Exception e) {
+// log("EXCEPTION:TERM_CODE_USER_HANGUP:call.isIncoming " + e.getMessage());
+// }
+// }
+// }
+// } catch (Exception e) {
+// log("EXCEPTION:register call on device " + e.getMessage());
+// }
+// }
}
}
@@ -1714,6 +1756,7 @@ 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);
i.putExtra("chatHandle", call.getChatid());
@@ -1724,9 +1767,6 @@ public void launchCallActivity(MegaChatCall call){
MegaChatRoom chatRoom = megaChatApi.getChatRoom(call.getChatid());
log("Launch call: "+chatRoom.getTitle());
-// TL.log(this,"launch Activity" );
-// Intent i = new Intent(this, TestActivity.class);
-// startActivity(i);
}
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 936578e2b73..722554b951f 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);
}
}
@@ -664,13 +679,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) {
@@ -850,6 +858,13 @@ else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) {
} else {
log("Upload Error: " + transfer.getFileName() + "_" + error.getErrorCode() + "___" + error.getErrorString());
+ if (error.getErrorCode() == MegaError.API_EOVERQUOTA) {
+ isOverquota = 1;
+ }
+ else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) {
+ isOverquota = 2;
+ }
+
if (!transfer.isFolderTransfer()) {
errorCount++;
}
@@ -873,10 +888,6 @@ else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) {
}
}
- 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) {
@@ -924,8 +935,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);
@@ -939,6 +950,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());
+ updateProgressNotification();
+ }
+ break;
+ }
+ }
}
private void showStorageOverquotaNotification(){
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..88553caee46
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/components/CustomizedGridCallRecyclerView.java
@@ -0,0 +1,104 @@
+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) {
+ log("onMeasure-> widthSpec: "+widthSpec+", heightSpec: "+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/components/MarqueeTextView.java b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java
new file mode 100644
index 00000000000..63de2e15ee0
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/components/MarqueeTextView.java
@@ -0,0 +1,108 @@
+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) {
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/mega/privacy/android/app/components/WrapTextView.java b/app/src/main/java/mega/privacy/android/app/components/WrapTextView.java
deleted file mode 100644
index 2ceef492954..00000000000
--- a/app/src/main/java/mega/privacy/android/app/components/WrapTextView.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package mega.privacy.android.app.components;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.os.Build;
-import android.text.Layout;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-public class WrapTextView extends TextView {
- public WrapTextView(Context context) {
- super(context);
- }
-
- public WrapTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public WrapTextView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public WrapTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- // Now fix width
- float max = 0;
- Layout layout = getLayout();
- for (int i = 0, size = layout.getLineCount(); i < size; i++) {
- final float lineWidth = layout.getLineMax(i);
- if (lineWidth > max) {
- max = lineWidth;
- }
- }
-
- final int height = getMeasuredHeight();
- final int width = (int) Math.ceil(max) + getCompoundPaddingLeft() + getCompoundPaddingRight();
-
- setMeasuredDimension(width, height);
- }
-}
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 70c02d859cc..5dad88e48c2 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
@@ -820,6 +820,7 @@ public Notification buildSummary(String groupKey) {
}
public void removeAllChatNotifications(){
+ log("removeAllChatNotifications");
notificationManager.cancel(Constants.NOTIFICATION_SUMMARY_CHAT);
notificationManager.cancel(Constants.NOTIFICATION_GENERAL_PUSH_CHAT);
}
@@ -931,7 +932,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)
@@ -941,6 +941,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);
@@ -953,13 +960,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));
}
@@ -1008,7 +1021,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() chats = new ArrayList<>();
for(int i=0; i= 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 +1728,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 +1771,8 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) {
}
if(isOverquota){
- return;
+ log("After overquota error");
+ isOverquota = false;
}
final long bytes = transfer.getTransferredBytes();
@@ -1741,6 +1783,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;
+
+ updateProgressNotification(totalSizeUploaded);
+ }
}
@Override
@@ -1768,12 +1821,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());
@@ -1901,17 +1955,14 @@ 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);
+
+ if(e.getErrorCode()==MegaError.API_EOVERQUOTA){
+ log("OVERQUOTA ERROR: "+e.getErrorCode());
+ isOverquota = true;
+ }
+
cancel();
}
}
@@ -1949,10 +2000,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);
@@ -1974,7 +2029,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();
@@ -1987,7 +2042,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();
}
@@ -2000,7 +2055,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/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/AudioVideoPlayerLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/AudioVideoPlayerLollipop.java
index c84b90f2662..8a3f13103d1 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
@@ -130,6 +130,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;
@@ -139,6 +141,7 @@
import nz.mega.sdk.MegaError;
import nz.mega.sdk.MegaEvent;
import nz.mega.sdk.MegaGlobalListenerInterface;
+import nz.mega.sdk.MegaHandleList;
import nz.mega.sdk.MegaNode;
import nz.mega.sdk.MegaRequest;
import nz.mega.sdk.MegaRequestListenerInterface;
@@ -152,7 +155,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;
@@ -583,6 +587,8 @@ else if (adapterType == Constants.FROM_CHAT){
finish();
return;
}
+
+ megaChatApi.addChatCallListener(this);
}
if (isFolderLink) {
@@ -767,6 +773,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
@@ -1142,6 +1156,16 @@ public void onLoadingChanged(boolean isLoading) {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
log("playerListener: onPlayerStateChanged: " + playbackState);
+
+ if (playWhenReady && mega.privacy.android.app.utils.Util.isChatEnabled() && megaChatApi != null) {
+ MegaHandleList handleList = megaChatApi.getChatCalls();
+ if(handleList!=null && handleList.size()>0) {
+ //Not allow to play content when a call is in progress
+ player.setPlayWhenReady(false);
+ showSnackbar(getString(R.string.not_allow_play_alert));
+ }
+ }
+
playbackStateSaved = playbackState;
if (playbackState == Player.STATE_BUFFERING) {
audioContainer.setVisibility(View.GONE);
@@ -3489,6 +3513,10 @@ protected void onDestroy() {
megaApi.httpServerStop();
}
+ if (megaChatApi != null) {
+ megaChatApi.removeChatCallListener(this);
+ }
+
if (megaApiFolder != null) {
megaApiFolder.httpServerStop();
}
@@ -3677,15 +3705,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();
+ }
+ }
}
}
}
@@ -3775,6 +3805,11 @@ public void onBackPressed() {
megaApi.removeGlobalListener(this);
megaApi.httpServerStop();
}
+
+ if (megaChatApi != null) {
+ megaChatApi.removeChatCallListener(this);
+ }
+
if (player != null){
player.release();
}
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 e26b6ea673a..ee70bcd8460 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
@@ -812,11 +812,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/ChooseAccountFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/ChooseAccountFragmentLollipop.java
index 9bbdcc674af..deb023dc663 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/ChooseAccountFragmentLollipop.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/ChooseAccountFragmentLollipop.java
@@ -243,7 +243,7 @@ public void onFreeClick (View view){
Intent intent = null;
intent = new Intent(context,ManagerActivityLollipop.class);
- intent.putExtra("firstTimeCam", true);
+ intent.putExtra("firstLogin", true);
intent.putExtra("upgradeAccount", false);
intent.putExtra("newAccount", true);
startActivity(intent);
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..047a557bf25 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;
@@ -75,6 +76,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;
@@ -165,11 +167,14 @@ public class ContactInfoActivityLollipop extends PinActivityLollipop implements
RelativeLayout shareContactLayout;
View dividerShareContactLayout;
+ RelativeLayout sharedFilesLayout;
+ View dividerSharedFilesLayout;
+
//Toolbar elements
ImageView contactStateIcon;
TextView firstLineTextToolbar;
TextView firstLineLengthToolbar;
- TextView secondLineTextToolbar;
+ MarqueeTextView secondLineTextToolbar;
TextView secondLineLengthToolbar;
RelativeLayout clearChatLayout;
@@ -286,8 +291,7 @@ 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);
secondLineLengthToolbar =(TextView) findViewById(R.id.second_line_length_toolbar);
nameText = (TextView) findViewById(R.id.chat_contact_properties_name_text);
@@ -389,6 +393,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);
@@ -481,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));
@@ -489,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){
@@ -622,6 +639,9 @@ public void run() {
notificationsLayout.setVisibility(View.GONE);
dividerNotificationsLayout.setVisibility(View.GONE);
+
+ sharedFilesLayout.setVisibility(View.GONE);
+ dividerSharedFilesLayout.setVisibility(View.GONE);
}
} else {
@@ -1275,6 +1295,14 @@ 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;
+ }
}
}
@@ -1796,7 +1824,9 @@ protected void onResume() {
contactStateIcon.setVisibility(View.GONE);
}
- requestLastGreen(-1);
+ if(Util.isChatEnabled()){
+ requestLastGreen(-1);
+ }
}
@Override
@@ -2529,13 +2559,13 @@ 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);
secondLineTextToolbar.setText(formattedDate);
+ secondLineTextToolbar.isMarqueeIsNecessary(this);
// secondLineTextToolbar.setText("formattedDate formattedDate formattedDate formattedDate formattedDate");
- secondLineTextToolbar.setSelected(true);
secondLineLengthToolbar.setText(formattedDate);
log("Date last green: "+formattedDate);
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/FileExplorerActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/FileExplorerActivityLollipop.java
index be58de30654..b2e6a7faf74 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
@@ -501,8 +501,8 @@ else if (ret == MegaChatApi.INIT_ERROR)
megaChatApi.logout(this);
}
else{
-
log("onCreate: Chat correctly initialized");
+ megaChatApi.enableGroupChatCalls(false);
}
}
}
@@ -1598,7 +1598,7 @@ public void onIntentChatProcessed(List infos) {
pMsgSingle.setFingerprint(fingerprint);
}
- long idMessage = dbH.addPendingMessage(pMsgSingle);
+ long idMessage = dbH.addPendingMessageFromExplorer(pMsgSingle);
pMsgSingle.setId(idMessage);
if(idMessage!=-1){
diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/LoginActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/LoginActivityLollipop.java
index f9050a6504c..57ac5652665 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/LoginActivityLollipop.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/LoginActivityLollipop.java
@@ -513,7 +513,7 @@ public void startCameraSyncService(boolean firstTimeCam, int time) {
Intent intent = null;
if (firstTimeCam) {
intent = new Intent(this, ManagerActivityLollipop.class);
- intent.putExtra("firstTimeCam", true);
+ intent.putExtra("firstLogin", true);
startActivity(intent);
finish();
} else {
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..3bd1e6a1b5e 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(false);
}
}
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(false);
}
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(false);
}
else{
log("ERROR INIT CHAT: " + ret);
@@ -1645,6 +1649,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 +1664,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 +1682,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 +1709,7 @@ public void onClick(View v) {
break;
}
case R.id.login_text_view:{
+ hidePasswordIfVisible();
numberOfClicksKarere++;
if (numberOfClicksKarere == 5){
MegaAttributes attrs = dbH.getAttributes();
@@ -1727,6 +1743,7 @@ public void onClick(View v) {
break;
}
case R.id.text_newToMega:{
+ hidePasswordIfVisible();
numberOfClicksSDK++;
if (numberOfClicksSDK == 5){
MegaAttributes attrs = dbH.getAttributes();
@@ -1984,7 +2001,7 @@ else if(action.equals(Constants.ACTION_CANCEL_ACCOUNT)) {
if (firstTime){
log("First time");
intent = new Intent(context,ManagerActivityLollipop.class);
- intent.putExtra("firstTimeCam", true);
+ intent.putExtra("firstLogin", true);
if (action != null){
log("Action not NULL");
if (action.equals(Constants.ACTION_EXPORT_MASTER_KEY)){
@@ -2016,7 +2033,7 @@ else if(action.equals(Constants.ACTION_CANCEL_ACCOUNT)) {
}
else{
intent = new Intent(context,ManagerActivityLollipop.class);
- intent.putExtra("firstTimeCam", true);
+ intent.putExtra("firstLogin", true);
initialCam = true;
}
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 fcc3258ec55..c12d24d685f 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
@@ -338,10 +338,13 @@ 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 isStorageStatusDialogShown = false;
int orientationSaved;
+ float elevation = 0;
+
public enum FragmentTag {
CLOUD_DRIVE, OFFLINE, CAMERA_UPLOADS, MEDIA_UPLOADS, INBOX, INCOMING_SHARES, OUTGOING_SHARES, CONTACTS, RECEIVED_REQUESTS, SENT_REQUESTS, SETTINGS, MY_ACCOUNT, MY_STORAGE, SEARCH,
TRANSFERS, COMPLETED_TRANSFERS, RECENT_CHAT, RUBBISH_BIN, NOTIFICATIONS, UPGRADE_ACCOUNT, MONTHLY_ANUALLY, FORTUMO, CENTILI, CREDIT_CARD, TURN_ON_NOTIFICATIONS, EXPORT_RECOVERY_KEY;
@@ -442,7 +445,7 @@ public String getTitle(Context context) {
TransfersPageAdapter mTabsAdapterTransfers;
ViewPager viewPagerTransfers;
- boolean firstTime = true;
+ boolean firstTimeAfterInstallation = true;
// String pathNavigation = "/";
SearchView searchView;
boolean searchExpand = false;
@@ -464,7 +467,7 @@ public String getTitle(Context context) {
// private int orderOutgoing = MegaApiJava.ORDER_DEFAULT_ASC;
// private int orderIncoming = MegaApiJava.ORDER_DEFAULT_ASC;
- boolean firstTimeCam = false;
+ boolean firstLogin = false;
private boolean isGetLink = false;
private boolean isClearRubbishBin = false;
private boolean moveToRubbish = false;
@@ -541,7 +544,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;
@@ -553,7 +555,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;
@@ -622,7 +624,7 @@ public String getTitle(Context context) {
private ProgressBar verify2faProgressBar;
private RelativeLayout lostYourDeviceButton;
- private boolean isFirstTime = true;
+ private boolean isFirstTime2fa = true;
private boolean isErrorShown = false;
private boolean pinLongClick = false;
@@ -642,11 +644,16 @@ 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) {
+ int newStorageState =
+ intent.getIntExtra("state", MegaApiJava.STORAGE_STATE_GREEN);
+ checkStorageStatus(newStorageState, false);
+ updateAccountDetailsVisibleInfo();
+ return;
+ }
+
+ int actionType = intent.getIntExtra("actionType", -1);
if(actionType == Constants.UPDATE_GET_PRICING){
log("BROADCAST TO UPDATE AFTER GET PRICING");
@@ -1513,12 +1520,12 @@ else if (fromTakePicture==Constants.TAKE_PROFILE_PICTURE){
}
case Constants.REQUEST_WRITE_STORAGE:{
log("REQUEST_WRITE_STORAGE PERMISSIONS");
- if (firstTimeCam){
+ if (firstLogin){
log("The first time");
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
-// if (firstTimeCam){
-// firstTimeCam = false;
+// if (firstLogin){
+// firstLogin = false;
// }
if (fromTakePicture==Constants.TAKE_PICTURE_OPTION){
@@ -1621,7 +1628,7 @@ public void onSaveInstanceState(Bundle outState) {
outState.putLong("parentHandleSearch", parentHandleSearch);
outState.putLong("parentHandleInbox", parentHandleInbox);
outState.putSerializable("drawerItem", drawerItem);
- outState.putBoolean("firstTimeCam",firstTimeCam);
+ outState.putBoolean("firstLogin", firstLogin);
outState.putBoolean("isSearchEnabled", isSearchEnabled);
outState.putLongArray("searchDate",searchDate);
@@ -1685,6 +1692,9 @@ public void onSaveInstanceState(Bundle outState) {
outState.putBoolean("isEnable2FADialogShown", isEnable2FADialogShown);
outState.putInt("bottomNavigationCurrentItem", bottomNavigationCurrentItem);
outState.putBoolean("searchExpand", searchExpand);
+ outState.putFloat("elevation", abL.getElevation());
+ outState.putInt("storageState", storageState);
+ outState.putBoolean("isStorageStatusDialogShown", isStorageStatusDialogShown);
}
@Override
@@ -1719,7 +1729,7 @@ protected void onCreate(Bundle savedInstanceState) {
deepBrowserTreeOutgoing = savedInstanceState.getInt("deepBrowserTreeOutgoing", 0);
isSearchEnabled = savedInstanceState.getBoolean("isSearchEnabled");
searchDate = savedInstanceState.getLongArray("searchDate");
- firstTimeCam = savedInstanceState.getBoolean("firstTimeCam");
+ firstLogin = savedInstanceState.getBoolean("firstLogin");
drawerItem = (DrawerItem) savedInstanceState.getSerializable("drawerItem");
indexShares = savedInstanceState.getInt("indexShares", indexShares);
log("savedInstanceState -> indexShares: "+indexShares);
@@ -1742,6 +1752,9 @@ protected void onCreate(Bundle savedInstanceState) {
isEnable2FADialogShown = savedInstanceState.getBoolean("isEnable2FADialogShown", false);
bottomNavigationCurrentItem = savedInstanceState.getInt("bottomNavigationCurrentItem", -1);
searchExpand = savedInstanceState.getBoolean("searchExpand", false);
+ elevation = savedInstanceState.getFloat("elevation", 0);
+ storageState = savedInstanceState.getInt("storageState", -1);
+ isStorageStatusDialogShown = savedInstanceState.getBoolean("isStorageStatusDialogShown", false);
}
else{
log("Bundle is NULL");
@@ -1758,10 +1771,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);
@@ -1871,7 +1895,7 @@ else if (newIntent.getAction().equals(Constants.ACTION_CANCEL_CAM_SYNC)){
prefs = dbH.getPreferences();
if (prefs == null){
- firstTime = true;
+ firstTimeAfterInstallation = true;
isList=true;
isListCameraUploads=false;
isSmallGridCameraUploads = false;
@@ -1879,10 +1903,10 @@ else if (newIntent.getAction().equals(Constants.ACTION_CANCEL_CAM_SYNC)){
else{
if (prefs.getFirstTime() == null){
- firstTime = true;
+ firstTimeAfterInstallation = true;
isListCameraUploads=false;
}else{
- firstTime = Boolean.parseBoolean(prefs.getFirstTime());
+ firstTimeAfterInstallation = Boolean.parseBoolean(prefs.getFirstTime());
}
if (prefs.getPreferredViewList() == null){
isList = true;
@@ -2201,6 +2225,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(false);
+ }
}
else{
log("Offline mode: Do not init, chat already initialized");
@@ -2743,8 +2775,8 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){
switch (accountType){
case 0:{
- log("intent firstTime==true");
- firstTimeCam = true;
+ log("intent firstTimeAfterInstallation==true");
+ firstLogin = true;
drawerItem = DrawerItem.CAMERA_UPLOADS;
setIntent(null);
displayedAccountType = -1;
@@ -2785,9 +2817,9 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){
}
}
else{
- firstTimeCam = getIntent().getBooleanExtra("firstTimeCam", firstTimeCam);
- if (firstTimeCam){
- log("intent firstTimeCam==true");
+ firstLogin = getIntent().getBooleanExtra("firstLogin", firstLogin);
+ if (firstLogin){
+ log("intent firstLogin==true");
drawerItem = DrawerItem.CAMERA_UPLOADS;
setIntent(null);
}
@@ -2804,15 +2836,15 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){
//reset flag to fix incorrect view loaded when orientation changes
getIntent().removeExtra("newAccount");
getIntent().removeExtra("upgradeAccount");
- firstTimeCam = intentRec.getBooleanExtra("firstTimeCam", firstTimeCam);
+ firstLogin = intentRec.getBooleanExtra("firstLogin", firstLogin);
if(upgradeAccount){
drawerLayout.closeDrawer(Gravity.LEFT);
int accountType = getIntent().getIntExtra("accountType", 0);
switch (accountType){
case Constants.FREE:{
- log("intent firstTime==true");
- firstTimeCam = true;
+ log("intent firstTimeAfterInstallation==true");
+ firstLogin = true;
drawerItem = DrawerItem.CAMERA_UPLOADS;
displayedAccountType = -1;
setIntent(null);
@@ -2853,19 +2885,19 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){
}
}
else{
- if (firstTimeCam) {
+ if (firstLogin) {
log("intent firstTimeCam2==true");
if (prefs != null){
if (prefs.getCamSyncEnabled() != null){
- firstTimeCam = false;
+ firstLogin = false;
}
else{
- firstTimeCam = true;
+ firstLogin = true;
drawerItem = DrawerItem.CAMERA_UPLOADS;
}
}
else{
- firstTimeCam = true;
+ firstLogin = true;
drawerItem = DrawerItem.CAMERA_UPLOADS;
}
setIntent(null);
@@ -2882,7 +2914,7 @@ else if (getIntent().getAction().equals(Constants.ACTION_REFRESH_STAGING)){
drawerLayout.closeDrawer(Gravity.LEFT);
}
- showStorageAlmostFullDialog();
+ checkStorageStatus(true);
//INITIAL FRAGMENT
if(selectDrawerItemPending){
@@ -4176,7 +4208,7 @@ protected void onDestroy(){
megaChatApi.removeChatCallListener(this);
}
- showStorageAlmostFullDialog = true;
+ isStorageStatusDialogShown = false;
LocalBroadcastManager.getInstance(this).unregisterReceiver(receiverUpdatePosition);
LocalBroadcastManager.getInstance(this).unregisterReceiver(updateMyAccountReceiver);
@@ -4250,7 +4282,7 @@ public void selectDrawerItemCloudDrive(){
}
replaceFragment(fbFLol, FragmentTag.CLOUD_DRIVE.getTag());
- if (!firstTime){
+ if (!firstTimeAfterInstallation){
log("Its NOT first time");
drawerLayout.closeDrawer(Gravity.LEFT);
@@ -4270,7 +4302,7 @@ public void selectDrawerItemCloudDrive(){
//Fill the contacts DB
FillDBContactsTask fillDBContactsTask = new FillDBContactsTask(this);
fillDBContactsTask.execute();
- firstTime = false;
+ firstTimeAfterInstallation = false;
dbH.setFirstTime(false);
}
}
@@ -4644,6 +4676,7 @@ public void showOnlineMode(){
// } updateAccountDetailsVisibleInfo();
updateAccountDetailsVisibleInfo();
+ checkStorageStatus(false);
} else {
log("showOnlineMode - Root is NULL");
if (getApplicationContext() != null) {
@@ -5025,7 +5058,6 @@ public void selectDrawerItemContacts (){
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- log("onPageScrolled");
indexContacts = position;
}
@@ -5209,7 +5241,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());
@@ -5348,7 +5380,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{
@@ -6251,7 +6283,7 @@ public boolean onQueryTextChange(String newText) {
addMenuItem.setVisible(true);
log("createFolderMenuItem.setVisible_14");
createFolderMenuItem.setVisible(true);
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6259,7 +6291,7 @@ public boolean onQueryTextChange(String newText) {
rubbishBinMenuItem.setVisible(true);
upgradeAccountMenuItem.setVisible(true);
importLinkMenuItem.setVisible(true);
- if(!firstTimeCam){
+ if(!firstLogin){
takePicture.setVisible(true);
}else{
takePicture.setVisible(false);
@@ -6306,7 +6338,7 @@ public boolean onQueryTextChange(String newText) {
else if(drawerItem == DrawerItem.RUBBISH_BIN){
log("onCreateOptionsMenuLollipop: in Rubbish");
//Show
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6363,7 +6395,7 @@ else if(drawerItem == DrawerItem.RUBBISH_BIN){
else if (drawerItem == DrawerItem.SAVED_FOR_OFFLINE){
log("onCreateOptionsMenuLollipop: in Offline");
//Show
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6422,7 +6454,7 @@ else if (drawerItem == DrawerItem.CAMERA_UPLOADS){
takePicture.setVisible(false);
if(firstNavigationLevel){
- if(!firstTimeCam){
+ if(!firstLogin){
searchByDate.setVisible(true);
}else{
searchByDate.setVisible(false);
@@ -6441,7 +6473,7 @@ else if (drawerItem == DrawerItem.CAMERA_UPLOADS){
addMenuItem.setVisible(false);
refreshMenuItem.setVisible(false);
unSelectMenuItem.setVisible(false);
- if(!firstTimeCam){
+ if(!firstLogin){
searchMenuItem.setVisible(true);
thumbViewMenuItem.setVisible(true);
}else{
@@ -6479,7 +6511,7 @@ else if (drawerItem == DrawerItem.CAMERA_UPLOADS){
gridSmallLargeMenuItem.setIcon(Util.mutateIcon(this, R.drawable.ic_menu_gridview_small, R.color.black));
}
- if(!firstTimeCam) {
+ if(!firstLogin) {
gridSmallLargeMenuItem.setVisible(true);
}else{
gridSmallLargeMenuItem.setVisible(false);
@@ -6505,7 +6537,7 @@ else if (drawerItem == DrawerItem.MEDIA_UPLOADS){
takePicture.setVisible(false);
if(firstNavigationLevel){
- if(!firstTimeCam){
+ if(!firstLogin){
searchByDate.setVisible(true);
}else{
searchByDate.setVisible(false);
@@ -6524,7 +6556,7 @@ else if (drawerItem == DrawerItem.MEDIA_UPLOADS){
addMenuItem.setVisible(false);
refreshMenuItem.setVisible(false);
unSelectMenuItem.setVisible(false);
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6561,7 +6593,7 @@ else if (drawerItem == DrawerItem.MEDIA_UPLOADS){
gridSmallLargeMenuItem.setIcon(Util.mutateIcon(this, R.drawable.ic_menu_gridview_small, R.color.black));
}
- if(!firstTimeCam) {
+ if(!firstLogin) {
gridSmallLargeMenuItem.setVisible(true);
}else{
gridSmallLargeMenuItem.setVisible(false);
@@ -6602,7 +6634,7 @@ else if (drawerItem == DrawerItem.INBOX){
}
searchMenuItem.setVisible(true);
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6639,7 +6671,7 @@ else if (drawerItem == DrawerItem.SHARED_ITEMS){
if (index == 0) {
inSFLol = (IncomingSharesFragmentLollipop) sharesPageAdapter.instantiateItem(viewPagerShares, 0);
log("onCreateOptionsMenuLollipop: in Incoming");
- if (!firstTimeCam) {
+ if (!firstLogin) {
thumbViewMenuItem.setVisible(true);
}
else {
@@ -6723,7 +6755,7 @@ else if (index == 1) {
outSFLol = (OutgoingSharesFragmentLollipop) sharesPageAdapter.instantiateItem(viewPagerShares, 1);
log("onCreateOptionsMenuLollipop: in Outgoing");
- if (!firstTimeCam) {
+ if (!firstLogin) {
thumbViewMenuItem.setVisible(true);
}
else {
@@ -6793,7 +6825,7 @@ else if (drawerItem == DrawerItem.CONTACTS){
//Show
addContactMenuItem.setVisible(true);
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -6975,7 +7007,7 @@ else if (drawerItem == DrawerItem.SEARCH){
if(sFLol != null && sFLol.getNodes()!=null){
if(sFLol.getNodes().size()!=0){
selectMenuItem.setVisible(true);
- if(!firstTimeCam){
+ if(!firstLogin){
thumbViewMenuItem.setVisible(true);
}else{
thumbViewMenuItem.setVisible(false);
@@ -7153,7 +7185,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);
@@ -8021,7 +8053,7 @@ else if (drawerItem == DrawerItem.MEDIA_UPLOADS){
}
else{
thumbViewMenuItem.setTitle(getString(R.string.action_list));
- if(!firstTimeCam) {
+ if(!firstLogin) {
gridSmallLargeMenuItem.setVisible(true);
}else{
gridSmallLargeMenuItem.setVisible(false);
@@ -8044,7 +8076,7 @@ else if (drawerItem == DrawerItem.MEDIA_UPLOADS){
}
else{
thumbViewMenuItem.setTitle(getString(R.string.action_list));
- if(!firstTimeCam) {
+ if(!firstLogin) {
gridSmallLargeMenuItem.setVisible(true);
}else{
gridSmallLargeMenuItem.setVisible(false);
@@ -9520,8 +9552,8 @@ else if (item == MEDIA_UPLOADS_BNV) {
}
void isFirstTimeCam() {
- if(firstTimeCam){
- firstTimeCam = false;
+ if(firstLogin){
+ firstLogin = false;
dbH.setCamSyncEnabled(false);
bottomNavigationCurrentItem = CLOUD_DRIVE_BNV;
}
@@ -9538,8 +9570,21 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.bottom_navigation_item_cloud_drive: {
- drawerItem = DrawerItem.CLOUD_DRIVE;
- setBottomNavigationMenuItemChecked(CLOUD_DRIVE_BNV);
+ if (drawerItem == DrawerItem.CLOUD_DRIVE) {
+ long rootHandle = megaApi.getRootNode().getHandle();
+ if (parentHandleBrowser != -1 && parentHandleBrowser != rootHandle) {
+ parentHandleBrowser = rootHandle;
+ refreshFragment(FragmentTag.CLOUD_DRIVE.getTag());
+ fbFLol = (FileBrowserFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.CLOUD_DRIVE.getTag());
+ if (fbFLol != null) {
+ fbFLol.scrollToFirstPosition();
+ }
+ }
+ }
+ else {
+ drawerItem = DrawerItem.CLOUD_DRIVE;
+ setBottomNavigationMenuItemChecked(CLOUD_DRIVE_BNV);
+ }
break;
}
case R.id.bottom_navigation_item_offline: {
@@ -10350,7 +10395,7 @@ public void afterTextChanged(Editable s) {
secondPin.requestFocus();
secondPin.setCursorVisible(true);
- if (isFirstTime && !pinLongClick){
+ if (isFirstTime2fa && !pinLongClick){
secondPin.setText("");
thirdPin.setText("");
fourthPin.setText("");
@@ -10393,7 +10438,7 @@ public void afterTextChanged(Editable s) {
thirdPin.requestFocus();
thirdPin.setCursorVisible(true);
- if (isFirstTime && !pinLongClick) {
+ if (isFirstTime2fa && !pinLongClick) {
thirdPin.setText("");
fourthPin.setText("");
fifthPin.setText("");
@@ -10435,7 +10480,7 @@ public void afterTextChanged(Editable s) {
fourthPin.requestFocus();
fourthPin.setCursorVisible(true);
- if (isFirstTime && !pinLongClick) {
+ if (isFirstTime2fa && !pinLongClick) {
fourthPin.setText("");
fifthPin.setText("");
sixthPin.setText("");
@@ -10476,7 +10521,7 @@ public void afterTextChanged(Editable s) {
fifthPin.requestFocus();
fifthPin.setCursorVisible(true);
- if (isFirstTime && !pinLongClick) {
+ if (isFirstTime2fa && !pinLongClick) {
fifthPin.setText("");
sixthPin.setText("");
}
@@ -10516,7 +10561,7 @@ public void afterTextChanged(Editable s) {
sixthPin.requestFocus();
sixthPin.setCursorVisible(true);
- if (isFirstTime && !pinLongClick) {
+ if (isFirstTime2fa && !pinLongClick) {
sixthPin.setText("");
}
else if (pinLongClick) {
@@ -10688,7 +10733,7 @@ void verifyQuitError(){
void verifyShowError(){
log("Pin not correct verifyShowError");
- isFirstTime = false;
+ isFirstTime2fa = false;
isErrorShown = true;
pinError.setVisibility(View.VISIBLE);
firstPin.setTextColor(ContextCompat.getColor(this, R.color.login_warning));
@@ -12413,7 +12458,7 @@ public void secondaryMediaUploadsClicked(){
public void setInitialCloudDrive (){
drawerItem = DrawerItem.CLOUD_DRIVE;
setBottomNavigationMenuItemChecked(CLOUD_DRIVE_BNV);
- firstTime = true;
+ //firstTimeAfterInstallation = true;
selectDrawerItemLollipop(drawerItem);
}
@@ -12534,48 +12579,6 @@ else if(dialog instanceof ContactsBottomSheetDialogFragment){
return -1;
}
- private void showOverquotaAlert(boolean prewarning){
- log("showOverquotaAlert: prewarning: "+prewarning);
-
- 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));
- dbH.setCamSyncEnabled(false);
- }
-
- 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) {
- //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();
- overquotaDialog=null;
- }
- });
-
- overquotaDialog = builder.create();
- overquotaDialog.setCanceledOnTouchOutside(false);
- }
-
- overquotaDialog.show();
- }
-
public void updateAccountDetailsVisibleInfo(){
log("updateAccountDetailsVisibleInfo");
if(isFinishing()){
@@ -12641,25 +12644,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;
}
}
@@ -14590,149 +14590,249 @@ public void onClick(View v) {
alertDialogTransferOverquota.show();
}
+ /**
+ * 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);
+ }
+
+ /**
+ * 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");
+ 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();
+ }
+ }
+ storageState = newStorageState;
+ break;
+
+ case MegaApiJava.STORAGE_STATE_ORANGE:
+ log("STORAGE STATE ORANGE");
+ if (onCreate && isStorageStatusDialogShown) {
+ isStorageStatusDialogShown = false;
+ showStorageAlmostFullDialog();
+ } else if (newStorageState > storageState) {
+ showStorageAlmostFullDialog();
+ }
+ storageState = newStorageState;
+ break;
+
+ case MegaApiJava.STORAGE_STATE_RED:
+ log("STORAGE STATE RED");
+ 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(((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);
-
- TextView title = (TextView) dialogView.findViewById(R.id.storage_almost_full_title);
- title.setText(getString(R.string.action_upgrade_account));
+ if(isStorageStatusDialogShown){
+ log("Storage status dialog already shown");
+ return;
+ }
- 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_status_dialog_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_status_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));
+ ImageView image = (ImageView) dialogView.findViewById(R.id.image_storage_status);
+ TextView text = (TextView) dialogView.findViewById(R.id.text_storage_status);
- verticalDismissButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- }
+ switch (storageState) {
+ case MegaApiJava.STORAGE_STATE_GREEN:
+ log("STORAGE STATE GREEN");
+ return;
- });
+ case MegaApiJava.STORAGE_STATE_ORANGE:
+ image.setImageResource(R.drawable.ic_storage_almost_full);
+ text.setText(getString(R.string.text_almost_full_warning));
+ break;
- achievementsButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- log("Go to achievements section");
- navigateToAchievements();
- }
+ case MegaApiJava.STORAGE_STATE_RED:
+ image.setImageResource(R.drawable.ic_storage_full);
+ text.setText(getString(R.string.text_storage_full_warning));
+ break;
- });
+ default:
+ log("STORAGE STATE INVALID VALUE: " + storageState);
+ return;
+ }
- verticalActionButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- navigateToUpgradeAccount();
- }
+ if (overquotaAlert) {
+ if (!preWarning)
+ title.setText(getString(R.string.overquota_alert_title));
- });
- }
- else{
- horizontalButtonsLayout.setVisibility(View.VISIBLE);
- verticalButtonsLayout.setVisibility(View.GONE);
- horizontalActionButton.setText(getString(R.string.button_plans_almost_full_warning));
+ text.setText(getString(preWarning ? R.string.pre_overquota_alert_text :
+ R.string.overquota_alert_text));
+ }
- horizontalDismissButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- }
- });
+ LinearLayout horizontalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.horizontal_buttons_storage_status_layout);
+ LinearLayout verticalButtonsLayout = (LinearLayout) dialogView.findViewById(R.id.vertical_buttons_storage_status_layout);
- horizontalActionButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- 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);
+ final OnClickListener achievementsClickListener = new OnClickListener(){
+ public void onClick(View v) {
+ alertDialogStorageStatus.dismiss();
+ isStorageStatusDialogShown = false;
+ log("Go to achievements section");
+ navigateToAchievements();
+ }
+ };
- 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));
+ final OnClickListener customPlanClickListener = new OnClickListener(){
+ public void onClick(View v) {
+ alertDialogStorageStatus.dismiss();
+ isStorageStatusDialogShown = false;
+ askForCustomizedPlan();
+ }
+ };
- horizontalActionButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- askForCustomizedPlan();
- }
+ 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);
- });
- }
- 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);
- horizontalActionButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- navigateToUpgradeAccount();
- }
+ Button achievementsButton = (Button) dialogView.findViewById(R.id.vertical_storage_status_button_achievements);
+ achievementsButton.setOnClickListener(achievementsClickListener);
- });
+ 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));
}
-
- horizontalDismissButton.setOnClickListener(new OnClickListener(){
- public void onClick(View v) {
- alertDialogStorageAlmostFull.dismiss();
- }
-
- });
-
}
+ 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;
- alertDialogStorageAlmostFull = dialogBuilder.create();
+ 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;
- alertDialogStorageAlmostFull.setCancelable(false);
- alertDialogStorageAlmostFull.setCanceledOnTouchOutside(false);
- alertDialogStorageAlmostFull.show();
- }
- else{
- log("Storage almost full dialog already shown");
- }
+ 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{
- if(((MegaApplication) getApplication()).getMyAccountInfo().getAccountType()==MegaAccountDetails.ACCOUNT_TYPE_FREE){
- log("usedSpacePerc<95");
- if(Util.showMessageRandom()){
- log("Random: TRUE");
- showProPanel();
- }
- }
+ horizontalButtonsLayout.setVisibility(View.VISIBLE);
+ verticalButtonsLayout.setVisibility(View.GONE);
}
+
+ alertDialogStorageStatus = dialogBuilder.create();
+ alertDialogStorageStatus.setCancelable(false);
+ alertDialogStorageStatus.setCanceledOnTouchOutside(false);
+
+ isStorageStatusDialogShown = true;
+
+ alertDialogStorageStatus.show();
}
public void askForCustomizedPlan(){
@@ -17215,10 +17315,15 @@ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, Meg
log("onTransferTemporaryError: " + transfer.getFileName() + " - " + transfer.getTag());
if(e.getErrorCode() == MegaError.API_EOVERQUOTA){
- log("API_EOVERQUOTA error!!");
- fbFLol = (FileBrowserFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.CLOUD_DRIVE.getTag());
- if (fbFLol != null){
- fbFLol.setOverviewLayout();
+ if (e.getValue() != 0) {
+ log("TRANSFER OVERQUOTA ERROR: " + e.getErrorCode());
+ fbFLol = (FileBrowserFragmentLollipop) getSupportFragmentManager().findFragmentByTag(FragmentTag.CLOUD_DRIVE.getTag());
+ if (fbFLol != null){
+ fbFLol.setOverviewLayout();
+ }
+ }
+ else {
+ log("STORAGE OVERQUOTA ERROR: " + e.getErrorCode());
}
}
}
@@ -17260,11 +17365,11 @@ public void setSmallGridCameraUploads(boolean isSmallGridCameraUploads) {
this.isSmallGridCameraUploads = isSmallGridCameraUploads;
}
- public boolean getFirstTimeCam() {
- return firstTimeCam;
+ public boolean getFirstLogin() {
+ return firstLogin;
}
- public void setFirstTimeCam(boolean flag){
- firstTimeCam = flag;
+ public void setFirstLogin(boolean flag){
+ firstLogin = flag;
}
public void setListCameraUploads(boolean isListCameraUploads) {
@@ -17873,7 +17978,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);
}
}
}
@@ -17925,7 +18030,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() {
@@ -18030,10 +18141,19 @@ public void setDrawerLockMode (boolean locked) {
}
}
- public void changeActionBarElevation(boolean whitElevation){
+ public void changeActionBarElevation(boolean withElevation){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (whitElevation) {
+ if (withElevation) {
abL.setElevation(Util.px2dp(4, outMetrics));
+ if (elevation > 0) {
+ elevation = 0;
+ abL.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ abL.setElevation(Util.px2dp(4, outMetrics));
+ }
+ }, 100);
+ }
}
else {
abL.setElevation(0);
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 a3ec4505860..b37ad4bc638 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
@@ -159,6 +159,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;
@@ -256,6 +258,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;
@@ -915,6 +919,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
@@ -990,6 +996,7 @@ protected void onPostExecute(InputStream inputStream) {
.scrollHandle(defaultScrollHandle)
.spacing(10) // in dp
.onPageError(PdfViewerActivityLollipop.this)
+ .password(password)
.load();
} catch (Exception e) {
@@ -1001,7 +1008,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());
}
@@ -1019,6 +1037,7 @@ private void loadLocalPDF() {
.scrollHandle(defaultScrollHandle)
.spacing(10) // in dp
.onPageError(this)
+ .password(password)
.load();
} catch (Exception e) {
@@ -2525,6 +2544,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")) {
@@ -2957,15 +2979,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();
+ }
+ }
}
}
}
@@ -3175,7 +3199,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/java/mega/privacy/android/app/lollipop/TwoFactorAuthenticationActivity.java b/app/src/main/java/mega/privacy/android/app/lollipop/TwoFactorAuthenticationActivity.java
index 49a87bd54ab..354b369d3c7 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/TwoFactorAuthenticationActivity.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/TwoFactorAuthenticationActivity.java
@@ -193,7 +193,7 @@ protected void onCreate(Bundle savedInstanceState) {
scanOrCopyIsShown = savedInstanceState.getBoolean("scanOrCopyIsShown", false);
isEnabled2FA = savedInstanceState.getBoolean("isEnabled2FA", false);
isErrorShown = savedInstanceState.getBoolean("isErrorShown", false);
- firstTime = savedInstanceState.getBoolean("firstTime", true);
+ firstTime = savedInstanceState.getBoolean("firstTimeAfterInstallation", true);
rkSaved = savedInstanceState.getBoolean("rkSaved", false);
seed = savedInstanceState.getString("seed");
arraySeed = savedInstanceState.getStringArrayList("arraySeed");
@@ -903,7 +903,7 @@ protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean("scanOrCopyIsShown", scanOrCopyIsShown);
outState.putBoolean("isEnabled2FA", isEnabled2FA);
outState.putBoolean("isErrorShown", isErrorShown);
- outState.putBoolean("firstTime", firstTime);
+ outState.putBoolean("firstTimeAfterInstallation", firstTime);
outState.putBoolean("rkSaved", rkSaved);
outState.putBoolean("isNoAppsDialogShown", isNoAppsDialogShown);
outState.putBoolean("isHelpDialogShown", isHelpDialogShown);
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..e0e3c2a0705 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;
@@ -71,7 +72,8 @@ public class MegaContactsLollipopAdapter extends RecyclerView.Adapter _contacts, RecyclerView _listView, int adapterType) {
this.context = _context;
@@ -107,7 +109,7 @@ public ViewHolderContacts(View v) {
public TextView contactInitialLetter;
// ImageView imageView;
TextView textViewContactName;
- TextView textViewContent;
+ MarqueeTextView textViewContent;
RelativeLayout itemLayout;
public String contactMail;
}
@@ -139,7 +141,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);
@@ -153,8 +155,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 = (TextView) v.findViewById(R.id.contact_list_content);
- holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.contact_list_three_dots_layout);
+ holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.contact_list_content);
+ 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);
@@ -185,7 +188,8 @@ 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 = (MarqueeTextView) v.findViewById(R.id.contact_grid_content);
+ 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);
@@ -214,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 = (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);
@@ -228,7 +232,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
@@ -253,7 +256,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);
@@ -267,7 +270,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);
@@ -321,39 +323,71 @@ 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());
+ holder.textViewContent.isMarqueeIsNecessary(context);
+ }
}
}
}
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);
+ }
+
+ 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 {
@@ -361,7 +395,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));
}
}
@@ -418,13 +452,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);
}
@@ -488,6 +516,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);
}
}
}
@@ -624,6 +653,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);
}
}
}
@@ -634,8 +664,6 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){
holder.contactStateIcon.setVisibility(View.GONE);
}
-
-
holder.textViewContactName.setText(contact.getFullName());
createDefaultAvatar(holder, contact);
@@ -721,34 +749,57 @@ 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());
+ holder.textViewContent.isMarqueeIsNecessary(context);
+ }
}
}
}
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);
}
holder.textViewContactName.setText(contact.getFullName());
@@ -866,12 +917,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/adapters/MegaNodeAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaNodeAdapter.java
index 4edd741efbc..26651e7c4d0 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
@@ -46,7 +46,6 @@
import mega.privacy.android.app.lollipop.managerSections.OutgoingSharesFragmentLollipop;
import mega.privacy.android.app.lollipop.managerSections.RubbishBinFragmentLollipop;
import mega.privacy.android.app.lollipop.managerSections.SearchFragmentLollipop;
-import mega.privacy.android.app.lollipop.megachat.NodeAttachmentActivityLollipop;
import mega.privacy.android.app.utils.Constants;
import mega.privacy.android.app.utils.MegaApiUtils;
import mega.privacy.android.app.utils.OfflineUtils;
@@ -142,106 +141,28 @@ 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);
- }
+ startAnimation(pos, putOrDeletePostion(pos));
}
public void toggleSelection(int pos) {
log("toggleSelection: " + pos);
+ startAnimation(pos, putOrDeletePostion(pos));
+ }
+ boolean putOrDeletePostion(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;
}
- notifyItemChanged(pos);
+ }
+
+ void startAnimation (final int pos, final boolean delete) {
+
if (adapterType == MegaNodeAdapter.ITEM_VIEW_TYPE_LIST) {
log("adapter type is LIST");
MegaNodeAdapter.ViewHolderBrowserList view = (MegaNodeAdapter.ViewHolderBrowserList)listFragment.findViewHolderForLayoutPosition(pos);
@@ -251,31 +172,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) {
- 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(pos);
}
}
@@ -284,69 +190,45 @@ 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(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(pos);
+ }
}
@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();
+ notifyItemChanged(pos);
}
@Override
@@ -354,36 +236,41 @@ public void onAnimationRepeat(Animation animation) {
}
});
- if (view.folderLayout.getVisibility() == View.VISIBLE) {
- view.imageViewIcon.startAnimation(flipAnimation);
+ if (isFile) {
+ view.fileGridSelected.startAnimation(flipAnimation);
}
else {
- view.fileGridSelected.startAnimation(flipAnimation);
+ view.imageViewIcon.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(pos);
+ }
+ }
+ }
+
+ 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();
}
}
}
@@ -491,7 +378,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.
@@ -567,8 +454,8 @@ public MegaNodeAdapter(Context _context, Object fragment, ArrayList _n
}
public void setNodes(ArrayList nodes) {
- log("setNodes");
this.nodes = insertPlaceHolderNode(nodes);
+ log("setNodes size: "+this.nodes.size());
// contentTextFragment.setText(getInfoFolder(node));
notifyDataSetChanged();
}
@@ -657,7 +544,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);
@@ -703,27 +590,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);
@@ -742,7 +614,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,12 +623,11 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) {
holder.thumbLayout.setBackgroundColor(Color.TRANSPARENT);
if (type == Constants.INCOMING_SHARES_ADAPTER) {
-
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);
}
//Show the owner of the shared folder
ArrayList sharesIncoming = megaApi.getInSharesList();
@@ -782,12 +653,11 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) {
}
}
} else if (type == Constants.OUTGOING_SHARES_ADAPTER) {
-
if (node.isOutShare() || megaApi.isPendingShare(node)) {
- setFolderSelected(holder,position,R.drawable.ic_folder_outgoing);
+ setFolderGridSelected(holder,position,R.drawable.ic_folder_outgoing);
}
else {
- setFolderSelected(holder,position,R.drawable.ic_folder);
+ setFolderGridSelected(holder,position,R.drawable.ic_folder);
}
//Show the number of contacts who shared the folder
ArrayList sl = megaApi.getOutShares(node);
@@ -798,23 +668,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()) {
@@ -833,18 +703,6 @@ public void onBindViewHolderGrid(ViewHolderBrowserGrid holder,int position) {
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);
@@ -871,77 +729,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
@@ -963,8 +800,15 @@ else if (inbox){
}
}
- private void setFolderSelected(ViewHolderBrowserGrid holder,int position,int folderDrawableResId) {
- if (multipleSelect && isItemChecked(position)) {
+ 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);
+ }
+
+ 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());
@@ -977,6 +821,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);
@@ -1021,43 +881,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){
@@ -1082,33 +908,12 @@ 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);
- 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.isInShare()) {
- holder.imageView.setImageResource(R.drawable.ic_folder_incoming_list);
- }
- else {
- holder.imageView.setImageResource(R.drawable.ic_folder_list);
- }
- }
+ if (node.isInShare()) {
+ setFolderListSelected(holder, position, R.drawable.ic_folder_incoming_list);
+ }
+ else {
+ setFolderListSelected(holder, position, R.drawable.ic_folder_list);
}
//Show the owner of the shared folder
@@ -1153,34 +958,11 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) {
}
} else if (type == Constants.OUTGOING_SHARES_ADAPTER) {
- if (!multipleSelect) {
- holder.itemLayout.setBackgroundColor(Color.WHITE);
- if (node.isOutShare() || megaApi.isPendingShare(node)) {
- holder.imageView.setImageResource(R.drawable.ic_folder_outgoing_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 {
- holder.imageView.setImageResource(R.drawable.ic_folder_list);
- }
- }
+ if (node.isOutShare() || megaApi.isPendingShare(node)) {
+ setFolderListSelected(holder, position, R.drawable.ic_folder_outgoing_list);
+ }
+ else {
+ setFolderListSelected(holder, position, R.drawable.ic_folder_list);
}
//Show the number of contacts who shared the folder
ArrayList sl = megaApi.getOutShares(node);
@@ -1190,76 +972,30 @@ 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);
- }
+ 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 {
+ if (((ManagerActivityLollipop) context).isCameraUploads(node)) {
+ setFolderListSelected(holder, position, R.drawable.ic_folder_image_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);
- }
- }
+ 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 {
@@ -1275,7 +1011,7 @@ public void onBindViewHolderList(ViewHolderBrowserList holder,int position) {
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());
@@ -1575,8 +1311,6 @@ public void onClick(View v) {
((FolderLinkActivityLollipop)context).itemClick(currentPosition,dimens,imageView);
} else if (type == Constants.SEARCH_ADAPTER) {
((SearchFragmentLollipop)fragment).itemClick(currentPosition,dimens,imageView);
- } else if (type == Constants.NODE_ATTACHMENT_ADAPTER) {
- log("Node attachment adapter");
} else {
log("layout FileBrowserFragmentLollipop!");
((FileBrowserFragmentLollipop)fragment).itemClick(currentPosition,dimens,imageView);
@@ -1600,7 +1334,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) {
@@ -1628,8 +1362,6 @@ private void threeDotsClicked(int currentPosition,MegaNode n) {
((FolderLinkActivityLollipop)context).showOptionsPanel(n);
} else if(type==Constants.CONTACT_SHARED_FOLDER_ADAPTER){
((ContactSharedFolderFragment) fragment).showOptionsPanel(n);
- }else if (type == Constants.NODE_ATTACHMENT_ADAPTER) {
- ((NodeAttachmentActivityLollipop)context).showOptionsPanel(n);
} else {
((ManagerActivityLollipop)context).showNodeOptionsPanel(n);
}
@@ -1670,8 +1402,6 @@ public boolean onLongClick(View view) {
((SearchFragmentLollipop)fragment).activateActionMode();
((SearchFragmentLollipop)fragment).itemClick(currentPosition,null,null);
}
- } else if (type == Constants.NODE_ATTACHMENT_ADAPTER) {
- log("NODE_ATTACHMENT_ADAPTER - no multiselect");
} else {
log("click layout FileBrowserFragmentLollipop!");
((FileBrowserFragmentLollipop)fragment).activateActionMode();
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..7f9c6490b21 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
@@ -251,7 +251,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
@@ -369,7 +369,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
@@ -488,7 +488,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
@@ -547,7 +547,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
@@ -664,7 +664,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_IGNORED: {
@@ -722,7 +722,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_ACCEPTED:{
@@ -838,7 +838,7 @@ public void onBindViewHolder(ViewHolderNotifications holder, int position) {
}
}
- holder.itemLayout.setOnClickListener(this);
+ holder.itemLayout.setOnClickListener(null);
break;
}
case MegaUserAlert.TYPE_NEWSHARE:{
@@ -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/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/adapters/MegaOfflineLollipopAdapter.java
index df6b40b016d..d3874978e47 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;
@@ -115,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;
@@ -182,7 +182,7 @@ protected void onPostExecute(Bitmap thumb){
}else if(getAdapterType() == MegaOfflineLollipopAdapter.ITEM_VIEW_TYPE_GRID){
holder.iconView.setVisibility(View.GONE);
holder.imageView.setVisibility(View.VISIBLE);
- thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, thumb, 3);
+ thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, thumb, 2);
}
holder.imageView.setImageBitmap(thumb);
Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in);
@@ -192,36 +192,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 +221,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 +241,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 +284,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 +347,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++) {
@@ -535,7 +517,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);
@@ -743,16 +724,14 @@ 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)) {
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;
@@ -760,7 +739,7 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){
if (currentFile.exists()){
thumb = ThumbnailUtils.getThumbnailFromCache(Long.parseLong(currentNode.getHandle()));
if (thumb != null){
- thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, thumb, 3);
+ thumb = ThumbnailUtilsLollipop.getRoundedRectBitmap(context, thumb, 2);
holder.imageView.setImageBitmap(thumb);
holder.imageView.setVisibility(View.VISIBLE);
holder.iconView.setVisibility(View.GONE);
@@ -1036,7 +1015,7 @@ else if(currentNode.getOrigin()==MegaOffline.INBOX){
@Override
public int getItemCount() {
log("getItemCount");
- return mOffList.size();
+ return mOffList.size() - placeholderCount;
}
public int getItemCountWithoutRK(){
@@ -1120,7 +1099,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/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/java/mega/privacy/android/app/lollipop/controllers/ChatController.java b/app/src/main/java/mega/privacy/android/app/lollipop/controllers/ChatController.java
index 750363cfa41..e5607af405d 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
@@ -33,6 +33,7 @@
import mega.privacy.android.app.lollipop.ManagerActivityLollipop;
import mega.privacy.android.app.lollipop.PdfViewerActivityLollipop;
import mega.privacy.android.app.lollipop.ZipBrowserActivityLollipop;
+import mega.privacy.android.app.lollipop.listeners.ChatImportToForwardListener;
import mega.privacy.android.app.lollipop.megachat.AndroidMegaChatMessage;
import mega.privacy.android.app.lollipop.megachat.ArchivedChatsActivity;
import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop;
@@ -40,7 +41,7 @@
import mega.privacy.android.app.lollipop.megachat.ChatFullScreenImageViewer;
import mega.privacy.android.app.lollipop.megachat.ChatItemPreferences;
import mega.privacy.android.app.lollipop.megachat.GroupChatInfoActivityLollipop;
-import mega.privacy.android.app.lollipop.megachat.NodeAttachmentActivityLollipop;
+import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity;
import mega.privacy.android.app.lollipop.megachat.NonContactInfo;
import mega.privacy.android.app.utils.Constants;
import mega.privacy.android.app.utils.MegaApiUtils;
@@ -194,6 +195,14 @@ public void archiveChat(MegaChatRoom chat){
megaChatApi.archiveChat(chat.getChatId(), true, (GroupChatInfoActivityLollipop) context);
}
}
+ else if(context instanceof ChatActivityLollipop){
+ if(chat.isArchived()){
+ megaChatApi.archiveChat(chat.getChatId(), false,(ChatActivityLollipop) context);
+ }
+ else{
+ megaChatApi.archiveChat(chat.getChatId(), true, (ChatActivityLollipop) context);
+ }
+ }
}
public void archiveChats(ArrayList chats){
@@ -220,7 +229,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= Build.VERSION_CODES.M) {
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (!hasStoragePermission) {
- if (context instanceof ChatActivityLollipop) {
- ActivityCompat.requestPermissions(((ChatActivityLollipop) context),
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
- }
- else if (context instanceof ChatFullScreenImageViewer){
- ActivityCompat.requestPermissions(((ChatFullScreenImageViewer) context),
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
- }
- else if (context instanceof PdfViewerActivityLollipop){
- ActivityCompat.requestPermissions(((PdfViewerActivityLollipop) context),
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
- }
- else if (context instanceof AudioVideoPlayerLollipop){
- ActivityCompat.requestPermissions(((AudioVideoPlayerLollipop) context),
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
- }
- }
- }
-
- Map dlFiles = new HashMap();
- if (node != null) {
-
- if (Environment.getExternalStorageDirectory() != null){
- destination = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Util.offlineDIR + "/"+MegaApiUtils.createStringTree(node, context));
- }
- else{
- destination = context.getFilesDir();
- }
-
- destination.mkdirs();
-
- log ("DESTINATION!!!!!: " + destination.getAbsolutePath());
- if (destination.exists() && destination.isDirectory()){
-
- File offlineFile = new File(destination, node.getName());
- if (offlineFile.exists() && node.getSize() == offlineFile.length() && offlineFile.getName().equals(node.getName())){ //This means that is already available offline
- log("File already exists!");
- if (context instanceof ChatFullScreenImageViewer){
- ((ChatFullScreenImageViewer) context).showSnackbar(context.getString(R.string.file_already_exists));
- }
- else if (context instanceof AudioVideoPlayerLollipop){
- ((AudioVideoPlayerLollipop) context).showSnackbar(context.getString(R.string.file_already_exists));
- }
- else if (context instanceof PdfViewerActivityLollipop){
- ((PdfViewerActivityLollipop) context).showSnackbar(context.getString(R.string.file_already_exists));
- }
- }
- else{
- dlFiles.put(node, destination.getAbsolutePath());
- }
- }
- else{
- log("Destination ERROR");
- }
- }
-
-
- double availableFreeSpace = Double.MAX_VALUE;
- try{
- StatFs stat = new StatFs(destination.getAbsolutePath());
- availableFreeSpace = (double)stat.getAvailableBlocks() * (double)stat.getBlockSize();
- }
- catch(Exception ex){}
-
- for (MegaNode document : dlFiles.keySet()) {
-
- String path = dlFiles.get(document);
-
- if(availableFreeSpace nodeList){
log("prepareForDownload: "+nodeList.size()+" files to download");
@@ -1702,9 +1643,6 @@ public void checkSizeBeforeDownload(String parentPath, ArrayList nodeL
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop) context).showSnackbarNotSpace();
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).showSnackbarNotSpace();
- }
else if(context instanceof ChatFullScreenImageViewer){
((ChatFullScreenImageViewer) context).showSnackbarNotSpace();
}
@@ -1714,6 +1652,9 @@ else if (context instanceof PdfViewerActivityLollipop){
else if (context instanceof AudioVideoPlayerLollipop){
((AudioVideoPlayerLollipop) context).showSnackbarNotSpace();
}
+ else if (context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).showSnackbarNotSpace();
+ }
log("Not enough space");
return;
}
@@ -1740,9 +1681,6 @@ else if (context instanceof AudioVideoPlayerLollipop){
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop) context).askSizeConfirmationBeforeChatDownload(parentPathC, nodeList, sizeC);
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).askSizeConfirmationBeforeChatDownload(parentPathC, nodeList, sizeC);
- }
else if(context instanceof ChatFullScreenImageViewer){
((ChatFullScreenImageViewer) context).askSizeConfirmationBeforeChatDownload(parentPathC, nodeList, sizeC);
}
@@ -1752,6 +1690,9 @@ else if (context instanceof PdfViewerActivityLollipop){
else if (context instanceof AudioVideoPlayerLollipop){
((AudioVideoPlayerLollipop) context).askSizeConfirmationBeforeChatDownload(parentPath, nodeList, sizeC);
}
+ else if (context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).askSizeConfirmationBeforeChatDownload(parentPath, nodeList, sizeC);
+ }
}
else{
download(parentPathC, nodeList);
@@ -1880,8 +1821,8 @@ else if (MimeTypeList.typeForName(tempNode.getName()).isVideoReproducible() || M
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop) context).showSnackbar(context.getString(R.string.intent_not_available));
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).showSnackbar(context.getString(R.string.intent_not_available));
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(context.getString(R.string.intent_not_available));
}
Intent intentShare = new Intent(Intent.ACTION_SEND);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && localPath.contains(Environment.getExternalStorageDirectory().getPath())) {
@@ -1954,8 +1895,8 @@ else if (MimeTypeList.typeForName(tempNode.getName()).isPdf()){
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop) context).showSnackbar(context.getString(R.string.general_already_downloaded));
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).showSnackbar(context.getString(R.string.general_already_downloaded));
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(context.getString(R.string.general_already_downloaded));
}
}
}
@@ -1963,15 +1904,15 @@ else if(context instanceof NodeAttachmentActivityLollipop){
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop) context).showSnackbar(context.getString(R.string.general_already_downloaded));
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).showSnackbar(context.getString(R.string.general_already_downloaded));
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(context.getString(R.string.general_already_downloaded));
}
}
}
}
return;
- }
+ }//localPath found
else{
log("localPath is NULL");
}
@@ -2009,6 +1950,157 @@ else if(context instanceof NodeAttachmentActivityLollipop){
}
}
+ public void importNode(long idMessage, long idChat) {
+ log("importNode");
+ ArrayList messages = new ArrayList<>();
+ MegaChatMessage m = megaChatApi.getMessage(idChat, idMessage);
+
+ if(m!=null){
+ AndroidMegaChatMessage aMessage = new AndroidMegaChatMessage(m);
+ messages.add(aMessage);
+ importNodesFromAndroidMessages(messages);
+ }
+ else{
+ log("Message cannot be recovered - null");
+ }
+ }
+
+ public void importNodesFromMessages(ArrayList messages){
+ log("importNodesFromMessages");
+
+ 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);
+
+ long[] longArray = new long[messages.size()];
+ for (int i = 0; i < messages.size(); i++) {
+ longArray[i] = messages.get(i).getMessage().getMsgId();
+ }
+ intent.putExtra("HANDLES_IMPORT_CHAT", longArray);
+
+ 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) {
+ log("prepareMessageToForward");
+ ArrayList messagesSelected = new ArrayList<>();
+ MegaChatMessage m = megaChatApi.getMessage(idChat, idMessage);
+ messagesSelected.add(m);
+
+ prepareMessagesToForward(messagesSelected, 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<>();
+ long[] idMessages = new long[messagesSelected.size()];
+ for(int i=0; i messagesSelected, long idChat){
+ log ("forwardMessages");
+
+ long[] idMessages = new long[messagesSelected.size()];
+ for(int i=0; i messagesSelected, int counter, Context context) {
+ public ChatImportToForwardListener(int action, ArrayList messagesSelected, int counter, Context context, ChatController chatC, long chatId) {
super();
this.actionListener = action;
this.context = context;
this.counter = counter;
this.messagesSelected = messagesSelected;
+ this.chatC = chatC;
+ this.chatId = chatId;
}
int counter = 0;
int error = 0;
int actionListener = -1;
String message;
- ArrayList messagesSelected;
+ long chatId;
+ ArrayList messagesSelected;
+ ChatController chatC;
@Override
public void onRequestUpdate(MegaApiJava api, MegaRequest request) {
@@ -79,11 +85,13 @@ public void onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e) {
((ChatActivityLollipop) context).removeRequestDialog();
((ChatActivityLollipop) context).showSnackbar(message);
}
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ ((NodeAttachmentHistoryActivity) context).removeProgressDialog();
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(message);
+ }
}
else{
- if(context instanceof ChatActivityLollipop){
- ((ChatActivityLollipop) context).forwardMessages(messagesSelected);
- }
+ chatC.forwardMessages(messagesSelected, chatId);
}
}
break;
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..7bfbb3c93c4
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/GroupCallListener.java
@@ -0,0 +1,108 @@
+package mega.privacy.android.app.lollipop.listeners;
+
+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.view.TextureView;
+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;
+import nz.mega.sdk.MegaChatVideoListenerInterface;
+
+
+public class GroupCallListener implements MegaChatVideoListenerInterface {
+
+ Context context;
+ int width;
+ int height;
+ Bitmap bitmap;
+ TextureView myTexture = null;
+ MegaSurfaceRendererGroup localRenderer = null;
+
+ public GroupCallListener(Context context, TextureView myTexture, Long peerHandle) {
+ log("GroupCallListener");
+ this.context = context;
+ this.width = 0;
+ this.height = 0;
+ this.myTexture = myTexture;
+ 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;
+ }
+
+ if (this.width != width || this.height != height) {
+ this.width = width;
+ this.height = height;
+
+ int viewWidth = myTexture.getWidth();
+ int viewHeight = myTexture.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);
+ }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 TextureView getSurfaceView() {
+ return myTexture;
+ }
+
+ public MegaSurfaceRendererGroup getLocalRenderer() {
+ return localRenderer;
+ }
+
+ 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("GroupCallListener", log);
+ }
+
+}
+
diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleForwardChatProcessor.java b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleForwardChatProcessor.java
index 2f68f35ac5e..c1baed734b0 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleForwardChatProcessor.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/listeners/MultipleForwardChatProcessor.java
@@ -7,6 +7,7 @@
import mega.privacy.android.app.R;
import mega.privacy.android.app.lollipop.megachat.AndroidMegaChatMessage;
import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop;
+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.MegaApiAndroid;
@@ -93,6 +94,7 @@ public void forward(){
break;
}
case MegaChatMessage.TYPE_NODE_ATTACHMENT:{
+
if(messageToForward.getUserHandle()!=megaChatApi.getMyUserHandle()){
MegaNodeList nodeList = messageToForward.getMegaNodeList();
if(nodeList != null) {
@@ -140,6 +142,7 @@ public void forward(){
String text = "";
if(meta!=null && meta.getType()==MegaChatContainsMeta.CONTAINS_META_RICH_PREVIEW){
text = meta.getRichPreview().getText();
+ }else{
}
if(chatHandles[0]==idChat){
((ChatActivityLollipop) context).sendMessage(text);
@@ -240,6 +243,7 @@ public void forward(){
String text = "";
if(meta!=null && meta.getType()==MegaChatContainsMeta.CONTAINS_META_RICH_PREVIEW){
text = meta.getRichPreview().getText();
+ }else{
}
if(chatHandles[k]==idChat){
((ChatActivityLollipop) context).sendMessage(text);
@@ -340,6 +344,43 @@ else if(totalErrors==errorNotAvailable){
((ChatActivityLollipop) context).removeProgressDialog();
}
}
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ if(success>0){
+ //A message has been forwarded
+ String text = null;
+ int totalErrors = error+errorNotAvailable;
+ if(totalErrors == 0){
+ text = context.getResources().getQuantityString(R.plurals.messages_forwarded_success_plural, totalMessages);
+ }
+ else if(totalErrors==errorNotAvailable){
+ text = context.getResources().getQuantityString(R.plurals.messages_forwarded_error_not_available, totalErrors, totalErrors);
+ }
+ else{
+ text = context.getResources().getQuantityString(R.plurals.messages_forwarded_partial_error, totalErrors, totalErrors);
+ }
+
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(text);
+
+// if(chatHandles.length==1){
+// ((NodeAttachmentHistoryActivity) context).openChatAfterForward(chatHandles[0], text);
+// }
+// else {
+// ((NodeAttachmentHistoryActivity) context).openChatAfterForward(-1, text);
+// }
+ }
+ else{
+ //No messages forwarded
+ int totalErrors = error+errorNotAvailable;
+ if(totalErrors==errorNotAvailable){
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(context.getResources().getQuantityString(R.plurals.messages_forwarded_error_not_available, totalErrors, totalErrors));
+ }
+ else{
+ String text = context.getResources().getQuantityString(R.plurals.messages_forwarded_partial_error, totalErrors, totalErrors);
+ ((NodeAttachmentHistoryActivity) context).showSnackbar(text);
+ }
+ }
+ ((NodeAttachmentHistoryActivity) context).removeProgressDialog();
+ }
}
}
};
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 144a2ad8d94..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,7 +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.NodeAttachmentActivityLollipop;
+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;
@@ -298,15 +298,16 @@ else if(context instanceof ChatActivityLollipop){
else if(context instanceof ContactAttachmentActivityLollipop){
((ContactAttachmentActivityLollipop) context).showSnackbar(message);
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop) context).showSnackbar(message);
- }
else if(context instanceof AchievementsActivity){
((AchievementsActivity) context).showInviteConfirmationDialog();
}
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/managerSections/CameraUploadFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/CameraUploadFragmentLollipop.java
index 0e6ac5b8e74..270826c56a9 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/CameraUploadFragmentLollipop.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/CameraUploadFragmentLollipop.java
@@ -740,7 +740,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
((ManagerActivityLollipop) context).supportInvalidateOptionsMenu();
if (type == TYPE_CAMERA) {
- if (((ManagerActivityLollipop) context).getFirstTimeCam()) {
+ if (((ManagerActivityLollipop) context).getFirstLogin()) {
((ManagerActivityLollipop) context).showHideBottomNavigationView(true);
setInitialPreferences();
View v = inflater.inflate(R.layout.activity_cam_sync_initial, container, false);
@@ -1429,7 +1429,7 @@ public void onAttach(Context context) {
@SuppressLint("NewApi")
private void cameraOnOffFirstTime(){
- ((ManagerActivityLollipop) context).setFirstTimeCam(false);
+ ((ManagerActivityLollipop) context).setFirstLogin(false);
// firstTimeCam = false;
DatabaseHandler dbH = DatabaseHandler.getDbHandler(context);
dbH.setCamSyncEnabled(true);
@@ -1605,7 +1605,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
// boolean hasCameraPermission = (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
// if (hasCameraPermission){
- if (((ManagerActivityLollipop) context).getFirstTimeCam()){
+ if (((ManagerActivityLollipop) context).getFirstLogin()){
this.cameraOnOffFirstTime();
}
else{
@@ -1687,7 +1687,7 @@ public void onClick(View v) {
break;
}
case R.id.cam_sync_button_skip:{
- ((ManagerActivityLollipop) context).setFirstTimeCam(false);
+ ((ManagerActivityLollipop) context).setFirstLogin(false);
dbH.setCamSyncEnabled(false);
((ManagerActivityLollipop)context).setInitialCloudDrive();
break;
@@ -2030,8 +2030,8 @@ public void hideMultipleSelect() {
public int onBackPressed(){
log("onBackPressed");
- if(((ManagerActivityLollipop)context).getFirstTimeCam()){
- ((ManagerActivityLollipop) context).setFirstTimeCam(false);
+ if(((ManagerActivityLollipop)context).getFirstLogin()){
+ ((ManagerActivityLollipop) context).setFirstLogin(false);
dbH.setCamSyncEnabled(false);
((ManagerActivityLollipop) context).refreshMenu();
}
@@ -2371,11 +2371,11 @@ public void notifyDataSetChanged(){
}
}
-// public void setFirstTimeCam(boolean firstTimeCam){
+// public void setFirstLogin(boolean firstTimeCam){
// this.firstTimeCam = firstTimeCam;
// }
//
-// public boolean getFirstTimeCam(){
+// public boolean getFirstLogin(){
// return firstTimeCam;
// }
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..f12b03d50a1 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){
@@ -833,47 +846,10 @@ 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(Util.isChatEnabled()){
+ if(!visibleContacts.isEmpty()){
+ for (int i=0;i contacts = megaApi.getContacts();
+ setContacts(megaApi.getContacts());
if(adapter == null){
if (((ManagerActivityLollipop)context).isList()) {
@@ -1156,7 +1144,7 @@ public void updateView () {
}
}
else{
- this.setContacts(contacts);
+ adapter.setContacts(visibleContacts);
}
if (visibleContacts.size() == 0){
@@ -1200,8 +1188,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 +1197,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 +1217,39 @@ 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);
+ //contact.setLastGreen("Veryyy veryy longg tooo check what happens");
+ 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/managerSections/FileBrowserFragmentLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/FileBrowserFragmentLollipop.java
index 0fae1058799..b8ef0009782 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/FileBrowserFragmentLollipop.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/managerSections/FileBrowserFragmentLollipop.java
@@ -1487,16 +1487,16 @@ public int onBackPressed() {
visibilityFastScroller();
setOverviewLayout();
-
+
int lastVisiblePosition = 0;
if (!lastPositionStack.empty()) {
lastVisiblePosition = lastPositionStack.pop();
log("Pop of the stack " + lastVisiblePosition + " position");
}
log("Scroll to " + lastVisiblePosition + " position");
-
+
if (lastVisiblePosition >= 0) {
-
+
if (((ManagerActivityLollipop)context).isList) {
mLayoutManager.scrollToPositionWithOffset(lastVisiblePosition,0);
} else {
@@ -1514,6 +1514,15 @@ public int onBackPressed() {
return 0;
}
+
+ public void scrollToFirstPosition () {
+ if (((ManagerActivityLollipop)context).isList) {
+ mLayoutManager.scrollToPositionWithOffset(0,0);
+ }
+ else {
+ gridLayoutManager.scrollToPositionWithOffset(0,0);
+ }
+ }
public RecyclerView getRecyclerView() {
return recyclerView;
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..5b58e4a86e4 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,15 @@
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.utils.Util;
import nz.mega.sdk.MegaApiAndroid;
+import nz.mega.sdk.MegaChatApiAndroid;
+import nz.mega.sdk.MegaContactRequest;
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 +45,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 +80,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,27 +252,51 @@ public void itemClick(int position) {
switch (alertType) {
case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_REQUEST:
- case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_CANCELLED:
- case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_REMINDER:
- case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_IGNORED:
+ case MegaUserAlert.TYPE_CONTACTCHANGE_CONTACTESTABLISHED:
case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_ACCEPTED:
- case MegaUserAlert.TYPE_UPDATEDPENDINGCONTACTINCOMING_DENIED:{
- log("Go to Received requests");
- ((ManagerActivityLollipop)context).navigateToContacts(2);
+ case MegaUserAlert.TYPE_INCOMINGPENDINGCONTACT_REMINDER:
+ {
+ MegaUser contact = megaApi.getContact(notif.getEmail());
+ if(contact!=null && contact.getVisibility() == MegaUser.VISIBILITY_VISIBLE){
+ log("Go to contact info");
+ Intent intent = new Intent(context, ContactInfoActivityLollipop.class);
+ intent.putExtra("name", notif.getEmail());
+ startActivity(intent);
+ }
+ else{ ArrayList contacts = megaApi.getIncomingContactRequests();
+ if(contacts!=null){
+ for(int i = 0; i updatedUserAlerts) {
continue;
}
+ log("User alert type: "+updatedUserAlerts.get(i).getType());
long idToUpdate = updatedUserAlerts.get(i).getId();
int indexToReplace = -1;
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 361d45dd84e..c47660bef20 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.NewGridRecyclerView;
@@ -221,9 +222,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);
+ }
+ }
}
}
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 631eb9d096c..d65470ae276 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
@@ -67,6 +67,7 @@
import nz.mega.sdk.MegaChatApiAndroid;
import nz.mega.sdk.MegaChatPresenceConfig;
import nz.mega.sdk.MegaNode;
+import nz.mega.sdk.MegaTransfer;
@SuppressLint("NewApi")
public class SettingsFragmentLollipop extends PreferenceFragmentCompat implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
@@ -2205,8 +2206,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;
@@ -2214,6 +2213,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 099ba44597f..fd4726d50f5 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;
@@ -79,14 +78,13 @@
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;
-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;
-import mega.privacy.android.app.lollipop.FileExplorerActivityLollipop;
import mega.privacy.android.app.lollipop.FileLinkActivityLollipop;
import mega.privacy.android.app.lollipop.FolderLinkActivityLollipop;
import mega.privacy.android.app.lollipop.LoginActivityLollipop;
@@ -94,7 +92,6 @@
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.ChatImportToForwardListener;
import mega.privacy.android.app.lollipop.listeners.ChatLinkInfoListener;
import mega.privacy.android.app.lollipop.listeners.MultipleForwardChatProcessor;
import mega.privacy.android.app.lollipop.listeners.MultipleGroupChatRequestListener;
@@ -151,7 +148,6 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha
public static int NUMBER_MESSAGES_TO_LOAD = 20;
public static int NUMBER_MESSAGES_BEFORE_LOAD = 8;
- public static int REQUEST_CODE_SELECT_CHAT = 1005;
public static int INITIAL_PRESENCE_STATUS = -55;
@@ -200,7 +196,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha
boolean pendingMessagesLoaded = false;
- boolean isFirstTimeStorage = true;
+// boolean isFirstTimeStorage = true;
boolean startVideo = false;
public boolean activityVisible = false;
@@ -230,7 +226,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha
LinearLayout toolbarElements;
TextView titleToolbar;
- TextView subtitleToobar;
+ MarqueeTextView subtitleToobar;
ImageView iconStateToolbar;
float scaleH, scaleW;
float density;
@@ -271,6 +267,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha
RelativeLayout rLPickFileStorageButton;
RelativeLayout callInProgressLayout;
+ TextView callInProgressText;
EmojiEditText textChat;
ImageButton sendIcon;
@@ -287,6 +284,7 @@ public class ChatActivityLollipop extends PinActivityLollipop implements MegaCha
MenuItem clearHistoryMenuItem;
MenuItem contactInfoMenuItem;
MenuItem leaveMenuItem;
+ MenuItem archiveMenuItem;
boolean focusChanged=false;
@@ -594,7 +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 = (MarqueeTextView) tB.findViewById(R.id.subtitle_toolbar);
subtitleToobar.setFocusable(true);
subtitleToobar.setFocusableInTouchMode(true);
subtitleToobar.setEllipsize(TextUtils.TruncateAt.MARQUEE);
@@ -667,6 +665,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);
rLKeyboardTwemojiButton.setOnClickListener(this);
rLMediaButton.setOnClickListener(this);
@@ -689,7 +688,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) {
}
@@ -914,9 +912,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);
@@ -937,10 +932,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){
@@ -1292,10 +1283,15 @@ else if(permission==MegaChatRoom.PRIV_RM) {
iconStateToolbar.setVisibility(View.GONE);
}
else{
- long participantsLabel = chatRoom.getPeerCount()+1; //Add one to include me
- subtitleToobar.setText(adjustForLargeFont(getResources().getQuantityString(R.plurals.subtitle_of_group_chat, (int) participantsLabel, participantsLabel)));
- subtitleToobar.setVisibility(View.VISIBLE);
- iconStateToolbar.setVisibility(View.GONE);
+ if(chatRoom.hasCustomTitle()){
+ setCustomSubtitle();
+ }
+ else{
+ long participantsLabel = chatRoom.getPeerCount()+1; //Add one to include me
+ subtitleToobar.setText(adjustForLargeFont(getResources().getQuantityString(R.plurals.subtitle_of_group_chat, (int) participantsLabel, participantsLabel)));
+ subtitleToobar.setVisibility(View.VISIBLE);
+ iconStateToolbar.setVisibility(View.GONE);
+ }
}
}
}
@@ -1396,15 +1392,80 @@ else if(permission==MegaChatRoom.PRIV_RM) {
}
}
+ public void setCustomSubtitle(){
+ log("setCustomSubtitle");
+
+ long participantsCount = chatRoom.getPeerCount();
+ StringBuilder customSubtitle = new StringBuilder("");
+ for(int i=0;i= Build.VERSION_CODES.M) {
boolean hasCameraPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
@@ -1910,9 +1996,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){
@@ -1941,10 +2024,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){
@@ -1982,6 +2061,11 @@ public void showProgressForwarding(){
statusDialog.show();
}
+ public void forwardMessages(ArrayList messagesSelected){
+ log("forwardMessages");
+ chatC.prepareAndroidMessagesToForward(messagesSelected, idChat);
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
log("onActivityResult, resultCode: " + resultCode);
@@ -2023,86 +2107,11 @@ else if (requestCode == Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER && resultCod
return;
}
- statusDialog = new ProgressDialog(this);
- statusDialog.setMessage(getString(R.string.general_importing));
- statusDialog.show();
-
final long toHandle = intent.getLongExtra("IMPORT_TO", 0);
final long[] importMessagesHandles = intent.getLongArrayExtra("HANDLES_IMPORT_CHAT");
- MegaNode target = null;
- target = megaApi.getNodeByHandle(toHandle);
- if(target == null){
- target = megaApi.getRootNode();
- }
- log("TARGET: " + target.getName() + "and handle: " + target.getHandle());
-
- if(importMessagesHandles.length==1){
- for (int k = 0; k < importMessagesHandles.length; k++){
- MegaChatMessage message = megaChatApi.getMessage(idChat, importMessagesHandles[k]);
- if(message!=null){
-
- MegaNodeList nodeList = message.getMegaNodeList();
-
- for(int i=0;i contactsData = intent.getStringArrayListExtra(AddContactActivityLollipop.EXTRA_CONTACTS);
@@ -2167,7 +2176,7 @@ else if (requestCode == Constants.REQUEST_CODE_GET && resultCode == RESULT_OK) {
}
statusDialog = temp;
}
- else if (requestCode == REQUEST_CODE_SELECT_CHAT && resultCode == RESULT_OK) {
+ else if (requestCode == Constants.REQUEST_CODE_SELECT_CHAT && resultCode == RESULT_OK) {
if(!Util.isOnline(this)) {
try{
statusDialog.dismiss();
@@ -2214,6 +2223,86 @@ else if (requestCode == Constants.TAKE_PHOTO_CODE && resultCode == RESULT_OK) {
super.onActivityResult(requestCode, resultCode, intent);
}
+ public void importNodes(final long toHandle, final long[] importMessagesHandles){
+ log("importNode: "+toHandle+ " -> "+ importMessagesHandles.length);
+ statusDialog = new ProgressDialog(this);
+ statusDialog.setMessage(getString(R.string.general_importing));
+ statusDialog.show();
+
+ MegaNode target = null;
+ target = megaApi.getNodeByHandle(toHandle);
+ if(target == null){
+ target = megaApi.getRootNode();
+ }
+ log("TARGET: " + target.getName() + "and handle: " + target.getHandle());
+
+ if(importMessagesHandles.length==1){
+ for (int k = 0; k < importMessagesHandles.length; k++){
+ MegaChatMessage message = megaChatApi.getMessage(idChat, importMessagesHandles[k]);
+ if(message!=null){
+
+ MegaNodeList nodeList = message.getMegaNodeList();
+
+ for(int i=0;i messagesSelected = adapter.getSelectedMessages();
- if(megaChatApi.isSignalActivityRequired()){
- megaChatApi.signalPresenceActivity();
- }
-
switch(item.getItemId()){
// case R.id.cab_menu_select_all:{
// selectAll();
@@ -2984,7 +3075,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
}
case R.id.chat_cab_menu_forward:{
log("Forward message");
- prepareMessagesToForward(messagesSelected);
+ forwardMessages(messagesSelected);
break;
}
case R.id.chat_cab_menu_copy:{
@@ -3038,13 +3129,13 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
clearSelections();
hideMultipleSelect();
- importNodes(messagesSelected);
+ chatC.importNodesFromAndroidMessages(messagesSelected);
break;
}
case R.id.chat_cab_menu_offline:{
clearSelections();
hideMultipleSelect();
- chatC.saveForOfflineWithMessages(messagesSelected);
+ chatC.saveForOfflineWithAndroidMessages(messagesSelected);
break;
}
}
@@ -3210,7 +3301,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)){
@@ -3226,7 +3317,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)){
@@ -3273,7 +3364,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;
}
}
@@ -3337,7 +3428,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:
@@ -3409,13 +3500,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();
@@ -3452,9 +3538,6 @@ public void selectAll() {
public void itemClick(int positionInAdapter, int [] screenPosition) {
log("itemClick");
int position = positionInAdapter-1;
- if(megaChatApi.isSignalActivityRequired()){
- megaChatApi.signalPresenceActivity();
- }
if(position messages = adapter.getSelectedMessages();
+ if (messages.size() > 0) {
+ updateActionModeTitle();
+ }
+ }
- List messages = adapter.getSelectedMessages();
- if (messages.size() > 0) {
- updateActionModeTitle();
-// adapter.notifyDataSetChanged();
}
-// else {
-// hideMultipleSelect();
+
+// adapter.toggleSelection(positionInAdapter);
+
+// List messages = adapter.getSelectedMessages();
+// if (messages.size() > 0) {
+// updateActionModeTitle();
+//// adapter.notifyDataSetChanged();
// }
+//// else {
+//// hideMultipleSelect();
+//// }
}
}else{
-
if(m!=null){
if(m.isUploading()){
showUploadingAttachmentBottomSheet(m, position);
@@ -3777,7 +3870,6 @@ else if (MimeTypeList.typeForName(node.getName()).isPdf()){
}
else if(m.getMessage().getType()==MegaChatMessage.TYPE_CONTACT_ATTACHMENT){
log("TYPE_CONTACT_ATTACHMENT");
-
log("show contact attachment panel");
if (Util.isOnline(this)) {
if (m != null) {
@@ -3799,16 +3891,21 @@ else if(m.getMessage().getType()==MegaChatMessage.TYPE_CONTACT_ATTACHMENT){
}
else if(m.getMessage().getType()==MegaChatMessage.TYPE_CONTAINS_META){
log("TYPE_CONTAINS_META");
-
log("open rich link");
// if(!adapter.getforwardOwnRichLinksB()){
MegaChatContainsMeta meta = m.getMessage().getContainsMeta();
- if(meta!=null && meta.getType()==MegaChatContainsMeta.CONTAINS_META_RICH_PREVIEW){
- String url = meta.getRichPreview().getUrl();
- Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- startActivity(browserIntent);
+ if((meta != null) && (meta.getType()!= MegaChatContainsMeta.CONTAINS_META_INVALID)){
+ if(meta.getType()==MegaChatContainsMeta.CONTAINS_META_RICH_PREVIEW){
+ String url = meta.getRichPreview().getUrl();
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ startActivity(browserIntent);
+ }
+ }else{
+
}
+
+
// }else{
// ArrayList message = new ArrayList<>();
@@ -3818,7 +3915,6 @@ else if(m.getMessage().getType()==MegaChatMessage.TYPE_CONTAINS_META){
}else if((m.getMessage().getType() == MegaChatMessage.TYPE_NORMAL) && (m.getRichLinkMessage()!=null)){
log("TYPE_NORMAL");
-
AndroidMegaRichLinkMessage richLinkMessage = m.getRichLinkMessage();
String url = richLinkMessage.getUrl();
@@ -4780,7 +4876,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");
@@ -4990,33 +5087,34 @@ public void deleteMessage(MegaChatMessage msg, boolean rejected){
log("Decrease generalUnread:Position where new messages layout is show: " + positionNewMessagesLayout);
generalUnreadCount--;
}
-
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");
@@ -5110,6 +5208,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 +5288,8 @@ public int modifyMessageReceived(AndroidMegaChatMessage msg, boolean checkTempId
}
else{
+ log("indexToChange == -1");
+
log("Error, id temp message not found!!");
}
return indexToChange;
@@ -5211,7 +5313,6 @@ public void loadBufferMessages(){
adapter.setMessages(messages);
}
else{
-// adapter.setPositionClicked(-1);
adapter.loadPreviousMessages(messages, bufferMessages.size());
log("addMessage: "+messages.size());
@@ -5269,7 +5370,6 @@ public void clearHistory(AndroidMegaChatMessage androidMsg){
}
adapter.setMessages(messages);
- adapter.notifyDataSetChanged();
}
public void loadPendingMessages(){
@@ -5281,10 +5381,10 @@ public void loadPendingMessages(){
for(int i=0;i=0) {
@@ -5497,6 +5633,16 @@ public int appendMessagePosition(AndroidMegaChatMessage msg){
messages.add(lastIndex, msg);
adjustInfoToShow(lastIndex);
msg.setShowAvatar(true);
+ if(!messages.get(lastIndex).isUploading()){
+ int nextIndex = lastIndex+1;
+ if(nextIndex0){
setShowAvatar(lastIndex-1);
}
@@ -5537,7 +5683,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;
}
@@ -5826,7 +5972,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 {
@@ -5914,8 +6060,8 @@ public void removePendingMsg(long id){
if(pMsg!=null && pMsg.getState()==PendingMessageSingle.STATE_UPLOADING) {
if (pMsg.getTransferTag() != -1) {
log("Transfer tag: " + pMsg.getTransferTag());
- if (megaApi != null && megaApi.isOnline()) {
- megaApi.cancelTransferByTag(pMsg.getTransferTag());
+ if (megaApi != null) {
+ megaApi.cancelTransferByTag(pMsg.getTransferTag(), this);
}
}
}
@@ -6029,15 +6175,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.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_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.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){
@@ -6121,6 +6289,50 @@ else if(request.getType() == MegaChatRequest.TYPE_CREATE_CHATROOM){
else if(request.getType() == MegaChatRequest.TYPE_LAST_GREEN){
log("TYPE_LAST_GREEN requested");
}
+ else if(request.getType() == MegaChatRequest.TYPE_ARCHIVE_CHATROOM){
+ long chatHandle = request.getChatHandle();
+ chatRoom = megaChatApi.getChatRoom(chatHandle);
+ String chatTitle = chatRoom.getTitle();
+
+ if(chatTitle==null){
+ chatTitle = "";
+ }
+ else if(!chatTitle.isEmpty() && chatTitle.length()>60){
+ chatTitle = chatTitle.substring(0,59)+"...";
+ }
+
+ if(!chatTitle.isEmpty() && chatRoom.isGroup() && !chatRoom.hasCustomTitle()){
+ chatTitle = "\""+chatTitle+"\"";
+ }
+
+ if(e.getErrorCode()==MegaChatError.ERROR_OK){
+ if(request.getFlag()){
+ log("Chat archived");
+ showSnackbar(getString(R.string.success_archive_chat, chatTitle));
+ }
+ else{
+ log("Chat unarchived");
+ showSnackbar(getString(R.string.success_unarchive_chat, chatTitle));
+ }
+ }
+ else{
+ if(request.getFlag()){
+ log("EEEERRRRROR WHEN ARCHIVING CHAT " + e.getErrorString());
+ showSnackbar(getString(R.string.error_archive_chat, chatTitle));
+ }
+ else{
+ log("EEEERRRRROR WHEN UNARCHIVING CHAT " + e.getErrorString());
+ showSnackbar(getString(R.string.error_unarchive_chat, chatTitle));
+ }
+ }
+
+ supportInvalidateOptionsMenu();
+ setChatSubtitle();
+
+ if(!chatRoom.isArchived()){
+ requestLastGreen(INITIAL_PRESENCE_STATUS);
+ }
+ }
}
@Override
@@ -6278,37 +6490,6 @@ public void setChatRoom(MegaChatRoom chatRoom) {
this.chatRoom = chatRoom;
}
- public void importNode(long idMessage) {
- log("importNode");
- ArrayList messages = new ArrayList<>();
- MegaChatMessage m = megaChatApi.getMessage(idChat, idMessage);
-
- if(m!=null){
- AndroidMegaChatMessage aMessage = new AndroidMegaChatMessage(m);
- messages.add(aMessage);
- importNodes(messages);
- }
- else{
- log("Message cannot be recovered - null");
- }
- }
-
- public void importNodes(ArrayList messages){
- log("importNodes");
-
- Intent intent = new Intent(this, 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).getMessage().getMsgId();
- }
- intent.putExtra("HANDLES_IMPORT_CHAT", longArray);
-
- startActivityForResult(intent, Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER);
-
- }
-
public void removeRequestDialog(){
try{
statusDialog.dismiss();
@@ -6394,6 +6575,14 @@ else if(e.getErrorCode()==MegaError.API_EGOINGOVERQUOTA){
Snackbar.make(fragmentContainer, getString(R.string.import_success_message), Snackbar.LENGTH_LONG).show();
}
}
+ else if (request.getType() == MegaRequest.TYPE_CANCEL_TRANSFER){
+ if (e.getErrorCode() != MegaError.API_OK) {
+ log("Error TYPE_CANCEL_TRANSFER: "+e.getErrorCode());
+ }
+ else{
+ log("Chat upload cancelled");
+ }
+ }
}
@Override
@@ -6571,88 +6760,6 @@ public void onIntentProcessed(List infos) {
}
}
- public void prepareMessageToForward(long idMessage) {
- log("prepareMessageToForward");
- ArrayList messagesSelected = new ArrayList<>();
- MegaChatMessage m = megaChatApi.getMessage(idChat, idMessage);
- AndroidMegaChatMessage aM = new AndroidMegaChatMessage(m);
- messagesSelected.add(aM);
-
- prepareMessagesToForward(messagesSelected);
- }
-
- public void prepareMessagesToForward(ArrayList messagesSelected){
- log ("prepareMessagesToForward");
-
- ArrayList messagesToImport = new ArrayList<>();
- long[] idMessages = new long[messagesSelected.size()];
- for(int i=0; i messagesSelected){
- log ("forwardMessages");
-
- long[] idMessages = new long[messagesSelected.size()];
- for(int i=0; i= MegaChatCall.CALL_STATUS_REQUEST_SENT) && (callInProgress.getStatus() <= MegaChatCall.CALL_STATUS_IN_PROGRESS)){
+ log("onResume() callStatus: "+callInProgress.getStatus());
+
+ if((callInProgress.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT)||(callInProgress.getStatus()==MegaChatCall.CALL_STATUS_RING_IN)){
+ 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);
+ callInProgressText.setText(getString(R.string.call_in_progress_layout));
callInProgressLayout.setOnClickListener(this);
- }
- else{
+ }else{
+ log("onResume() other case - GONE");
callInProgressLayout.setVisibility(View.GONE);
}
}
else{
+ log("onResume() callInProgress != null - GONE");
callInProgressLayout.setVisibility(View.GONE);
}
@@ -6988,7 +7111,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);
@@ -7166,7 +7289,6 @@ private void showOverquotaAlert(boolean prewarning){
}
else{
builder.setMessage(getString(R.string.overquota_alert_text));
- dbH.setCamSyncEnabled(false);
}
if(overquotaDialog==null){
@@ -7211,12 +7333,59 @@ 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||call.getStatus()==MegaChatCall.CALL_STATUS_TERMINATING){
- log("Hide call in progress");
+ if(call.getStatus()==MegaChatCall.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("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("onChatCallUpdate - CALL_STATUS_RING_IN ");
+
+ 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();
+ 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);
+ }
+ }else if(call.getStatus()==MegaChatCall.CALL_STATUS_USER_NO_PRESENT){
+ log("onChatCallUpdate - CALL_STATUS_USER_NO_PRESENT");
+ 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();
+
}
}
}
@@ -7449,8 +7618,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;
@@ -7459,6 +7628,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/ChatFileStorageFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFileStorageFragment.java
index 9ada70bbf80..6707ae5a059 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFileStorageFragment.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatFileStorageFragment.java
@@ -29,12 +29,10 @@
import java.util.List;
import mega.privacy.android.app.DatabaseHandler;
-import mega.privacy.android.app.MegaApplication;
import mega.privacy.android.app.MegaPreferences;
import mega.privacy.android.app.R;
import mega.privacy.android.app.lollipop.megachat.chatAdapters.MegaChatFileStorageAdapter;
import mega.privacy.android.app.utils.Util;
-import nz.mega.sdk.MegaApiAndroid;
import nz.mega.sdk.MegaChatApiAndroid;
public class ChatFileStorageFragment extends BottomSheetDialogFragment{
@@ -47,7 +45,6 @@ public class ChatFileStorageFragment extends BottomSheetDialogFragment{
MegaChatFileStorageAdapter adapter;
ChatFileStorageFragment fileStorageFragment = this;
public static int GRID_LARGE = 2;
- MegaApiAndroid megaApi;
MegaChatApiAndroid megaChatApi;
Context context;
ActionBar aB;
@@ -74,9 +71,6 @@ public static ChatFileStorageFragment newInstance() {
@Override
public void onCreate (Bundle savedInstanceState){
- if (megaApi == null){
- megaApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaApi();
- }
dbH = DatabaseHandler.getDbHandler(getActivity());
@@ -107,18 +101,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
log("fragment ADDED");
- if (megaApi == null){
- megaApi = ((MegaApplication) ((Activity)context).getApplication()).getMegaApi();
- }
-
if (aB == null){
aB = ((AppCompatActivity)context).getSupportActionBar();
}
- if (megaApi.getRootNode() == null){
- return null;
- }
-
prefs = dbH.getPreferences();
display = ((Activity)context).getWindowManager().getDefaultDisplay();
outMetrics = new DisplayMetrics ();
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 a17f29c77de..2747537311e 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
@@ -684,7 +684,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/ChatUploadService.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/ChatUploadService.java
index 7a7bd1adb5a..fae4aad9893 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
@@ -466,188 +466,199 @@ public void finishDownsampling(String returnedFile, boolean success, long idPend
@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{
-
- 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 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;
+ }
+ }
+ }
- long total = 0;
- long inProgress = 0;
+ log("updateProgressNotification: progress: "+progressPercent);
- 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;
- }
- }
- }
+ 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);
+ }
- log("updateProgressNotification: progress: "+progressPercent);
+ 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;
+ }
- 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);
- }
+ String actionString = isOverquota == 0 ? getString(R.string.chat_upload_title_notification) :
+ getString(R.string.general_show_info);
- 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;
- 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);
- 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)
+ .setProgress(100, (int)progressPercent, false)
+ .setContentIntent(pendingIntent)
+ .setOngoing(true).setContentTitle(message)
+ .setContentText(actionString)
+ .setOnlyAlertOnce(true)
+ .setColor(ContextCompat.getColor(this,R.color.mega));
- 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(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) {
- 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) {
@@ -826,8 +837,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isPdf()) {
log("NOT video, image or pdf!");
attachNodes(transfer);
}
-
-// megaApi.cancelTransfers(MegaTransfer.TYPE_UPLOAD, this);
}
else{
log("Upload Error: " + transfer.getFileName() + "_" + error.getErrorCode() + "___" + error.getErrorString());
@@ -836,7 +845,6 @@ else if (MimeTypeList.typeForName(transfer.getPath()).isPdf()) {
log("Transfer API_EEXIST: "+transfer.getNodeHandle());
}
else{
-
if (error.getErrorCode() == MegaError.API_EOVERQUOTA) {
isOverquota = 1;
}
@@ -860,10 +868,6 @@ else if (error.getErrorCode() == MegaError.API_EGOINGOVERQUOTA) {
}
}
- 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) {
@@ -1006,8 +1010,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);
@@ -1019,9 +1023,31 @@ public void onTransferUpdate(MegaApiJava api, MegaTransfer transfer) {
}
@Override
- public void onTransferTemporaryError(MegaApiJava api,
- MegaTransfer transfer, MegaError e) {
+ public void onTransferTemporaryError(MegaApiJava api, MegaTransfer transfer, MegaError e) {
log(transfer.getPath() + "\nUpload Temporary Error: " + 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());
+ updateProgressNotification();
+ }
+ break;
+ }
+ }
}
@Override
@@ -1191,17 +1217,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);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
- mBuilderCompat.setColor(ContextCompat.getColor(this,R.color.mega));
+ NotificationCompat.Builder mBuilderCompatO = new NotificationCompat.Builder(getApplicationContext(), notificationChannelId);
+
+ 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/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/GroupChatInfoActivityLollipop.java
index da105e3a46d..20d98e3f744 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
@@ -131,6 +131,9 @@ public class GroupChatInfoActivityLollipop extends PinActivityLollipop implement
TextView notificationsTitle;
TextView notificationSelectedText;
+ RelativeLayout sharedFilesLayout;
+ View dividerSharedFilesLayout;
+
RelativeLayout clearChatLayout;
View dividerClearLayout;
RelativeLayout leaveChatLayout;
@@ -245,8 +248,13 @@ protected void onCreate(Bundle savedInstanceState) {
if (chat.getTitle().length() > 0){
String chatTitle = chat.getTitle().trim();
- String firstLetter = chatTitle.charAt(0) + "";
- firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+
+ String firstLetter = "";
+ if(!chatTitle.isEmpty()){
+ firstLetter = chatTitle.charAt(0) + "";
+ firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+ }
+
initialLetter.setText(firstLetter);
}
@@ -289,6 +297,13 @@ protected void onCreate(Bundle savedInstanceState) {
notificationsSwitch = (SwitchCompat) findViewById(R.id.chat_group_contact_properties_switch);
notificationsSwitch.setOnClickListener(this);
+ //Chat Shared Files Layout
+
+ sharedFilesLayout = (RelativeLayout) findViewById(R.id.chat_group_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_group_contact_properties_clear_layout);
clearChatLayout.setOnClickListener(this);
@@ -907,6 +922,14 @@ public void onClick(View view) {
break;
}
+ case R.id.chat_group_contact_properties_chat_files_shared_layout:{
+ Intent nodeHistoryIntent = new Intent(this, NodeAttachmentHistoryActivity.class);
+ if(chat!=null){
+ nodeHistoryIntent.putExtra("chatId", chat.getChatId());
+ }
+ startActivity(nodeHistoryIntent);
+ break;
+ }
}
}
@@ -987,6 +1010,11 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
input.setError(getString(R.string.invalid_string));
input.requestFocus();
}
+ else if(title.trim().isEmpty()){
+ log("title trim is empty");
+ input.setError(getString(R.string.invalid_string));
+ input.requestFocus();
+ }
else {
log("action DONE ime - change title");
changeTitle(title);
@@ -1010,6 +1038,11 @@ public void onClick(DialogInterface dialog, int whichButton) {
input.setError(getString(R.string.invalid_string));
input.requestFocus();
}
+ else if(title.trim().isEmpty()){
+ log("title trim is empty");
+ input.setError(getString(R.string.invalid_string));
+ input.requestFocus();
+ }
else {
log("positive button pressed - change title");
changeTitle(title);
@@ -1045,6 +1078,11 @@ public void onClick(View v) {
input.setError(getString(R.string.invalid_string));
input.requestFocus();
}
+ else if(title.trim().isEmpty()){
+ log("title trim is empty");
+ input.setError(getString(R.string.invalid_string));
+ input.requestFocus();
+ }
else {
log("positive button pressed - change title");
changeTitle(title);
@@ -1431,8 +1469,11 @@ else if(item.hasChanged(MegaChatListItem.CHANGE_TYPE_TITLE)) {
if (chat.getTitle().length() > 0){
String chatTitle = chat.getTitle().trim();
- String firstLetter = chatTitle.charAt(0) + "";
- firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+ String firstLetter = "";
+ if(!chatTitle.isEmpty()){
+ firstLetter = chatTitle.charAt(0) + "";
+ firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+ }
initialLetter.setText(firstLetter);
}
@@ -1529,7 +1570,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/lollipop/megachat/NodeAttachmentActivityLollipop.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentActivityLollipop.java
deleted file mode 100644
index 736dd673bd9..00000000000
--- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentActivityLollipop.java
+++ /dev/null
@@ -1,984 +0,0 @@
-package mega.privacy.android.app.lollipop.megachat;
-
-import android.Manifest;
-import android.annotation.SuppressLint;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.StatFs;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.ActionBar;
-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.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.io.File;
-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.MegaPreferences;
-import mega.privacy.android.app.R;
-import mega.privacy.android.app.components.SimpleDividerItemDecoration;
-import mega.privacy.android.app.lollipop.FileExplorerActivityLollipop;
-import mega.privacy.android.app.lollipop.FileStorageActivityLollipop;
-import mega.privacy.android.app.lollipop.FileStorageActivityLollipop.Mode;
-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.adapters.MegaNodeAdapter;
-import mega.privacy.android.app.lollipop.controllers.ChatController;
-import mega.privacy.android.app.modalbottomsheet.chatmodalbottomsheet.NodeAttachmentBottomSheetDialogFragment;
-import mega.privacy.android.app.snackbarListeners.SnackbarNavigateOption;
-import mega.privacy.android.app.utils.Constants;
-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.MegaChatApiJava;
-import nz.mega.sdk.MegaChatError;
-import nz.mega.sdk.MegaChatMessage;
-import nz.mega.sdk.MegaChatRequest;
-import nz.mega.sdk.MegaChatRequestListenerInterface;
-import nz.mega.sdk.MegaError;
-import nz.mega.sdk.MegaNode;
-import nz.mega.sdk.MegaNodeList;
-import nz.mega.sdk.MegaRequest;
-import nz.mega.sdk.MegaRequestListenerInterface;
-
-public class NodeAttachmentActivityLollipop extends PinActivityLollipop implements MegaChatRequestListenerInterface, MegaRequestListenerInterface, OnClickListener{
-
- NodeAttachmentActivityLollipop nodeAttachmentActivity = this;
- MegaApiAndroid megaApi;
- MegaChatApiAndroid megaChatApi;
-
- ActionBar aB;
- Toolbar tB;
-
- RecyclerView listView;
- LinearLayoutManager mLayoutManager;
- public MegaNode selectedNode;
- ImageView emptyImageView;
- TextView emptyTextView;
- TextView contentText;
- RelativeLayout fragmentContainer;
- Button downloadButton;
- View separator;
- Button importButton;
- LinearLayout optionsBar;
- DisplayMetrics outMetrics;
-
- ArrayList nodes;
- MegaNodeAdapter adapterList;
-
- private android.support.v7.app.AlertDialog downloadConfirmationDialog;
-
- MegaNodeList nodeList;
- AndroidMegaChatMessage message = null;
- public long chatId;
- public long messageId;
-
- ChatController cC;
-
- DatabaseHandler dbH = null;
- MegaPreferences prefs = null;
-
- public static int REQUEST_CODE_SELECT_LOCAL_FOLDER = 1004;
-
- private ActionMode actionMode;
-
- Handler handler;
-
- public void activateActionMode(){
- log("activateActionMode");
- if (!adapterList.isMultipleSelect()){
- adapterList.setMultipleSelect(true);
- actionMode = startSupportActionMode(new ActionBarCallBack());
- }
- }
-
- private class ActionBarCallBack implements ActionMode.Callback {
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
-
- List documents = adapterList.getSelectedNodes();
-
- switch(item.getItemId()){
- case R.id.cab_menu_download:{
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(nodeAttachmentActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (!hasStoragePermission) {
- ActivityCompat.requestPermissions(nodeAttachmentActivity,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
-
- handleListM.clear();
- for (int i=0;i handleList = new ArrayList();
- for (int i=0;i selected = adapterList.getSelectedNodes();
- boolean showDownload = false;
-
- if (selected.size() != 0) {
- if (selected.size() > 0) {
- showDownload = true;
- }
- if(selected.size()==adapterList.getItemCount()){
- menu.findItem(R.id.cab_menu_select_all).setVisible(false);
- menu.findItem(R.id.cab_menu_unselect_all).setVisible(true);
- }
- else{
- menu.findItem(R.id.cab_menu_select_all).setVisible(true);
- menu.findItem(R.id.cab_menu_unselect_all).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.cab_menu_download).setVisible(showDownload);
-
- return false;
- }
-
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- log("onOptionsItemSelected");
- switch (item.getItemId()) {
- // Respond to the action bar's Up/Home button
- case android.R.id.home:{
- onBackPressed();
- return true;
- }
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- log("onCreate()");
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- super.onCreate(savedInstanceState);
-
- Display display = getWindowManager().getDefaultDisplay();
- outMetrics = new DisplayMetrics ();
- display.getMetrics(outMetrics);
-
- MegaApplication app = (MegaApplication)getApplication();
- megaApi = app.getMegaApi();
-
- handler = new Handler();
-
- 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){
- 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;
- }
-
- nodeAttachmentActivity = this;
-
- nodes = new ArrayList();
-
- cC = new ChatController(this);
-
- 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_folder_link);
-
- //Set toolbar
- tB = (Toolbar) findViewById(R.id.toolbar_folder_link);
- setSupportActionBar(tB);
- aB = getSupportActionBar();
-// aB.setHomeAsUpIndicator(R.drawable.ic_menu_white);
- aB.setDisplayHomeAsUpEnabled(true);
- aB.setDisplayShowHomeEnabled(true);
-
- fragmentContainer = (RelativeLayout) findViewById(R.id.folder_link_fragment_container);
-
- emptyImageView = (ImageView) findViewById(R.id.folder_link_list_empty_image);
- emptyTextView = (TextView) findViewById(R.id.folder_link_list_empty_text);
-
- listView = (RecyclerView) findViewById(R.id.folder_link_list_view_browser);
- listView.addItemDecoration(new SimpleDividerItemDecoration(this, outMetrics));
- mLayoutManager = new LinearLayoutManager(this);
- listView.setLayoutManager(mLayoutManager);
- listView.setItemAnimator(new DefaultItemAnimator());
-
- optionsBar = (LinearLayout) findViewById(R.id.options_folder_link_layout);
- separator = (View) findViewById(R.id.separator_3);
-
- downloadButton = (Button) findViewById(R.id.folder_link_button_download);
- downloadButton.setOnClickListener(this);
-
- importButton = (Button) findViewById(R.id.folder_link_import_button);
- importButton.setOnClickListener(this);
-
- if (dbH == null){
- dbH = DatabaseHandler.getDbHandler(getApplicationContext());
- }
- if (dbH != null){
- if (dbH.getCredentials() != null){
- importButton.setVisibility(View.VISIBLE);
- }
- else{
- importButton.setVisibility(View.INVISIBLE);
- }
- }
-
- contentText = (TextView) findViewById(R.id.content_text);
- contentText.setVisibility(View.GONE);
-
- Intent intent = getIntent();
-
- if (intent != null) {
- chatId = intent.getLongExtra("chatId", -1);
- messageId = intent.getLongExtra("messageId", -1);
- log("Id Chat and Message id: "+chatId+ "___"+messageId);
- MegaChatMessage messageMega = megaChatApi.getMessage(chatId, messageId);
- if(messageMega!=null){
- message = new AndroidMegaChatMessage(messageMega);
- }
- }
-
- if(message!=null){
- setNodes();
- }
- else{
- finish();
- }
-
- aB.setTitle(getString(R.string.activity_title_files_attached));
- if(message.getMessage().getUserHandle()==megaChatApi.getMyUserHandle()) {
- aB.setSubtitle(megaChatApi.getMyFullname());
- }
- else{
- String fullNameAction = cC.getFullName(message.getMessage().getUserHandle(), chatId);
-
- if(fullNameAction==null){
- fullNameAction = "";
- }
- aB.setSubtitle(fullNameAction);
- }
-
- if (dbH == null){
- dbH = DatabaseHandler.getDbHandler(getApplicationContext());
- }
-
- if (adapterList == null){
- adapterList = new MegaNodeAdapter(this, null, nodes, -1, listView, aB, Constants.NODE_ATTACHMENT_ADAPTER, MegaNodeAdapter.ITEM_VIEW_TYPE_LIST);
- }
- else{
-// adapterList.setParentHandle(parentHandle);
- adapterList.setNodes(nodes);
- }
-
- adapterList.setMultipleSelect(false);
-
- listView.setAdapter(adapterList);
- }
-
- public void setNodes(){
- log("setNodes");
-// nodes.clear();
- nodeList = message.getMessage().getMegaNodeList();
- ArrayList nodesTemp = MegaApiJava.nodeListToArray(nodeList);
- for(int i=0;i 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(Util.scaleWidthPx(20, outMetrics), Util.scaleHeightPx(10, outMetrics), 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.setTitle(getString(R.string.confirmation_required));
-
- builder.setMessage(getString(R.string.alert_larger_file, 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 importNode(){
- log("importNodes");
-
- Intent intent = new Intent(this, FileExplorerActivityLollipop.class);
- intent.setAction(FileExplorerActivityLollipop.ACTION_PICK_IMPORT_FOLDER);
- startActivityForResult(intent, Constants.REQUEST_CODE_IMPORT_CHAT_NODE);
- }
-
- public void importNodeList(){
- log("importNodes");
-
- Intent intent = new Intent(this, FileExplorerActivityLollipop.class);
- intent.setAction(FileExplorerActivityLollipop.ACTION_PICK_IMPORT_FOLDER);
- startActivityForResult(intent, Constants.REQUEST_CODE_IMPORT_CHAT_NODE_LIST);
- }
-
- @Override
- protected void onPause() {
- nodeAttachmentActivity = null;
- log("onPause");
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- nodeAttachmentActivity = this;
- log("onResume");
- }
-
- @SuppressLint("NewApi") public void onFolderClick(long handle, long size){
- log("onFolderClick");
-
- long[] hashes = new long[1];
-
- hashes[0] = handle;
-
- if (dbH == null){
-// dbH = new DatabaseHandler(getApplicationContext());
- dbH = DatabaseHandler.getDbHandler(getApplicationContext());
- }
-
- boolean askMe = true;
- String downloadLocationDefaultPath = "";
- prefs = dbH.getPreferences();
- if (prefs != null){
- if (prefs.getStorageAskAlways() != null){
- if (!Boolean.parseBoolean(prefs.getStorageAskAlways())){
- if (prefs.getStorageDownloadLocation() != null){
- if (prefs.getStorageDownloadLocation().compareTo("") != 0){
- askMe = false;
- downloadLocationDefaultPath = prefs.getStorageDownloadLocation();
- }
- }
- }
- }
- }
-
- if (askMe){
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- File[] fs = getExternalFilesDirs(null);
- if (fs.length > 1){
- if (fs[1] == null){
- Intent intent = new Intent(Mode.PICK_FOLDER.getAction());
- intent.putExtra(FileStorageActivityLollipop.EXTRA_BUTTON_PREFIX, getString(R.string.context_download_to));
- intent.putExtra(FileStorageActivityLollipop.EXTRA_SIZE, size);
- intent.setClass(this, FileStorageActivityLollipop.class);
- intent.putExtra(FileStorageActivityLollipop.EXTRA_DOCUMENT_HASHES, hashes);
- startActivityForResult(intent, REQUEST_CODE_SELECT_LOCAL_FOLDER);
- }
- else{
- Dialog downloadLocationDialog;
- String[] sdCardOptions = getResources().getStringArray(R.array.settings_storage_download_location_array);
- AlertDialog.Builder b=new AlertDialog.Builder(this);
-
- b.setTitle(getResources().getString(R.string.settings_storage_download_location));
- final long sizeFinal = size;
- final long[] hashesFinal = new long[hashes.length];
- for (int i=0; i< hashes.length; i++){
- hashesFinal[i] = hashes[i];
- }
-
- b.setItems(sdCardOptions, new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- switch(which){
- case 0:{
- Intent intent = new Intent(Mode.PICK_FOLDER.getAction());
- intent.putExtra(FileStorageActivityLollipop.EXTRA_BUTTON_PREFIX, getString(R.string.context_download_to));
- intent.putExtra(FileStorageActivityLollipop.EXTRA_SIZE, sizeFinal);
- intent.setClass(getApplicationContext(), FileStorageActivityLollipop.class);
- intent.putExtra(FileStorageActivityLollipop.EXTRA_DOCUMENT_HASHES, hashesFinal);
- startActivityForResult(intent, REQUEST_CODE_SELECT_LOCAL_FOLDER);
- break;
- }
- case 1:{
- File[] fs = getExternalFilesDirs(null);
- if (fs.length > 1){
- String path = fs[1].getAbsolutePath();
- File defaultPathF = new File(path);
- defaultPathF.mkdirs();
- Toast.makeText(getApplicationContext(), getString(R.string.general_save_to_device) + ": " + defaultPathF.getAbsolutePath() , Toast.LENGTH_LONG).show();
- downloadTo(path, null, sizeFinal, hashesFinal);
- }
- break;
- }
- }
- }
- });
- b.setNegativeButton(getResources().getString(R.string.general_cancel), new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- downloadLocationDialog = b.create();
- downloadLocationDialog.show();
- }
- }
- else{
- Intent intent = new Intent(Mode.PICK_FOLDER.getAction());
- intent.putExtra(FileStorageActivityLollipop.EXTRA_BUTTON_PREFIX, getString(R.string.context_download_to));
- intent.putExtra(FileStorageActivityLollipop.EXTRA_SIZE, size);
- intent.setClass(this, FileStorageActivityLollipop.class);
- intent.putExtra(FileStorageActivityLollipop.EXTRA_DOCUMENT_HASHES, hashes);
- startActivityForResult(intent, REQUEST_CODE_SELECT_LOCAL_FOLDER);
- }
- }
- else{
- Intent intent = new Intent(Mode.PICK_FOLDER.getAction());
- intent.putExtra(FileStorageActivityLollipop.EXTRA_BUTTON_PREFIX, getString(R.string.context_download_to));
- intent.putExtra(FileStorageActivityLollipop.EXTRA_SIZE, size);
- intent.setClass(this, FileStorageActivityLollipop.class);
- intent.putExtra(FileStorageActivityLollipop.EXTRA_DOCUMENT_HASHES, hashes);
- startActivityForResult(intent, REQUEST_CODE_SELECT_LOCAL_FOLDER);
- }
- }
- else{
- downloadTo(downloadLocationDefaultPath, null, size, hashes);
- }
- }
-
- public void downloadTo(String parentPath, String url, long size, long [] hashes){
- log("downloadTo");
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (!hasStoragePermission) {
- ActivityCompat.requestPermissions(this,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
- }
- }
-
- double availableFreeSpace = Double.MAX_VALUE;
- try{
- StatFs stat = new StatFs(parentPath);
- availableFreeSpace = (double)stat.getAvailableBlocks() * (double)stat.getBlockSize();
- }
- catch(Exception ex){}
-
-
-
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
- log("onActivityResult");
- if (intent == null){
- return;
- }
-
- if (requestCode == Constants.REQUEST_CODE_IMPORT_CHAT_NODE && resultCode == RESULT_OK) {
- log("onActivityResult REQUEST_CODE_IMPORT_CHAT_NODE OK");
-
- if(!Util.isOnline(this)) {
-
- Snackbar.make(fragmentContainer, getString(R.string.error_server_connection_problem), Snackbar.LENGTH_LONG).show();
- return;
- }
-
- final long toHandle = intent.getLongExtra("IMPORT_TO", 0);
-
- MegaNode target = null;
- target = megaApi.getNodeByHandle(toHandle);
- if(target == null){
- target = megaApi.getRootNode();
- }
- log("TARGET: " + target.getName() + "and handle: " + target.getHandle());
-
- if (selectedNode != null) {
- log("DOCUMENT: " + selectedNode.getName() + "_" + selectedNode.getHandle());
- if (target != null) {
-// MegaNode autNode = megaApi.authorizeNode(document);
-
- megaApi.copyNode(selectedNode, target, this);
- } else {
- log("TARGET: null");
- Snackbar.make(fragmentContainer, getString(R.string.import_success_error), Snackbar.LENGTH_LONG).show();
- }
- }
- else{
- log("DOCUMENT: null");
- Snackbar.make(fragmentContainer, getString(R.string.import_success_error), Snackbar.LENGTH_LONG).show();
- }
- }
- else if (requestCode == Constants.REQUEST_CODE_IMPORT_CHAT_NODE_LIST && resultCode == RESULT_OK) {
- log("onActivityResult REQUEST_CODE_SELECT_IMPORT_FOLDER OK");
-
- if(!Util.isOnline(this)) {
-
- Snackbar.make(fragmentContainer, getString(R.string.error_server_connection_problem), Snackbar.LENGTH_LONG).show();
- return;
- }
-
- final long toHandle = intent.getLongExtra("IMPORT_TO", 0);
-
- MegaNode target = null;
- target = megaApi.getNodeByHandle(toHandle);
- if(target == null){
- target = megaApi.getRootNode();
- }
- log("TARGET: " + target.getName() + "and handle: " + target.getHandle());
-
- for(int i=0;i= Build.VERSION_CODES.HONEYCOMB)
-// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
-// startActivity(intent);
-// finish();
- }
-
- }else{
- log("OK");
- Snackbar.make(fragmentContainer, getString(R.string.context_correctly_copied), Snackbar.LENGTH_LONG).show();
-// Intent intent = new Intent(this, ManagerActivityLollipop.class);
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
-// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
-// startActivity(intent);
-// finish();
- }
- }
-
- }
-
- @Override
- public void onRequestTemporaryError(MegaApiJava api, MegaRequest request,
- MegaError e) {
- log("onRequestTemporaryError: " + request.getRequestString());
- }
-
- @Override
- public void onRequestStart(MegaChatApiJava api, MegaChatRequest request) {
-
- }
-
- @Override
- public void onRequestUpdate(MegaChatApiJava api, MegaChatRequest request) {
-
- }
-
- public void removeNodeFromList(long handle){
- log("removeNodeFromList");
- int position = -1;
- for(int i=0; i documents = adapterList.getSelectedNodes();
- int files = 0;
- int folders = 0;
- for (MegaNode document : documents) {
- if (document.isFile()) {
- files++;
- } else if (document.isFolder()) {
- folders++;
- }
- }
- Resources res = getResources();
- String format = "%d %s";
- String filesStr = String.format(format, files,
- res.getQuantityString(R.plurals.general_num_files, files));
- String foldersStr = String.format(format, folders,
- res.getQuantityString(R.plurals.general_num_folders, folders));
- String title;
- if (files == 0 && folders == 0) {
- title = foldersStr + ", " + filesStr;
- } else if (files == 0) {
- title = foldersStr;
- } else if (folders == 0) {
- title = filesStr;
- } else {
- title = foldersStr + ", " + filesStr;
- }
- actionMode.setTitle(title);
- try {
- actionMode.invalidate();
- } catch (NullPointerException e) {
- e.printStackTrace();
- log("oninvalidate error");
- }
- // actionMode.
- }
-
- ArrayList handleListM = new ArrayList();
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- switch(requestCode){
- case Constants.REQUEST_WRITE_STORAGE:{
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (hasStoragePermission) {
- log("Download");
- }
- break;
- }
- }
- }
-
- public void downloadNode(){
- log("Download option");
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (!hasStoragePermission) {
- ActivityCompat.requestPermissions(this,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
-
- handleListM.clear();
- handleListM.add(selectedNode.getHandle());
- return;
- }
- }
-
- ArrayList handleList = new ArrayList();
- handleList.add(selectedNode.getHandle());
-// onFileClick(handleList);
- }
-
- @Override
- public void onClick(View v) {
- log("onClick");
- switch(v.getId()){
- case R.id.folder_link_button_download:{
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- boolean hasStoragePermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
- if (!hasStoragePermission) {
- ActivityCompat.requestPermissions(this,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
- Constants.REQUEST_WRITE_STORAGE);
-
- return;
- }
- }
-
- cC.prepareForChatDownload(nodeList);
-
- break;
- }
- case R.id.folder_link_import_button:{
- importNodeList();
- break;
- }
- }
- }
-
- public void showOptionsPanel(MegaNode sNode){
- log("showNodeOptionsPanel-Offline");
- if(sNode!=null){
- this.selectedNode = sNode;
- NodeAttachmentBottomSheetDialogFragment bottomSheetDialogFragment = new NodeAttachmentBottomSheetDialogFragment();
- bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
- }
- }
-
- public void showSnackbar(String s){
- log("showSnackbar");
- 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();
- }
-
- public void showSnackbarNotSpace(){
- log("showSnackbarNotSpace");
- Snackbar mySnackbar = Snackbar.make(fragmentContainer, R.string.error_not_enough_free_space, Snackbar.LENGTH_LONG);
- mySnackbar.setAction("Settings", new SnackbarNavigateOption(this));
- mySnackbar.show();
- }
-
- public MegaNode getSelectedNode() {
- return selectedNode;
- }
-
- public void setSelectedNode(MegaNode selectedNode) {
- this.selectedNode = selectedNode;
- }
-}
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..d8261059f3b
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/NodeAttachmentHistoryActivity.java
@@ -0,0 +1,1784 @@
+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.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;
+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.text.Html;
+import android.text.Spanned;
+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.CheckBox;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+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.NewGridRecyclerView;
+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;
+import mega.privacy.android.app.lollipop.listeners.MultipleRequestListener;
+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;
+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.MegaError;
+import nz.mega.sdk.MegaNode;
+import nz.mega.sdk.MegaNodeList;
+import nz.mega.sdk.MegaRequest;
+import nz.mega.sdk.MegaRequestListenerInterface;
+
+public class NodeAttachmentHistoryActivity extends PinActivityLollipop implements MegaChatRequestListenerInterface, MegaRequestListenerInterface, RecyclerView.OnItemTouchListener, 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;
+
+ 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;
+ RelativeLayout emptyLayout;
+ TextView emptyTextView;
+ ImageView emptyImageView;
+
+ MenuItem importIcon;
+ private MenuItem thumbViewMenuItem;
+
+ ArrayList messages;
+ ArrayList bufferMessages;
+
+ public MegaChatRoom chatRoom;
+
+ NodeAttachmentHistoryAdapter adapter;
+ boolean scrollingUp = false;
+ boolean getMoreHistory=false;
+ boolean isLoadingHistory = false;
+
+ private ActionMode actionMode;
+ DisplayMetrics outMetrics;
+
+ ProgressDialog statusDialog;
+
+ MenuItem selectMenuItem;
+ MenuItem unSelectMenuItem;
+
+ Handler handler;
+ int stateHistory;
+ public long chatId = -1;
+ public long selectedMessageId = -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();
+
+ dbH = DatabaseHandler.getDbHandler(this);
+
+ Display display = getWindowManager().getDefaultDisplay();
+ 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_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);
+ aB = getSupportActionBar();
+// aB.setHomeAsUpIndicator(R.drawable.ic_menu_white);
+ aB.setDisplayHomeAsUpEnabled(true);
+ aB.setDisplayShowHomeEnabled(true);
+
+ 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());
+
+ 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 SimpleDividerItemDecoration(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.setHasFixedSize(true);
+
+ 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->loadAttachments:scrolling down");
+ isLoadingHistory = true;
+ stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD);
+ getMoreHistory = false;
+ }
+ }
+ }
+ checkScroll();
+ }
+ });
+
+
+ Bundle extras = getIntent().getExtras();
+ if (extras != null){
+ if(chatId==-1){
+ chatId = extras.getLong("chatId");
+ }
+
+ chatRoom=megaChatApi.getChatRoom(chatId);
+
+ if(chatRoom!=null){
+ messages = new ArrayList<>();
+ bufferMessages = new ArrayList();
+
+ if (messages.size() != 0){
+ emptyLayout.setVisibility(View.GONE);
+ listView.setVisibility(View.VISIBLE);
+ }
+ else{
+ emptyLayout.setVisibility(View.VISIBLE);
+ listView.setVisibility(View.GONE);
+ }
+
+ boolean resultOpen = megaChatApi.openNodeHistory(chatId, this);
+ if(resultOpen){
+ log("Node history opened correctly");
+
+ messages = new ArrayList();
+
+ 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);
+
+ adapter.setMessages(messages);
+
+ isLoadingHistory = true;
+ log("A->loadAttachments");
+ stateHistory = megaChatApi.loadAttachments(chatId, NUMBER_MESSAGES_TO_LOAD);
+ }
+ }
+ else{
+ log("ERROR: node is NULL");
+ }
+ }
+ }
+
+ 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_node_history, menu);
+
+ selectMenuItem = menu.findItem(R.id.action_select);
+ unSelectMenuItem = menu.findItem(R.id.action_unselect);
+ thumbViewMenuItem= menu.findItem(R.id.action_grid);
+
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+
+ if(messages.size()>0){
+ selectMenuItem.setVisible(true);
+ // 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));
+// }
+ }
+ else{
+ selectMenuItem.setVisible(false);
+ }
+
+ unSelectMenuItem.setVisible(false);
+ thumbViewMenuItem.setVisible(false);
+
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // 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;
+ }
+ 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);
+ }
+ }
+ }
+
+ 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()){
+ 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("NodeAttachmentHistoryActivity", log);
+ }
+
+
+ public void itemClick(int position) {
+ log("itemClick");
+ if(megaChatApi.isSignalActivityRequired()){
+ megaChatApi.signalPresenceActivity();
+ }
+
+ 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 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);
+ if(chatRoom!=null){
+ 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 ArrayList messagesSelected = 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.chat_cab_menu_forward: {
+ log("Forward message");
+ clearSelections();
+ hideMultipleSelect();
+ forwardMessages(messagesSelected);
+ break;
+ }
+ 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 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()) {
+ 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);
+ }
+
+ 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.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;
+ }
+ }
+
+ public void showConfirmationDeleteMessages(final ArrayList 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);
+ chatC.prepareMessagesToForward(messagesSelected, chatId);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ log("onActivityResult, resultCode: " + resultCode);
+ if (requestCode == Constants.REQUEST_CODE_SELECT_IMPORT_FOLDER && resultCode == RESULT_OK) {
+ if(!Util.isOnline(this) || megaApi==null) {
+ try{
+ statusDialog.dismiss();
+ } catch(Exception ex) {};
+
+ Snackbar.make(container, getString(R.string.error_server_connection_problem), Snackbar.LENGTH_LONG).show();
+ return;
+ }
+
+ final long toHandle = intent.getLongExtra("IMPORT_TO", 0);
+
+ final long[] importMessagesHandles = intent.getLongArrayExtra("HANDLES_IMPORT_CHAT");
+
+ importNodes(toHandle, importMessagesHandles);
+ }
+ else if (requestCode == Constants.REQUEST_CODE_SELECT_CHAT && resultCode == RESULT_OK) {
+ if(!Util.isOnline(this)) {
+ try{
+ statusDialog.dismiss();
+ } catch(Exception ex) {};
+
+ Snackbar.make(container, getString(R.string.error_server_connection_problem), Snackbar.LENGTH_LONG).show();
+ return;
+ }
+
+ showProgressForwarding();
+
+ long[] chatHandles = intent.getLongArrayExtra("SELECTED_CHATS");
+ log("Send to "+chatHandles.length+" chats");
+
+ long[] idMessages = intent.getLongArrayExtra("ID_MESSAGES");
+ log("Send "+idMessages.length+" messages");
+
+ MultipleForwardChatProcessor forwardChatProcessor = new MultipleForwardChatProcessor(this, chatHandles, idMessages, chatId);
+
+ forwardChatProcessor.forward();
+ }
+ }
+
+ public void showProgressForwarding(){
+ log("showProgressForwarding");
+
+ statusDialog = new ProgressDialog(this);
+ statusDialog.setMessage(getString(R.string.general_forwarding));
+ statusDialog.show();
+ }
+
+ public void removeProgressDialog(){
+ try{
+ statusDialog.dismiss();
+ } catch(Exception ex) {};
+ }
+
+ public void importNodes(final long toHandle, final long[] importMessagesHandles){
+ log("importNode: "+toHandle+ " -> "+ importMessagesHandles.length);
+ statusDialog = new ProgressDialog(this);
+ statusDialog.setMessage(getString(R.string.general_importing));
+ statusDialog.show();
+
+ MegaNode target = null;
+ target = megaApi.getNodeByHandle(toHandle);
+ if(target == null){
+ target = megaApi.getRootNode();
+ }
+ log("TARGET: " + target.getName() + "and handle: " + target.getHandle());
+
+ if(importMessagesHandles.length==1){
+ for (int k = 0; k < importMessagesHandles.length; k++){
+ MegaChatMessage message = megaChatApi.getMessage(chatId, importMessagesHandles[k]);
+ if(message!=null){
+
+ MegaNodeList nodeList = message.getMegaNodeList();
+
+ for(int i=0;i=NUMBER_MESSAGES_TO_LOAD){
+ fullHistoryReceivedOnLoad();
+ isLoadingHistory = false;
+ }
+ else{
+ log("onAttachmentLoaded:lessNumberReceived");
+ if((stateHistory!=MegaChatApi.SOURCE_NONE)&&(stateHistory!=MegaChatApi.SOURCE_ERROR)){
+ log("But more history exists --> loadAttachments");
+ log("G->loadAttachments");
+ isLoadingHistory = true;
+ 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){
+ fullHistoryReceivedOnLoad();
+ isLoadingHistory = false;
+ }
+ }
+ else{
+ log("New state of history: "+stateHistory);
+ fullHistoryReceivedOnLoad();
+ isLoadingHistory = false;
+ }
+ }
+ }
+ }
+
+ public void fullHistoryReceivedOnLoad() {
+ 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);
+ }
+
+ 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;
+
+ invalidateOptionsMenu();
+ }
+
+ @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);
+
+ invalidateOptionsMenu();
+ }
+
+ @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");
+ }
+
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public void onTruncate(MegaChatApiJava api, long msgid) {
+ log("onTruncate");
+ invalidateOptionsMenu();
+ messages.clear();
+ adapter.notifyDataSetChanged();
+ listView.setVisibility(View.GONE);
+ emptyLayout.setVisibility(View.VISIBLE);
+ }
+
+ public void showNodeAttachmentBottomSheet(MegaChatMessage message, int position){
+ log("showNodeAttachmentBottomSheet: "+position);
+ //this.selectedPosition = position;
+ if(message!=null){
+ this.selectedMessageId = message.getMsgId();
+
+ NodeAttachmentBottomSheetDialogFragment bottomSheetDialogFragment = new NodeAttachmentBottomSheetDialogFragment();
+ bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
+ }
+ }
+
+ 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())) {
+ changeActionBarElevation(true);
+ }
+ else {
+ changeActionBarElevation(false);
+ }
+ }
+ }
+
+ public void changeActionBarElevation(boolean whitElevation){
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (whitElevation) {
+ aB.setElevation(Util.px2dp(4, outMetrics));
+ }
+ else {
+ aB.setElevation(0);
+ }
+ }
+ }
+}
+
diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/PendingMessageSingle.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/PendingMessageSingle.java
index a7dafb9f62f..868ca624418 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/PendingMessageSingle.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/PendingMessageSingle.java
@@ -3,9 +3,11 @@
public class PendingMessageSingle {
public static int STATE_PREPARING = 0;
- public static int STATE_UPLOADING = 1;
- public static int STATE_ATTACHING = 2;
- public static int STATE_SENT = 3;
+ public static int STATE_PREPARING_FROM_EXPLORER = 1;
+ public static int STATE_UPLOADING = 2;
+ public static int STATE_ATTACHING = 3;
+ public static int STATE_SENT = 20;
+ //Error negative figures
public static int STATE_ERROR_UPLOADING = -1;
public static int STATE_ERROR_ATTACHING = -2;
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 bb5a597cc62..f4f98874479 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
@@ -282,7 +282,7 @@ public void setChats(){
}
}
else{
- log("chats no: "+chats.size());
+ log("setChats:chats size: "+chats.size());
//Order by last interaction
Collections.sort(chats, new Comparator (){
@@ -353,21 +353,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{
@@ -1254,6 +1258,7 @@ else if(item.hasChanged(MegaChatListItem.CHANGE_TYPE_ARCHIVE)){
}
else{
log("New unarchived element:refresh chat list");
+
setChats();
}
//Update last position
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/BigCameraGroupCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.java
new file mode 100644
index 00000000000..0968e90f11f
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/BigCameraGroupCallFragment.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.TextureView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.RelativeLayout;
+
+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 BigCameraGroupCallFragment extends Fragment implements MegaChatVideoListenerInterface {
+
+ int width = 0;
+ int height = 0;
+ Bitmap bitmap;
+ MegaChatApiAndroid megaChatApi;
+ Context context;
+ long chatId;
+ Long userHandle;
+
+ public TextureView myTexture;
+ MegaSurfaceRendererGroup renderer;
+
+ 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;
+ }
+
+ @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);
+ 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_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);
+
+
+ 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);
+ }
+
+ 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;
+
+ int viewWidth = myTexture.getWidth();
+ int viewHeight = myTexture.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 = renderer.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
+ renderer.DrawBitmap(false);
+ }
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ this.context = context;
+ }
+
+ @Override
+ public void onDestroy(){
+ log("onDestroy");
+ if(myTexture.getParent()!=null){
+ if(myTexture.getParent().getParent()!=null){
+ log("onDestroy() removeView chatId: "+chatId);
+ ((ViewGroup)myTexture.getParent()).removeView(myTexture);
+ }
+ }
+ 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();
+ }
+ @Override
+ public void onResume() {
+ log("onResume");
+ super.onResume();
+ }
+
+ private static void log(String log) {
+ Util.log("BigCameraGroupCallFragment", log);
+ }
+}
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 54142977b91..3b3bf3d1206 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
@@ -86,7 +86,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;
@@ -96,7 +98,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) {
if(call.getChatid()==chatId){
- if(call.getStatus()==MegaChatCall.CALL_STATUS_TERMINATING){
+ if(call.getStatus()==MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION){
log("Destroy call Service");
stopForeground(true);
mNotificationManager.cancel(Constants.NOTIFICATION_CALL_IN_PROGRESS);
@@ -137,12 +139,24 @@ public void showCallInProgressNotification(){
MegaChatRoom chat = megaChatApi.getChatRoom(chatId);
if (chat != null) {
title = chat.getTitle();
- userHandle = chat.getPeerHandle(0);
- email = chat.getPeerEmail(0);
- Bitmap largeIcon = setProfileContactAvatar(userHandle, title, email);
- if (largeIcon != null) {
- mBuilderCompatO.setLargeIcon(largeIcon);
+ if(chat.isGroup()){
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
+ Bitmap largeIcon = createDefaultAvatar(-1, title);
+ if(largeIcon!=null){
+ mBuilderCompatO.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){
+ mBuilderCompatO.setLargeIcon(largeIcon);
+ }
+ }
}
mBuilderCompatO.setContentTitle(title);
@@ -185,14 +199,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));
} else {
@@ -225,24 +251,19 @@ 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);
}
}
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;
@@ -271,13 +292,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);
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 b0542beccf4..e90389d4fbd 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,14 +6,13 @@
import android.content.Intent;
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;
import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.PixelFormat;
-import android.graphics.Rect;
-import android.graphics.Typeface;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -29,22 +28,32 @@
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.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;
+import android.support.v7.widget.LinearLayoutManager;
+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;
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;
@@ -61,9 +70,10 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Locale;
import java.util.TimeZone;
import java.util.Timer;
@@ -75,10 +85,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.CustomizedGridCallRecyclerView;
import mega.privacy.android.app.fcm.IncomingCallService;
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;
import mega.privacy.android.app.utils.Constants;
import mega.privacy.android.app.utils.ThumbnailUtilsLollipop;
import mega.privacy.android.app.utils.Util;
@@ -93,35 +106,32 @@
import nz.mega.sdk.MegaChatRequest;
import nz.mega.sdk.MegaChatRequestListenerInterface;
import nz.mega.sdk.MegaChatRoom;
-import nz.mega.sdk.MegaChatVideoListenerInterface;
+import nz.mega.sdk.MegaChatSession;
import nz.mega.sdk.MegaError;
import nz.mega.sdk.MegaRequest;
import nz.mega.sdk.MegaRequestListenerInterface;
import nz.mega.sdk.MegaUser;
+import android.provider.CallLog;
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 BaseActivity implements MegaChatRequestListenerInterface,View.OnTouchListener, MegaChatCallListenerInterface, MegaChatVideoListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback {
+public class ChatCallActivity extends BaseActivity implements MegaChatRequestListenerInterface, MegaChatCallListenerInterface, MegaRequestListenerInterface, View.OnClickListener, SensorEventListener, KeyEvent.Callback {
DatabaseHandler dbH = null;
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;
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;
@@ -135,7 +145,7 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
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;
@@ -143,14 +153,37 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
float scaleH;
AppBarLayout appBarLayout;
Toolbar tB;
- ActionBar aB;
+ LinearLayout toolbarElements;
+ TextView titleToolbar;
+ TextView subtitleToobar;
+ LinearLayout linearParticipants;
+ TextView participantText;
+ TextView infoUsersBar;
+ ActionBar aB;
boolean avatarRequested = false;
+ ArrayList peersOnCall = new ArrayList<>();
+ ArrayList peersBeforeCall = new ArrayList<>();
+
Timer timer = null;
Timer ringerTimer = null;
long milliseconds = 0;
+ RelativeLayout smallElementsIndividualCallLayout;
+ RelativeLayout bigElementsIndividualCallLayout;
+ RelativeLayout bigElementsGroupCallLayout;
+
+ RelativeLayout recyclerViewLayout;
+ CustomizedGridCallRecyclerView recyclerView;
+
+ RelativeLayout bigRecyclerViewLayout;
+ LinearLayoutManager layoutManager;
+ RecyclerView bigRecyclerView;
+
+ GroupCallAdapter adapterGrid;
+ GroupCallAdapter adapterList;
+
int isRemoteVideo = REMOTE_VIDEO_NOT_INIT;
Ringtone ringtone = null;
@@ -159,7 +192,6 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
//my avatar
RelativeLayout myAvatarLayout;
- RelativeLayout myImageBorder;
RoundedImageView myImage;
TextView myInitialLetter;
@@ -167,7 +199,8 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
RelativeLayout contactAvatarLayout;
RoundedImageView contactImage;
TextView contactInitialLetter;
- RelativeLayout contactImageBorder;
+
+ RelativeLayout fragmentContainer;
static ChatCallActivity chatCallActivityActivity = null;
@@ -177,20 +210,32 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
FloatingActionButton microFAB;
FloatingActionButton hangFAB;
FloatingActionButton answerCallFAB;
+ boolean isNecessaryCreateAdapter = true;
- SurfaceView remoteSurfaceView;
- MegaSurfaceRenderer remoteRenderer;
AudioManager audioManager;
MediaPlayer thePlayer;
FrameLayout fragmentContainerLocalCamera;
FrameLayout fragmentContainerLocalCameraFS;
+ FrameLayout fragmentContainerRemoteCameraFS;
- float heightFAB;
+ ViewGroup parentLocal;
+ ViewGroup parentLocalFS;
+ ViewGroup parentRemoteFS;
- String fullName = "";
- String email = "";
- long userHandle = -1;
+ private LocalCameraCallFragment localCameraFragment = null;
+ private LocalCameraCallFullScreenFragment localCameraFragmentFS = null;
+ private RemoteCameraCallFullScreenFragment remoteCameraFragmentFS = null;
+
+ //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;
private SensorManager mSensorManager;
private Sensor mSensor;
@@ -225,13 +270,19 @@ public class ChatCallActivity extends BaseActivity implements MegaChatRequestLis
long startTime, timeInMilliseconds = 0;
Handler customHandler = new Handler();
+ InfoPeerGroupCall peerSelected = null;
+ boolean isManualMode = false;
+ int statusBarHeight = 0;
+
+ private AlertDialog errorCallDialog;
+
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
log("onCreateOptionsMenu");
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_calls_chat, menu);
-
return super.onCreateOptionsMenu(menu);
}
@@ -240,36 +291,36 @@ public boolean onPrepareOptionsMenu(Menu menu) {
log("onPrepareOptionsMenu");
remoteAudioIcon = menu.findItem(R.id.info_remote_audio);
- if(callChat!=null){
- if(callChat.hasRemoteAudio()){
- 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));
+ 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("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");
((MegaApplication) getApplication()).sendSignalPresenceActivity();
-
int id = item.getItemId();
switch (id) {
case android.R.id.home: {
- log("Hang call");
+ log("home");
onBackPressed();
break;
}
@@ -278,86 +329,381 @@ 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);
- stopAudioSignals();
+ if(chat.isGroup()){
+ log("updateScreenStatusInProgress() - group chat - chatId: "+chatId);
- updateLocalVideoStatus();
- updateLocalAudioStatus();
- updateRemoteAudioStatus();
- updateRemoteVideoStatus();
- startClock();
- }
+ if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){
+ peersBeforeCall.clear();
+ }
- public void setCallInfo(){
- log("setCallInfo");
+ 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() == userHandle) {
+ peerContain = true;
+ break;
+ }
+ }
+ if (!peerContain) {
+ if (userHandle != megaChatApi.getMyUserHandle()) {
+ 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, true, null);
+ log("updateScreenStatusInProgress() "+myPeer.getName()+" added in peersOnCall");
+ peersOnCall.add(myPeer);
+ 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) {
+ log("updateScreenStatusInProgress() "+peersOnCall.get(i).getName()+" removed of peersOnCall");
+ peersOnCall.remove(i);
+ 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()){
+ 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;
- fullName = chat.getTitle();
- email = chat.getPeerEmail(0);
- userHandle = chat.getPeerHandle(0);
+ }else{
+ 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;
+ }
+ }
+ if(changes){
+ updatePeers(true);
+ }
+ }
+ }
- if (fullName.trim() != null) {
- if (fullName.trim().isEmpty()) {
- log("1 - Put email as fullname");
- String[] splitEmail = email.split("[@._]");
- fullName = splitEmail[0];
+ for(int i=0; i STATUS: "+callChat.getStatus());
+ 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);
+ if (userHandle == 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,true,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());
+
+ 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);
+
+ 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() == 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("onNewIntent() "+myPeer.getName()+" added in peersOnCall");
+ peersOnCall.add(myPeer);
+ changes = true;
+ } else {
+ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false, true,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) {
+ log("onNewIntent() "+peersOnCall.get(i).getName()+" removed of peersOnCall");
+ peersOnCall.remove(i);
+ changes = true;
+ }
+ }
+ if(changes){
+ updatePeers(true);
+ }
+
+ }else{
+ boolean changes = false;
+ for(int i=0; i 0) {
+ statusBarHeight = getResources().getDimensionPixelSize(resourceId);
+ }
+
+ widthScreenPX = outMetrics.widthPixels;
+ heightScreenPX = outMetrics.heightPixels - statusBarHeight;
+
+
MegaApplication app = (MegaApplication) getApplication();
if (megaApi == null) {
megaApi = app.getMegaApi();
@@ -437,8 +789,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);
@@ -458,6 +808,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) {
@@ -470,30 +821,57 @@ 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);
+
+ 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);
+ 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);
layoutCompress.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
linearFAB.setLayoutParams(layoutCompress);
+ 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.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.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);
@@ -515,32 +893,93 @@ 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);
+ //Cameras in Group call
+ bigElementsGroupCallLayout = (RelativeLayout) findViewById(R.id.big_elements_group_call);
+ bigElementsGroupCallLayout.setVisibility(GONE);
+
+ //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);
+// recyclerView.setHasFixedSize(true);
+ recyclerView.setColumnWidth((int) widthScreenPX);
+ recyclerView.setItemAnimator(new DefaultItemAnimator());
+ recyclerView.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= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
}
@@ -603,23 +1041,25 @@ protected void onCreate(Bundle savedInstanceState) {
int callStatus = callChat.getStatus();
log("The status of the callChat is: " + callStatus);
+ titleToolbar.setText(chat.getTitle());
+ updateSubTitleClock();
- setCallInfo();
-
- if(callStatus==MegaChatCall.CALL_STATUS_RING_IN){
- log("Incoming call");
+ if(chat.isGroup()){
+ smallElementsIndividualCallLayout.setVisibility(View.GONE);
+ bigElementsIndividualCallLayout.setVisibility(View.GONE);
+ bigElementsGroupCallLayout.setVisibility(View.VISIBLE);
- 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{
+ 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){
ringtone = RingtoneManager.getRingtone(this, DEFAULT_RINGTONE_URI);
-
ringerTimer = new Timer();
MyRingerTask myRingerTask = new MyRingerTask();
ringerTimer.schedule(myRingerTask, 0, 500);
@@ -633,37 +1073,94 @@ protected void onCreate(Bundle savedInstanceState) {
vibrator.vibrate(pattern, 0);
}
}
- }
- else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){
- updateScreenStatusInProgress();
- }
- else{
- log("Outgoing call");
+ if(chat.isGroup()){
+ log("onCreate()-Incoming group call");
- relativeVideo.getLayoutParams().height= RelativeLayout.LayoutParams.WRAP_CONTENT;
- relativeVideo.getLayoutParams().width= RelativeLayout.LayoutParams.WRAP_CONTENT;
- flagMyAvatar = false;
- setProfileMyAvatar();
- flagContactAvatar = true;
- setProfileContactAvatar();
+ //Get all the participants, add them to peersBeforeCall array and show only the avatars
+ if((peersBeforeCall != null)&&(peersBeforeCall.size() != 0)){
+ peersBeforeCall.clear();
+ }
+ if((peersOnCall != null)&&(peersOnCall.size() != 0)){
+ peersOnCall.clear();
+ }
+
+ if(callChat.getParticipants().size()!=0){
+ 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,true,null);
+ log("onCreate()- Incoming "+userPeer.getHandle()+" added in peersBeforeCall");
+ peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer);
+ changes = true;
+ }
+ if(changes){
+ updatePeers(false);
+ }
+ }
+ }else{
+ log("onCreate()-Incoming individual call");
+
+ myAvatarLayout.setVisibility(View.VISIBLE);
+ contactAvatarLayout.setVisibility(View.VISIBLE);
+ flagMyAvatar = true;
+ setProfileMyAvatar();
+ flagContactAvatar = false;
+ setProfileContactAvatar();
+ }
+ }else if(callStatus==MegaChatCall.CALL_STATUS_IN_PROGRESS){
+ log("onCreate()- In Progress");
+ updateScreenStatusInProgress();
+ }else if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){
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 {
+ }else {
thePlayer = MediaPlayer.create(getApplicationContext(), R.raw.outgoing_voice_video_call);
thePlayer.setLooping(true);
thePlayer.start();
}
+
+ if(chat.isGroup()){
+
+ log("onCreate()-Outgoing group call");
+
+ 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(), false,true,null);
+ log("onCreate()- Outgoing "+myPeer.getHandle()+" added in peersOnCall");
+ peersOnCall.add(myPeer);
+ updatePeers(true);
+
+ }else{
+ log("onCreate()-Outgoing individual call");
+
+ flagMyAvatar = false;
+ setProfileMyAvatar();
+ flagContactAvatar = true;
+ setProfileContactAvatar();
+ myAvatarLayout.setVisibility(View.VISIBLE);
+ }
updateLocalVideoStatus();
+ updateLocalAudioStatus();
+
+ }else if(callStatus==MegaChatCall.CALL_STATUS_JOINING){
+ log("onCreate()- Joining");
+ updateScreenStatusInProgress();
+
+ }else{
+
}
}
}
-
if(checkPermissions()){
- checkPermissionsWriteLog();
+// checkPermissionsWriteLog();
showInitialFABConfiguration();
}
}
@@ -675,6 +1172,7 @@ public void onRequestStart(MegaApiJava api, MegaRequest request) {
@Override
public void onRequestUpdate(MegaApiJava api, MegaRequest request) {
+ log("onRequestUpdate");
}
@@ -701,17 +1199,16 @@ 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;
- 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);
@@ -737,11 +1234,10 @@ 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()) {
if (avatar.length() > 0) {
BitmapFactory.Options bOpts = new BitmapFactory.Options();
@@ -757,24 +1253,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){
@@ -786,34 +1278,29 @@ 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));
}
}
public void createMyDefaultAvatar() {
- 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);
Canvas c = new Canvas(defaultAvatar);
Paint p = new Paint();
@@ -825,18 +1312,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(context, R.color.lollipop_primary_color));
+ 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);
@@ -851,7 +1336,6 @@ public void createMyDefaultAvatar() {
contactInitialLetter.setTextColor(Color.WHITE);
contactInitialLetter.setVisibility(View.VISIBLE);
}
-
}
public void setProfileMyAvatar() {
@@ -881,15 +1365,13 @@ public void setProfileMyAvatar() {
contactImage.setImageBitmap(myBitmap);
contactInitialLetter.setVisibility(GONE);
}
- }
- else{
+ }else{
createMyDefaultAvatar();
}
- }
- else {
+ }else {
createMyDefaultAvatar();
}
- } else {
+ }else {
createMyDefaultAvatar();
}
}
@@ -904,7 +1386,6 @@ public void run() {
aB.hide();
}
}).start();
-
} else {
aB.hide();
}
@@ -916,7 +1397,6 @@ protected void showActionBar(){
aB.show();
if(tB != null) {
tB.animate().translationY(0).setDuration(800L).start();
-
}
}
}
@@ -934,30 +1414,49 @@ protected void hideFABs(){
if(answerCallFAB.getVisibility() == View.VISIBLE){
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
public void onPause(){
- log("onPause()");
-
+ log("onPause");
mSensorManager.unregisterListener(this);
+ MegaApplication.activityPaused();
super.onPause();
}
@Override
protected void onResume() {
log("onResume()");
-
- this.width=0;
- this.height=0;
super.onResume();
- 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);
- this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
- MegaApplication.activityResumed();
+ if(peersOnCall!=null){
+ if(peersOnCall.size()!=0){
+ 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);
+ }
+ }
+ }
+ }
+ }
+ 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);
+ this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ MegaApplication.activityResumed();
if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){
((MegaApplication) getApplication()).sendSignalPresenceActivity();
}
@@ -966,18 +1465,64 @@ protected void onResume() {
@Override
public void onDestroy(){
log("onDestroy()");
+
if (megaChatApi != null) {
megaChatApi.removeChatCallListener(this);
- megaChatApi.removeChatVideoListener(this);
+// megaChatApi.removeChatVideoListener(chatId, userHandle, this);
}
if (customHandler != null){
customHandler.removeCallbacksAndMessages(null);
}
+ clearHandlers();
- stopAudioSignals();
+ if (localCameraFragment != null) {
+ localCameraFragment.removeSurfaceView();
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.remove(localCameraFragment);
+ localCameraFragment = null;
+ }
- MegaApplication.activityPaused();
+ if (localCameraFragmentFS != null) {
+ localCameraFragmentFS.removeSurfaceView();
+ FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction();
+ ftFS.remove(localCameraFragmentFS);
+ localCameraFragmentFS = null;
+ }
+ if (remoteCameraFragmentFS != null) {
+ remoteCameraFragmentFS.removeSurfaceView();
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.remove(remoteCameraFragmentFS);
+ remoteCameraFragmentFS = null;
+ }
+
+ if (bigCameraGroupCallFragment != null) {
+ FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction();
+ ftFS.remove(bigCameraGroupCallFragment);
+ bigCameraGroupCallFragment = null;
+ }
+
+ peerSelected = null;
+ if(adapterList!=null){
+ adapterList.updateMode(false);
+ }
+ isManualMode = false;
+
+ if(adapterGrid!=null){
+ adapterGrid.onDestroy();
+ }
+ if(adapterList!=null){
+ adapterList.onDestroy();
+ }
+
+ peersOnCall.clear();
+ peersBeforeCall.clear();
+
+ recyclerView.setAdapter(null);
+ bigRecyclerView.setAdapter(null);
+
+ stopAudioSignals();
+ mSensorManager.unregisterListener(this);
super.onDestroy();
}
@@ -990,12 +1535,13 @@ public void onBackPressed() {
if (megaChatApi != null) {
megaChatApi.removeChatCallListener(this);
- megaChatApi.removeChatVideoListener(this);
+// megaChatApi.removeChatVideoListener(chatId, userHandle, this);
}
if (customHandler != null){
customHandler.removeCallbacksAndMessages(null);
}
+ clearHandlers();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
@@ -1007,62 +1553,58 @@ public void onBackPressed() {
@Override
public void onRequestStart(MegaChatApiJava api, MegaChatRequest request) {
- log("onRequestStart()");
+ log("onRequestStart: "+request.getType());
}
@Override
public void onRequestUpdate(MegaChatApiJava api, MegaChatRequest request) {
- log("onRequestUpdate()");
-
+ log("onRequestUpdate: "+request.getType());
}
@Override
public void onRequestFinish(MegaChatApiJava api, MegaChatRequest request, MegaChatError e) {
- log("onRequestFinish()");
+ log("onRequestFinish: "+request.getType());
if(request.getType() == MegaChatRequest.TYPE_HANG_CHAT_CALL){
- MegaApplication.activityPaused();
+ log("onRequestFinish: TYPE_HANG_CHAT_CALL");
+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
- }
- else {
+ }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");
-// updateLocalVideoStatus();
-
- }
- else{
+ }else{
log("Ok answer with NO video - ");
-// updateLocalVideoStatus();
}
updateLocalVideoStatus();
- }
- else{
+ updateLocalAudioStatus();
+ }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){
@@ -1089,10 +1631,46 @@ 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) {
+
+ 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());
+// }
+// }
+// }
+// }
}
}
}
@@ -1103,58 +1681,134 @@ 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());
this.callChat = call;
+ log("onChatCallUpdate() call.getChatid() = chatId = "+chatId);
if(callChat.hasChanged(MegaChatCall.CHANGE_TYPE_STATUS)){
+
int callStatus = callChat.getStatus();
+ log("onChatCallUpdate()-CHANGE_TYPE_STATUS -> status: "+callStatus);
+
switch (callStatus){
case MegaChatCall.CALL_STATUS_IN_PROGRESS:{
+ if(chat.isGroup()){
+ log("CALL_STATUS_IN_PROGRESS -Group call");
+
+ if((peersOnCall != null)&&(peersOnCall.size() != 0)){
+ boolean peerContain = false;
+ for(InfoPeerGroupCall peer : peersOnCall) {
+ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) {
+ peerContain = true;
+ break;
+ }
+ }
+ if(!peerContain){
+ InfoPeerGroupCall myPeer = new InfoPeerGroupCall(megaChatApi.getMyUserHandle(), megaChatApi.getMyFullname(), callChat.hasLocalVideo(), callChat.hasLocalAudio(), false,true,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,true,null);
+ log("onChatCallUpdate()- CALL_STATUS_IN_PROGRESS "+myPeer.getHandle()+" added in peersOnCall");
+ peersOnCall.add(myPeer);
+ updatePeers(true);
+ }
+ updateLocalVideoStatus();
+ updateLocalAudioStatus();
+
+ updateSubtitleToolbar();
+
+ }else{
+ log("CALL_STATUS_IN_PROGRESS - Individual call");
+
+ flagMyAvatar = true;
+ setProfileMyAvatar();
+ flagContactAvatar = false;
+ setProfileContactAvatar();
+ if (localCameraFragmentFS != null) {
+ log("remove localCameraFragmentFS");
+ localCameraFragmentFS.removeSurfaceView();
+ FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction();
+ ftFS.remove(localCameraFragmentFS);
+ localCameraFragmentFS = null;
+ contactAvatarLayout.setVisibility(View.VISIBLE);
+ parentLocalFS.setVisibility(View.GONE);
+ fragmentContainerLocalCameraFS.setVisibility(View.GONE);
+ }
+
+ updateLocalVideoStatus();
+ updateLocalAudioStatus();
+
+ updateRemoteVideoStatus(-1);
+ updateRemoteAudioStatus(-1);
+
+ }
+
videoFAB.setOnClickListener(null);
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);
+ stopAudioSignals();
+ rtcAudioManager.start(null);
+ showInitialFABConfiguration();
+ updateSubTitleClock();
+ break;
+
+ }
+ case MegaChatCall.CALL_STATUS_TERMINATING_USER_PARTICIPATION:{
+ log("CALL_STATUS_TERMINATING_USER_PARTICIPATION");
+ //I have finished the group call but I can join again
+
+ log("Terminating call of chat: "+chatId);
+ if(chat.isGroup()){
+ stopAudioSignals();
+ rtcAudioManager.stop();
+
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ super.finishAndRemoveTask();
+ }
+ else {
+ super.finish();
+ }
+ }else{
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ super.finishAndRemoveTask();
+ }
+ else {
+ super.finish();
+ }
}
- updateLocalVideoStatus();
- updateRemoteVideoStatus();
- stopAudioSignals();
- rtcAudioManager.start(null);
- showInitialFABConfiguration();
- updateSubTitle();
break;
}
- case MegaChatCall.CALL_STATUS_TERMINATING:{
- log("Terminating call of chat: "+chatId);
+ case MegaChatCall.CALL_STATUS_USER_NO_PRESENT:{
+ log("CALL_STATUS_USER_NO_PRESENT");
+
break;
}
case MegaChatCall.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
stopAudioSignals();
-
rtcAudioManager.stop();
- MegaApplication.activityPaused();
-
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.finishAndRemoveTask();
}
@@ -1166,28 +1820,568 @@ public void onChatCallUpdate(MegaChatApiJava api, MegaChatCall call) {
}
}
else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_SESSION_STATUS)){
- log("Session status have changed");
- if(call.getPeerSessionStatusChange()==chat.getPeerHandle(0)){
- updateSubTitle();
+ log("CHANGE_TYPE_SESSION_STATUS");
+ log("onChatCallUpdate()-CHANGE_TYPE_SESSION_STATUS");
+
+ 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");
+
+ if(call.getPeerSessionStatusChange() == chat.getPeerHandle(0)){
+ updateSubTitleClock();
+ }
+
+ updateRemoteVideoStatus(userHandle);
+ updateRemoteAudioStatus(userHandle);
+
+ 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 ");
+
+ updateSubtitleToolbar();
+ //contact left the group call
+ log(chat.getPeerFullnameByHandle(userHandle)+" left the group call");
+ }
+ }
+ }else{
+ log("onChatCallUpdate() - CHANGE_TYPE_SESSION_STATUS");
+
+ if(call.getPeerSessionStatusChange() == chat.getPeerHandle(0)){
+ updateSubTitleClock();
+ }
+ updateRemoteVideoStatus(-1);
+ updateRemoteAudioStatus(-1);
+
+ updateLocalVideoStatus();
+ updateLocalAudioStatus();
}
- updateRemoteVideoStatus();
- updateRemoteAudioStatus();
}
else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_REMOTE_AVFLAGS)){
- log("Remote flags have changed");
- updateRemoteVideoStatus();
- updateRemoteAudioStatus();
- }
- else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_LOCAL_AVFLAGS)){
- log("Local flags have changed");
- updateLocalAudioStatus();
+ log("onChatCallUpdate()-CHANGE_TYPE_REMOTE_AVFLAGS");
+ 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("onChatCallUpdate()-CHANGE_TYPE_LOCAL_AVFLAGS");
updateLocalVideoStatus();
- }
- else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_RINGING_STATUS)){
- log("CHANGE_TYPE_RINGING_STATUS");
- }
- else{
- log("CHANGE_TYPE_RINGING_STATUS: "+call.getChanges());
+ updateLocalAudioStatus();
+
+
+ }else if(call.hasChanged(MegaChatCall.CHANGE_TYPE_RINGING_STATUS)){
+ 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 -CALL_STATUS_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 == megaChatApi.getMyUserHandle()){
+ isMe = true;
+ break;
+ }
+ }
+
+ if(!isMe){
+ boolean changes = false;
+ //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 peerBeforeCall: peersBeforeCall){
+ if(peerBeforeCall.getHandle() == userHandle){
+ peerContain = true;
+ break;
+ }
+ }
+ if(!peerContain){
+ InfoPeerGroupCall userPeer = new InfoPeerGroupCall(userHandle, chat.getPeerFullnameByHandle(userHandle), false, false, false,true,null);
+ log("onChatCallUpdate()-CHANGE_TYPE_CALL_COMPOSITION (ring in) "+userPeer.getName()+" added");
+ peersBeforeCall.add((peersBeforeCall.size() == 0 ? 0:(peersBeforeCall.size()-1)), userPeer);
+ changes = true;
+ }
+ }
+ 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 (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);
+ }
+ }
+
+ }
+ }
+ }
+
+ 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 (peersOnCall.size() < 4) {
+ recyclerViewLayout.setPadding(0, 0, 0, 0);
+ recyclerView.setColumnWidth((int) widthScreenPX);
+ adapterGrid.notifyItemRemoved(i);
+ adapterGrid.notifyDataSetChanged();
+ 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();
+ }
+ }
+
+ } else {
+ updatePeers(true);
+ }
+ } else {
+ 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 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);
+ }
+ }
+
+ }
+ }
+ }
+
+ 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);
+ adapterGrid.notifyItemRemoved(i);
+ adapterGrid.notifyDataSetChanged();
+ 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();
+ }
+ }
+
+ } else {
+ updatePeers(true);
+ }
+ } else {
+ 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= 7){
+ if(!isManualMode){
+ long userHandle = call.getPeerSessionStatusChange();
+ MegaChatSession userSession = callChat.getMegaChatSession(userHandle);
+ if(userSession != null){
+ boolean userHasAudio = userSession.getAudioDetected();
+ if(userHasAudio){
+ //The user is talking
+ int position = -1;
+ for(int i=0;i 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");
switch (v.getId()) {
+ case R.id.call_chat_contact_image_rl:
+ case R.id.parent_layout_big_camera_group_call:{
+ remoteCameraClick();
+ break;
+ }
case R.id.video_fab:{
- log("Click on 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();
+
answerCallFAB.clearAnimation();
- }
- else{
+ videoFAB.clearAnimation();
+ }else{
if(callChat.hasLocalVideo()){
+ log(" disableVideo");
megaChatApi.disableVideo(chatId, this);
- }
- else{
+ }else{
+ log(" enableVideo");
megaChatApi.enableVideo(chatId, this);
}
}
- // surfaceView.setVisibility(View.VISIBLE);
-// start_camera();
if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){
((MegaApplication) getApplication()).sendSignalPresenceActivity();
}
@@ -1398,8 +2501,7 @@ public void onClick(View v) {
log("Click on 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)){
@@ -1418,28 +2520,45 @@ public void onClick(View v) {
}
case R.id.answer_call_fab:{
log("Click on answer fab");
- ((MegaApplication) getApplication()).sendSignalPresenceActivity();
- megaChatApi.answerChatCall(chatId, false, this);
- videoFAB.clearAnimation();
- break;
- }
- }
- }
+ 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();
- 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);
- }else{
+ answerCallFAB.clearAnimation();
+ videoFAB.clearAnimation();
+ }else{
+
+ }
+
+ if((callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS)||(callChat.getStatus()==MegaChatCall.CALL_STATUS_REQUEST_SENT)){
+ ((MegaApplication) getApplication()).sendSignalPresenceActivity();
+ }
+ break;
}
}
}
+// 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);
+// }
+// }
+// }
+
public boolean checkPermissions(){
- log("checkPermissions()");
+ log("checkPermissions() Camera && Audio");
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
boolean hasCameraPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
@@ -1460,6 +2579,8 @@ public boolean checkPermissions(){
}
public void showInitialFABConfiguration(){
+ log("showInitialFABConfiguration() ");
+
if(callChat.getStatus()==MegaChatCall.CALL_STATUS_RING_IN){
relativeCall.setVisibility(View.VISIBLE);
linearArrowCall.setVisibility(GONE);
@@ -1471,12 +2592,19 @@ public void showInitialFABConfiguration(){
relativeVideo.setVisibility(View.VISIBLE);
linearArrowVideo.setVisibility(GONE);
videoFAB.setVisibility(View.VISIBLE);
- videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.accentColor)));
- videoFAB.setImageDrawable(ContextCompat.getDrawable(this, 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);
- if (callChat.hasRemoteVideo()) {
+ 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);
@@ -1484,23 +2612,17 @@ 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);
- 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);
}
@@ -1509,9 +2631,12 @@ public void run() {
}, 250);
}
}, 250);
+
+
videoFAB.setOnTouchListener(new OnSwipeTouchListener(this) {
public void onSwipeTop() {
log("onSwipeTop");
+
videoFAB.clearAnimation();
TranslateAnimation translateAnim = new TranslateAnimation( 0, 0 , 0, -380 );
@@ -1549,12 +2674,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();
}
});
@@ -1568,26 +2693,27 @@ 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);
- 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);
}
@@ -1636,11 +2762,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();
@@ -1669,150 +2795,527 @@ 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(){
- log("updateLocalVideoStatus: ");
+ log("updateLocalVideoStatus");
int callStatus = callChat.getStatus();
+ if(chat.isGroup()){
+ log("is group");
+ if(callChat !=null){
+ if (callChat.hasLocalVideo()) {
+ videoFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor)));
+ videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_videocam_white));
+ if ((peersOnCall != null)&& (peersOnCall.size()!=0)) {
+ int position = peersOnCall.size()-1;
+ InfoPeerGroupCall item = peersOnCall.get(position);
+ if(!item.isVideoOn()){
+ log("activate Local Video for "+peersOnCall.get(position).getName());
+ item.setVideoOn(true);
+ if(peersOnCall.size()<7){
+ if(adapterGrid!=null){
+ adapterGrid.notifyItemChanged(position);
+ }else{
+ updatePeers(true);
+ }
+ }else{
+ if(adapterList!=null){
+ adapterList.notifyItemChanged(position);
+ }else{
+ updatePeers(true);
+ }
+ }
+ updateSubtitleToolbar();
+ }
- if (callChat.hasLocalVideo()) {
- log("Video local connected");
- if (myAvatarLayout.getVisibility() == 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");
+ videoFAB.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.disable_fab_chat_call)));
+ videoFAB.setImageDrawable(getResources().getDrawable(R.drawable.ic_video_off));
+ if ((peersOnCall != null) && (peersOnCall.size()!=0)) {
+ int position = peersOnCall.size()-1;
+ InfoPeerGroupCall item = peersOnCall.get(position);
+ if(item.isVideoOn()){
+ log("desactivate Local Video fot "+peersOnCall.get(position).getName());
+ item.setVideoOn(false);
+ if(peersOnCall.size()<7){
+ if(adapterGrid!=null){
+ adapterGrid.notifyItemChanged(position);
+ }else{
+ updatePeers(true);
+ }
+ }else{
+ if(adapterList!=null){
+ adapterList.notifyItemChanged(position);
+ }else{
+ updatePeers(true);
+ }
+ }
+ updateSubtitleToolbar();
+ }
+ }
+ }
+ }
+ }else{
+ log("is individual");
+ if (callChat.hasLocalVideo()) {
+ log("Video local connected: chatId: "+chatId);
+ 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){
+ log("callStatus: CALL_STATUS_REQUEST_SENT");
+
if(localCameraFragmentFS == null){
- log("Create local camera fragment full screen");
- localCameraFragmentFS = new LocalCameraCallFullScreenFragment();
+ log("create localCameraFragmentFS");
+ 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);
+ 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 local camera fragment");
- localCameraFragment = new LocalCameraCallFragment();
+ 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);
- parent.setVisibility(View.VISIBLE);
+ parentLocal.setVisibility(View.VISIBLE);
fragmentContainerLocalCamera.setVisibility(View.VISIBLE);
}
- } else {
- log("No needed to refresh");
- }
- } else {
- log("Video local NOT connected");
-
- if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){
- parentFS.setVisibility(View.GONE);
- fragmentContainerLocalCameraFS.setVisibility(View.GONE);
- if (localCameraFragmentFS != null) {
- log("Remove local camera fragment full screen");
- localCameraFragmentFS.setVideoFrame(false);
- FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction();
- ftFS.remove(localCameraFragmentFS);
- localCameraFragmentFS = null;
- }
- contactAvatarLayout.setVisibility(View.VISIBLE);
+ }else {
+ 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));
+
+ if(callStatus==MegaChatCall.CALL_STATUS_REQUEST_SENT){
+ log("callStatus: CALL_STATUS_REQUEST_SENT");
+
+ if (localCameraFragmentFS != null) {
+ log("remove localCameraFragmentFS");
+ localCameraFragmentFS.removeSurfaceView();
+ FragmentTransaction ftFS = getSupportFragmentManager().beginTransaction();
+ ftFS.remove(localCameraFragmentFS);
+ localCameraFragmentFS = null;
+ }
+ parentLocalFS.setVisibility(View.GONE);
+ 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) {
+ log("remove localCameraFragment");
+ localCameraFragment.removeSurfaceView();
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.remove(localCameraFragment);
+ localCameraFragment = null;
+ }
+ parentLocal.setVisibility(View.GONE);
+ fragmentContainerLocalCamera.setVisibility(View.GONE);
+ myAvatarLayout.setVisibility(View.VISIBLE);
- }else{
- parent.setVisibility(View.GONE);
- fragmentContainerLocalCamera.setVisibility(View.GONE);
- if (localCameraFragment != null) {
- log("Create local camera fragment");
- localCameraFragment.setVideoFrame(false);
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- ft.remove(localCameraFragment);
- localCameraFragment = null;
}
- 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(){
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 != null && !peersOnCall.isEmpty()) {
+ int position = peersOnCall.size()-1;
+ if(!peersOnCall.get(position).isAudioOn()){
+ peersOnCall.get(position).setAudioOn(true);
+ if(peersOnCall.size()<7){
+ if(adapterGrid!=null){
+ adapterGrid.changesInAudio(position,null);
+ }else{
+ updatePeers(true);
+ }
+ }else{
+ if(adapterList!=null){
+ adapterList.changesInAudio(position,null);
+ }else{
+ updatePeers(true);
+ }
+ }
+ }
+ }
+ }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 != null && !peersOnCall.isEmpty()) {
+ int position = peersOnCall.size()-1;
+ if(peersOnCall.get(position).isAudioOn()){
+ peersOnCall.get(position).setAudioOn(false);
+ if(peersOnCall.size()<7){
+ if(adapterGrid!=null){
+ adapterGrid.changesInAudio(position,null);
+ }else{
+ updatePeers(true);
+ }
+ }else{
+ if(adapterList!=null){
+ adapterList.changesInAudio(position,null);
+ }else{
+ updatePeers(true);
+ }
+ }
+ }
+ }
- 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));
+ }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(){
- log("updateRemoteVideoStatus");
+ public void updateRemoteVideoStatus(long userHandle){
+ log("updateRemoteVideoStatus(): "+userHandle);
+ if(chat.isGroup()){
+ log("isGroup()");
+
+ MegaChatSession userSession = callChat.getMegaChatSession(userHandle);
+ if(userSession!=null && userSession.hasVideo()) {
+ log(userHandle+": Video remote connected");
+ if ((peersOnCall != null) && (peersOnCall.size()!=0)) {
+ for(int i=0;i 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if(checkPermissions()){
- checkPermissionsWriteLog();
- showInitialFABConfiguration();
+// checkPermissionsWriteLog();
+ showInitialFABConfiguration();
}
}
else{
@@ -1824,7 +3327,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
log("RECORD_AUDIO");
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if(checkPermissions()){
- checkPermissionsWriteLog();
+// checkPermissionsWriteLog();
showInitialFABConfiguration();
}
}
@@ -1836,9 +3339,9 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
case Constants.WRITE_LOG: {
log("WRITE_LOG");
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- checkPermissionsWriteLog();
- }
+// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+// checkPermissionsWriteLog();
+// }
break;
}
}
@@ -1864,37 +3367,61 @@ public void onSensorChanged(SensorEvent event) {
}
}
- @Override
- public boolean onTouch(View view, MotionEvent event){
+ public void remoteCameraClick(){
+ log("remoteCameraClick");
+ if(callChat.getStatus()==MegaChatCall.CALL_STATUS_IN_PROGRESS) {
+ if (aB.isShowing()) {
+ hideActionBar();
+ hideFABs();
+ } else {
+ showActionBar();
+ showInitialFABConfiguration();
+ }
+ }
+ }
- final int X = (int) event.getRawX();
- final int Y = (int) event.getRawY();
+ public void itemClicked(InfoPeerGroupCall peer){
+ 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;
+ log("manual mode - False");
+ }else{
+ isManualMode = true;
+ log("manual mode - True");
- 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(aB.isShowing()){
- hideActionBar();
- hideFABs();
- }else{
- showActionBar();
- showInitialFABConfiguration();
+ }
+ if(adapterList!=null){
+ adapterList.updateMode(isManualMode);
+ for(int i=0;i 0){
+ BitmapFactory.Options bOpts = new BitmapFactory.Options();
+ bOpts.inPurgeable = true;
+ bOpts.inInputShareable = true;
+ bitmap = BitmapFactory.decodeFile(avatar.getAbsolutePath(), bOpts);
+ if (bitmap == null) {
+ avatar.delete();
+
+ 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);
+ }
+ }else{
+ avatarBigCameraGroupCallInitialLetter.setVisibility(GONE);
+ avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE);
+ avatarBigCameraGroupCallImage.setImageBitmap(bitmap);
+ }
+ }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);
+ }
+ }
+ }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, 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);
+
+ 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);
+ avatarBigCameraGroupCallImage.setVisibility(View.VISIBLE);
+ avatarBigCameraGroupCallImage.setImageBitmap(defaultAvatar);
+
+ 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(){
+ 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);
+ }
+ }
+
+ 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/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..03689a3b11c
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/InfoPeerGroupCall.java
@@ -0,0 +1,85 @@
+package mega.privacy.android.app.lollipop.megachat.calls;
+
+
+import android.util.Log;
+import android.view.SurfaceView;
+
+import mega.privacy.android.app.lollipop.listeners.GroupCallListener;
+
+public class InfoPeerGroupCall {
+ Long handle;
+ String name;
+ boolean videoOn;
+ boolean audioOn;
+ boolean greenLayer;
+ GroupCallListener listener = null;
+ boolean goodQuality = true;
+
+public InfoPeerGroupCall(Long handle, String name, boolean videoOn, boolean audioOn, boolean greenLayer, boolean goodQuality, GroupCallListener listener) {
+
+ this.handle = handle;
+ this.name = name;
+ this.videoOn = videoOn;
+ this.audioOn = audioOn;
+ this.greenLayer = greenLayer;
+ this.listener = listener;
+ this.goodQuality = goodQuality;
+}
+
+ 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 boolean isGoodQuality() {
+ return goodQuality;
+ }
+
+ public void setGoodQuality(boolean goodQuality) {
+ this.goodQuality = goodQuality;
+ }
+
+ public boolean hasGreenLayer() {
+ return greenLayer;
+ }
+
+ public void setGreenLayer(boolean greenLayer) {
+ this.greenLayer = greenLayer;
+ }
+
+ 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/calls/LocalCameraCallFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/LocalCameraCallFragment.java
index c41d183e0fb..f83360c4332 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
@@ -29,24 +29,34 @@ public class LocalCameraCallFragment extends Fragment implements MegaChatVideoLi
Bitmap bitmap;
MegaChatApiAndroid megaChatApi;
Context context;
+ long chatId;
public SurfaceView localSurfaceView;
MegaSurfaceRenderer localRenderer;
+ 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);
+ 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);
+ log("onCreate() chatId: "+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;
@@ -60,14 +70,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
localRenderer = new MegaSurfaceRenderer(localSurfaceView);
- megaChatApi.addChatLocalVideoListener(this);
+ log("onCreateView() addChatLocalVideoListener chatId: "+chatId);
+ 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;
}
@@ -104,13 +114,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);
@@ -119,26 +122,41 @@ public void onAttach(Context context) {
@Override
public void onDestroy(){
- megaChatApi.removeChatVideoListener(this);
+ log("onDestroy");
+ if(localSurfaceView.getParent()!=null){
+ if(localSurfaceView.getParent().getParent()!=null){
+ log("onDestroy() removeView chatId: "+chatId);
+ ((ViewGroup)localSurfaceView.getParent()).removeView(localSurfaceView);
+ }
+ }
+ localSurfaceView.setVisibility(View.GONE);
+ log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId);
+ megaChatApi.removeChatVideoListener(chatId, -1, this);
super.onDestroy();
}
@Override
public void onResume() {
- log("onResume");
+ log("onResume()");
this.width=0;
this.height=0;
+ localSurfaceView.setVisibility(View.VISIBLE);
+
super.onResume();
}
-
- public void setVideoFrame(boolean 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: "+chatId);
+ ((ViewGroup)localSurfaceView.getParent()).removeView(localSurfaceView);
+ }
}
+ localSurfaceView.setVisibility(View.GONE);
+ log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+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 c34bf3709a9..5427b7fff76 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
@@ -29,10 +29,20 @@ public class LocalCameraCallFullScreenFragment extends Fragment implements MegaC
Bitmap bitmap;
MegaChatApiAndroid megaChatApi;
Context context;
+ long chatId;
public SurfaceView localFullScreenSurfaceView;
MegaSurfaceRenderer localRenderer;
+ public static LocalCameraCallFullScreenFragment newInstance(long chatId) {
+ log("newInstance");
+ LocalCameraCallFullScreenFragment f = new LocalCameraCallFullScreenFragment();
+ Bundle args = new Bundle();
+ args.putLong("chatId", chatId);
+ f.setArguments(args);
+ return f;
+ }
+
@Override
public void onCreate (Bundle savedInstanceState){
log("onCreate");
@@ -40,13 +50,14 @@ public void onCreate (Bundle savedInstanceState){
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;
@@ -60,7 +71,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
localSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
localRenderer = new MegaSurfaceRenderer(localFullScreenSurfaceView);
- megaChatApi.addChatLocalVideoListener(this);
+ log("onCreateView() addChatLocalVideoListener chatId: "+chatId);
+ megaChatApi.addChatLocalVideoListener(chatId, this);
return v;
}
@@ -105,12 +117,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) {
@@ -120,7 +126,16 @@ public void onAttach(Context context) {
@Override
public void onDestroy(){
- megaChatApi.removeChatVideoListener(this);
+ log("onDestroy()");
+ if(localFullScreenSurfaceView.getParent()!=null){
+ if(localFullScreenSurfaceView.getParent().getParent()!=null){
+ log("onDestroy() removeView chatId: "+chatId);
+ ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView);
+ }
+ }
+ localFullScreenSurfaceView.setVisibility(View.GONE);
+ log("onDestroy() removeChatVideoListener (LOCAL) chatId: "+chatId);
+ megaChatApi.removeChatVideoListener(chatId, -1, this);
super.onDestroy();
}
@Override
@@ -128,16 +143,21 @@ public void onResume() {
log("onResume");
this.width=0;
this.height=0;
+ localFullScreenSurfaceView.setVisibility(View.VISIBLE);
+
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){
+ log("removeSurfaceView() removeView chatId: "+chatId);
+ ((ViewGroup)localFullScreenSurfaceView.getParent()).removeView(localFullScreenSurfaceView);
+ }
}
+ localFullScreenSurfaceView.setVisibility(View.GONE);
+ log("removeSurfaceView() removeChatVideoListener (LOCAL) chatId: "+chatId);
+ 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/MegaSurfaceRenderer.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRenderer.java
index a2d7055cf85..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
@@ -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;
@@ -36,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 {
@@ -58,6 +60,9 @@ public class MegaSurfaceRenderer implements Callback {
public MegaSurfaceRenderer(SurfaceView view) {
+ log("MegaSurfaceRenderer() ");
+
+// this.surf = view;
surfaceHolder = view.getHolder();
if(surfaceHolder == null)
return;
@@ -69,6 +74,9 @@ public MegaSurfaceRenderer(SurfaceView view) {
// 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;
@@ -79,7 +87,15 @@ private void changeDestRect(int dstWidth, int dstHeight) {
}
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();
@@ -101,25 +117,11 @@ private void adjustAspectRatio() {
}
}
- public void surfaceChanged(SurfaceHolder holder, int format,
- int in_width, int 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 surfaceCreated(SurfaceHolder holder) {
+ log("surfaceCreated(): ");
+
Canvas canvas = surfaceHolder.lockCanvas();
if(canvas != null) {
Rect dst = surfaceHolder.getSurfaceFrame();
@@ -143,13 +145,36 @@ 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);
+
+ 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():");
+
Logging.d(TAG, "ViESurfaceRenderer::surfaceDestroyed");
bitmap = null;
byteBuffer = null;
}
public Bitmap CreateBitmap(int width, int height) {
+ log("CreateBitmap(): width = "+width+", height = "+height);
+
+
Logging.d(TAG, "CreateByteBitmap " + width + ":" + height);
if (bitmap == null) {
try {
@@ -165,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);
@@ -181,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();
@@ -198,6 +229,8 @@ private void saveBitmapToJPEG(int width, int height) {
}
public void DrawByteBuffer() {
+ log("DrawByteBuffer(): ");
+
if(byteBuffer == null)
return;
byteBuffer.rewind();
@@ -206,18 +239,17 @@ public void DrawByteBuffer() {
}
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);
@@ -232,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);
@@ -251,4 +287,5 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
return 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
new file mode 100644
index 00000000000..51ed2d23bac
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/MegaSurfaceRendererGroup.java
@@ -0,0 +1,289 @@
+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.Matrix;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+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;
+
+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 android.view.TextureView;
+
+import org.webrtc.Logging;
+
+import mega.privacy.android.app.R;
+import mega.privacy.android.app.utils.Util;
+
+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 SurfaceTexture 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;
+ private TextureView myTexture = null;
+
+ protected List listeners;
+
+
+ public MegaSurfaceRendererGroup(TextureView view, Long handle) {
+ log("MegaSurfaceRendererGroup(): ");
+
+ 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);
+ 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 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 void DrawBitmap(boolean flag) {
+ if(bitmap == null){
+ return;
+ }
+ if (myTexture == null){
+ return;
+ }
+ Canvas canvas = myTexture.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);
+ }
+ myTexture.unlockCanvasAndPost(canvas);
+ }
+ }
+
+ 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);
+ }
+
+ @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);
+ }
+
+ 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/calls/RemoteCameraCallFullScreenFragment.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java
new file mode 100644
index 00000000000..00e36e5272b
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/calls/RemoteCameraCallFullScreenFragment.java
@@ -0,0 +1,182 @@
+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.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, View.OnClickListener {
+
+ 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() chatId: "+chatId);
+
+ 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("onCreate() chatId: "+chatId);
+
+ super.onCreate(savedInstanceState);
+ log("after onCreate called super");
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+ 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.setOnClickListener(this);
+ remoteFullScreenSurfaceView.setZOrderMediaOverlay(true);
+ SurfaceHolder remoteSurfaceHolder = remoteFullScreenSurfaceView.getHolder();
+ remoteSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
+ remoteRenderer = new MegaSurfaceRenderer(remoteFullScreenSurfaceView);
+
+ log("onCreateView() addChatRemoteVideoListener chatId: "+chatId);
+ 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) {
+ log("onAttach");
+ super.onAttach(context);
+ this.context = context;
+ }
+
+ @Override
+ public void onDestroy(){
+ log("onDestroy");
+ if(remoteFullScreenSurfaceView.getParent()!=null){
+ if(remoteFullScreenSurfaceView.getParent().getParent()!=null){
+ log("onDestroy() removeView chatId: "+chatId);
+ ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView);
+ }
+ }
+ log("onDestroy() removeChatVideoListener (REMOTE) chatId: "+chatId);
+ remoteFullScreenSurfaceView.setVisibility(View.GONE);
+ megaChatApi.removeChatVideoListener(chatId, userHandle, this);
+ super.onDestroy();
+ }
+
+ @Override
+ public void onResume() {
+ log("onResume");
+ this.width=0;
+ this.height=0;
+ remoteFullScreenSurfaceView.setVisibility(View.VISIBLE);
+
+ super.onResume();
+ }
+
+ public void removeSurfaceView(){
+ log("removeSurfaceView()");
+ if(remoteFullScreenSurfaceView.getParent()!=null){
+ if(remoteFullScreenSurfaceView.getParent().getParent()!=null){
+ log("removeSurfaceView() removeView chatId: "+chatId);
+ ((ViewGroup)remoteFullScreenSurfaceView.getParent()).removeView(remoteFullScreenSurfaceView);
+ }
+ }
+ remoteFullScreenSurfaceView.setVisibility(View.GONE);
+ log("removeSurfaceView() removeChatVideoListener (REMOTE) chatId: "+chatId);
+ megaChatApi.removeChatVideoListener(chatId, userHandle, this);
+ }
+
+ 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/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..b61d98c8ade
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/GroupCallAdapter.java
@@ -0,0 +1,1112 @@
+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.os.Environment;
+import android.os.Handler;
+import android.os.HandlerThread;
+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;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.Display;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+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;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.Random;
+
+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.ChatUserAvatarListener;
+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 nz.mega.sdk.MegaChatApiJava;
+import nz.mega.sdk.MegaChatVideoListenerInterface;
+import nz.mega.sdk.MegaNode;
+
+import static android.view.View.GONE;
+
+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;
+ Display display;
+ DisplayMetrics outMetrics;
+ float density;
+ float scaleW;
+ float scaleH;
+ float widthScreenPX, heightScreenPX;
+ boolean isCallInProgress = false;
+
+ RecyclerView recyclerViewFragment;
+
+ ArrayList peers;
+ long chatId;
+
+ int maxScreenWidth, maxScreenHeight;
+ boolean avatarRequested = false;
+ boolean isGrid = true;
+ boolean isManualMode = false;
+ int statusBarHeight = 0;
+
+public GroupCallAdapter(Context context, RecyclerView recyclerView, ArrayList peers, long chatId, boolean isCallInProgress, boolean isGrid) {
+
+ log("GroupCallAdapter(peers: "+peers.size()+")");
+
+ this.context = context;
+ this.recyclerViewFragment = recyclerView;
+ this.peers = peers;
+ this.chatId = chatId;
+ this.isCallInProgress = isCallInProgress;
+ this.isGrid = isGrid;
+
+ 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();
+ }
+ }
+
+ public class ViewHolderGroupCall extends RecyclerView.ViewHolder{
+
+ RelativeLayout rlGeneral;
+ RelativeLayout greenLayer;
+ RelativeLayout avatarMicroLayout;
+ RelativeLayout avatarLayout;
+ RoundedImageView avatarImage;
+ ImageView microAvatar;
+ ImageView microSurface;
+ RelativeLayout qualityLayout;
+ RelativeLayout qualityIcon;
+ TextView avatarInitialLetter;
+ RelativeLayout parentSurfaceView;
+ RelativeLayout surfaceMicroLayout;
+ 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 = ((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);
+
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_camera_group_call, parent, false);
+
+ 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;
+
+ holderGrid = new ViewHolderGroupCallGrid(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.parentSurfaceView = (RelativeLayout) v.findViewById(R.id.parent_surface_view);
+ 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 = (ImageView) v.findViewById(R.id.micro_surface_view);
+ holderGrid.qualityLayout = (RelativeLayout) v.findViewById(R.id.rl_quality);
+ holderGrid.qualityIcon = (RelativeLayout) v.findViewById(R.id.quality_icon);
+ holderGrid.avatarImage = (RoundedImageView) v.findViewById(R.id.avatar_image);
+ holderGrid.avatarInitialLetter = (TextView) v.findViewById(R.id.avatar_initial_letter);
+ holderGrid.avatarImage.setImageBitmap(null);
+ holderGrid.avatarInitialLetter.setText("");
+
+ v.setTag(holderGrid);
+ return holderGrid;
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolderGroupCall holder, int position) {
+ ViewHolderGroupCallGrid holderGrid2 = (ViewHolderGroupCallGrid) holder;
+ onBindViewHolderGrid(holderGrid2, position);
+ }
+
+ public void onBindViewHolderGrid (final ViewHolderGroupCallGrid holder, final int position){
+ log("onBindViewHolderGrid() - position: "+position);
+
+ final InfoPeerGroupCall peer = getNodeAt(position);
+ if (peer == null){
+ return;
+ }
+
+ int numPeersOnCall = getItemCount();
+ 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{
+ 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);
+ }
+
+ if(isCallInProgress){
+ holder.rlGeneral.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(getItemCount() < 7){
+ ((ChatCallActivity) context).remoteCameraClick();
+ }else{
+ ((ChatCallActivity) context).itemClicked(peer);
+ }
+ }
+ });
+ }else{
+ holder.rlGeneral.setOnClickListener(null);
+ }
+
+ holder.avatarImage.setImageBitmap(null);
+ holder.avatarInitialLetter.setText("");
+
+ if(peer.isVideoOn()) {
+ log("peer: "+peer.getHandle()+", VIDEO ON pos: "+position);
+
+ 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;
+ layoutParamsSurface.height = maxScreenWidth;
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenWidth;
+ paramsQualityLayout.width = maxScreenWidth;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+
+ }else if(numPeersOnCall == 2){
+
+ //Surface Layout:
+ RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams();
+ layoutParamsSurface.width = maxScreenHeight/numPeersOnCall;
+ layoutParamsSurface.height = maxScreenHeight/numPeersOnCall;
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenHeight/numPeersOnCall;
+ paramsQualityLayout.width = maxScreenHeight/numPeersOnCall;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+
+ }else if(numPeersOnCall == 3){
+
+ //Surface Layout:
+ RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams();
+ layoutParamsSurface.width = maxScreenHeight/numPeersOnCall;
+ layoutParamsSurface.height = maxScreenHeight/numPeersOnCall;
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenHeight/numPeersOnCall;
+ paramsQualityLayout.width = maxScreenHeight/numPeersOnCall;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+
+ }else if(numPeersOnCall == 4){
+
+ //Surface Layout:
+ RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams();
+ 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{
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
+
+ }
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenWidth/2;
+ paramsQualityLayout.width = maxScreenWidth/2;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+
+ }else if(numPeersOnCall == 5){
+
+ //Surface Layout:
+ RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams();
+ layoutParamsSurface.width = maxScreenWidth/2;
+ layoutParamsSurface.height = maxScreenWidth/2;
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenWidth/2;
+ paramsQualityLayout.width = maxScreenWidth/2;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+
+ }else if(numPeersOnCall == 6){
+
+ //Surface Layout:
+ RelativeLayout.LayoutParams layoutParamsSurface = (RelativeLayout.LayoutParams) holder.parentSurfaceView.getLayoutParams();
+ layoutParamsSurface.width = maxScreenWidth/2;
+ layoutParamsSurface.height = maxScreenWidth/2;
+ layoutParamsSurface.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
+ layoutParamsSurface.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ holder.parentSurfaceView.setLayoutParams(layoutParamsSurface);
+
+ RelativeLayout.LayoutParams paramsQualityLayout = new RelativeLayout.LayoutParams(holder.qualityLayout.getLayoutParams());
+ paramsQualityLayout.height = maxScreenWidth/2;
+ paramsQualityLayout.width = maxScreenWidth/2;
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_TOP, R.id.parent_surface_view);
+ paramsQualityLayout.addRule(RelativeLayout.ALIGN_LEFT, R.id.parent_surface_view);
+ holder.qualityLayout.setLayoutParams(paramsQualityLayout);
+ }
+
+ //Listener && SurfaceView
+ 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);
+
+ if (peer.getHandle().equals(megaChatApi.getMyUserHandle())) {
+ megaChatApi.addChatLocalVideoListener(chatId, peer.getListener());
+ } else {
+ megaChatApi.addChatRemoteVideoListener(chatId, peer.getHandle(), peer.getListener());
+ }
+ if(numPeersOnCall < 7){
+ peer.getListener().getLocalRenderer().addListener(null);
+ }else{
+ peer.getListener().getLocalRenderer().addListener(this);
+ }
+
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+
+ }else{
+
+ log("peer: "+peer.getHandle()+", VIDEO ON - listener != null");
+ 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());
+ }else{
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+ }
+ }else{
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+ }
+ }else{
+ if(holder.parentSurfaceView.getChildAt(0).equals(peer.getListener().getSurfaceView())){
+ }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());
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+ }else{
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+ }
+ }else{
+ holder.parentSurfaceView.addView(peer.getListener().getSurfaceView());
+ }
+ }
+ }
+
+ if(peer.getListener().getHeight() != 0){
+ peer.getListener().setHeight(0);
+ }
+ if(peer.getListener().getWidth() != 0){
+ peer.getListener().setWidth(0);
+ }
+ }
+
+ holder.surfaceMicroLayout.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_TOP, R.id.parent_surface_view);
+ paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view);
+ holder.microSurface.setLayoutParams(paramsMicroSurface);
+
+ RelativeLayout.LayoutParams paramsQuality = new RelativeLayout.LayoutParams(holder.qualityIcon.getLayoutParams());
+ paramsQuality.height = Util.scaleWidthPx(24, outMetrics);
+ paramsQuality.width = Util.scaleWidthPx(24, outMetrics);
+ paramsQuality.setMargins(Util.scaleWidthPx(15, outMetrics), 0, 0, Util.scaleWidthPx(15, outMetrics));
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+ holder.qualityIcon.setLayoutParams(paramsQuality);
+ }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_TOP, R.id.parent_surface_view);
+ paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view);
+ holder.microSurface.setLayoutParams(paramsMicroSurface);
+
+ RelativeLayout.LayoutParams paramsQuality = new RelativeLayout.LayoutParams(holder.qualityIcon.getLayoutParams());
+ paramsQuality.height = Util.scaleWidthPx(20, outMetrics);
+ paramsQuality.width = Util.scaleWidthPx(20, outMetrics);
+ paramsQuality.setMargins(Util.scaleWidthPx(7, outMetrics), 0, 0, Util.scaleWidthPx(7, outMetrics));
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+ holder.qualityIcon.setLayoutParams(paramsQuality);
+ }
+
+ if(peer.isAudioOn()){
+ holder.microSurface.setVisibility(View.GONE);
+ }else{
+ if(isCallInProgress) {
+ holder.microSurface.setVisibility(View.VISIBLE);
+ }else{
+ holder.microSurface.setVisibility(View.GONE);
+ }
+ }
+
+ if(peer.isGoodQuality()){
+ holder.qualityLayout.setVisibility(View.GONE);
+ }else{
+ if(isCallInProgress) {
+ holder.qualityLayout.setVisibility(View.VISIBLE);
+ }else{
+ holder.qualityLayout.setVisibility(View.GONE);
+ }
+ }
+
+ //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);
+ }
+ }
+
+ }else{
+ log("peer: "+peer.getHandle()+", VIDEO OFF");
+ //Avatar:
+ if(peer.getHandle() == megaChatApi.getMyUserHandle()){
+ setProfileMyAvatar(holder);
+ }else{
+ setProfileUserAvatar(peer.getHandle(), peer.getName(), holder);
+ }
+
+ holder.qualityLayout.setVisibility(GONE);
+
+ //Remove SurfaceView && Listener:
+ holder.surfaceMicroLayout.setVisibility(GONE);
+ 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()).removeView(peer.getListener().getSurfaceView());
+ }
+ }
+ }else{
+ holder.parentSurfaceView.removeAllViews();
+
+ 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);
+
+
+ //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);
+ }
+ }
+
+ //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);
+ }
+ }
+
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ if (peers != null){
+ return peers.size();
+ }else{
+ return 0;
+ }
+ }
+
+ public Object getItem(int position) {
+ if (peers != null){
+ return peers.get(position);
+ }
+ return null;
+ }
+
+ public InfoPeerGroupCall getNodeAt(int position) {
+ try {
+ if (peers != null) {
+ return peers.get(position);
+ }
+ } catch (IndexOutOfBoundsException e) {}
+ return null;
+ }
+
+ //My avatar
+ public void setProfileMyAvatar(ViewHolderGroupCall holder) {
+ log("setProfileMyAvatar()");
+ Bitmap myBitmap = null;
+ File avatar = null;
+ if (context != 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);
+ }
+ }
+ //My Default avatar
+ 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){
+ 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.setImageBitmap(defaultAvatar);
+ holder.avatarInitialLetter.setText(myFirstLetter);
+ holder.avatarInitialLetter.setVisibility(View.VISIBLE);
+ }
+
+
+ public void setProfileUserAvatar(long userHandle, String fullName, ViewHolderGroupCall holder){
+ log("setProfileUserAvatar()");
+ String contactMail = megaChatApi.getContactEmail(userHandle);
+
+ 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);
+ if (bitmap == null) {
+ avatar.delete();
+
+ 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);
+ }
+ }else{
+ holder.avatarInitialLetter.setVisibility(GONE);
+ holder.avatarImage.setVisibility(View.VISIBLE);
+ holder.avatarImage.setImageBitmap(bitmap);
+ }
+ }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);
+ }
+ }
+ }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);
+ }
+ }
+ }
+
+ //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);
+
+ 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);
+
+ 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() {
+ return recyclerViewFragment;
+ }
+
+ public void setListFragment(RecyclerView recyclerViewFragment) {
+ this.recyclerViewFragment = recyclerViewFragment;
+ }
+
+ public void changesInQuality(int position, ViewHolderGroupCall holder){
+
+ if(holder == null){
+ holder = (ViewHolderGroupCall) recyclerViewFragment.findViewHolderForAdapterPosition(position);
+ }
+ if(holder!=null){
+ InfoPeerGroupCall peer = getNodeAt(position);
+ if (peer == null){
+ return;
+ }
+
+ if(peer.isGoodQuality()){
+ holder.qualityLayout.setVisibility(View.GONE);
+ }else{
+ if(peer.isVideoOn()){
+ if(peers.size() < 7){
+ RelativeLayout.LayoutParams paramsQuality = new RelativeLayout.LayoutParams(holder.qualityIcon.getLayoutParams());
+ paramsQuality.height = Util.scaleWidthPx(24, outMetrics);
+ paramsQuality.width = Util.scaleWidthPx(24, outMetrics);
+ paramsQuality.setMargins(Util.scaleWidthPx(15, outMetrics), 0, 0, Util.scaleWidthPx(15, outMetrics));
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+ holder.qualityIcon.setLayoutParams(paramsQuality);
+ }else{
+ RelativeLayout.LayoutParams paramsQuality = new RelativeLayout.LayoutParams(holder.qualityIcon.getLayoutParams());
+ paramsQuality.height = Util.scaleWidthPx(20, outMetrics);
+ paramsQuality.width = Util.scaleWidthPx(20, outMetrics);
+ paramsQuality.setMargins(Util.scaleWidthPx(7, outMetrics), 0, 0, Util.scaleWidthPx(7, outMetrics));
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ paramsQuality.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+ holder.qualityIcon.setLayoutParams(paramsQuality);
+ }
+ holder.qualityLayout.setVisibility(View.VISIBLE);
+ }else{
+ holder.qualityLayout.setVisibility(View.GONE);
+ }
+ }
+ }else{
+ notifyItemChanged(position);
+ }
+ }
+
+ 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()){
+ holder.microAvatar.setVisibility(View.GONE);
+ holder.microSurface.setVisibility(View.GONE);
+
+ }else{
+ if(!peer.isVideoOn()){
+ 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);
+ 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);
+ }
+
+ }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_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_TOP, R.id.parent_surface_view);
+ paramsMicroSurface.addRule(RelativeLayout.ALIGN_RIGHT, R.id.parent_surface_view);
+ holder.microSurface.setLayoutParams(paramsMicroSurface);
+ }
+
+ }
+ }
+ }else{
+ notifyItemChanged(position);
+ }
+ }
+
+ public void updateMode(boolean flag){
+ isManualMode = flag;
+ }
+
+ 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()){
+ 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);
+ }
+ }
+
+ @Override
+ public void resetSize(Long userHandle) {
+ log("resetSize");
+ if(getItemCount()!=0){
+ for(InfoPeerGroupCall peer:peers){
+ if(peer.getListener()!=null){
+ if(peer.getListener().getWidth()!=0){
+ peer.getListener().setWidth(0);
+ }
+ if(peer.getListener().getHeight()!=0){
+ peer.getListener().setHeight(0);
+ }
+ }
+ }
+ }
+ }
+
+ public void onDestroy(){
+ log("onDestroy()");
+ ViewHolderGroupCall holder = null;
+ for(int i=0; i getPeers() {
+ return peers;
+ }
+
+ public void setPeers(ArrayList peers) {
+ this.peers = peers;
+ }
+
+ private static void log(String log) {
+ Util.log("GroupCallAdapter", log);
+ }
+
+
+}
\ No newline at end of file
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..35e44aa3d81 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
@@ -209,7 +209,7 @@ protected void onPostExecute(Integer param) {
File previewFile = new File(PreviewUtils.getPreviewFolder(context), node.getBase64Handle() + ".jpg");
log("GET PREVIEW OF HANDLE: " + node.getHandle() + " to download here: " + previewFile.getAbsolutePath());
pendingPreviews.add(node.getHandle());
- PreviewDownloadListener listener = new PreviewDownloadListener(context, (ViewHolderMessageChat) holder, megaChatAdapter);
+ PreviewDownloadListener listener = new PreviewDownloadListener(context, (ViewHolderMessageChat) holder, megaChatAdapter, node);
megaApi.getPreview(node, previewFile.getAbsolutePath(), listener);
}
}
@@ -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);
@@ -1402,9 +1404,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: {
@@ -1495,6 +1498,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;
}
@@ -1506,8 +1510,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();
@@ -1554,103 +1558,109 @@ 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_calling));
+ 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 hours = message.getDuration() / 3600;
- int minutes = (message.getDuration() % 3600) / 60;
- int seconds = message.getDuration() % 60;
+ int hours = message.getDuration() / 3600;
+ int minutes = (message.getDuration() % 3600) / 60;
+ int seconds = message.getDuration() % 60;
- textToShow = context.getString(R.string.call_ended_message);
+ textToShow = context.getString(R.string.call_ended_message);
- if(hours != 0){
- String textHours = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_hours, hours, hours);
- textToShow = textToShow + textHours;
- if((minutes != 0)||(seconds != 0)){
- textToShow = textToShow+", ";
+ if(hours != 0){
+ String textHours = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_hours, hours, hours);
+ textToShow = textToShow + textHours;
+ if((minutes != 0)||(seconds != 0)){
+ textToShow = textToShow+", ";
+ }
+ }
+
+ if(minutes != 0){
+ String textMinutes = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_minutes, minutes, minutes);
+ textToShow = textToShow + textMinutes;
+ if(seconds != 0){
+ textToShow = textToShow+", ";
+ }
}
- }
- if(minutes != 0){
- String textMinutes = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_minutes, minutes, minutes);
- textToShow = textToShow + textMinutes;
if(seconds != 0){
- textToShow = textToShow+", ";
+ String textSeconds = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_seconds, seconds, seconds);
+ textToShow = textToShow + textSeconds;
}
- }
- if(seconds != 0){
- String textSeconds = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_seconds, seconds, seconds);
- textToShow = textToShow + textSeconds;
- }
+ 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;
}
}
@@ -1804,101 +1814,104 @@ 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).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 hours = message.getDuration() / 3600;
- int minutes = (message.getDuration() % 3600) / 60;
- int seconds = message.getDuration() % 60;
+ int hours = message.getDuration() / 3600;
+ int minutes = (message.getDuration() % 3600) / 60;
+ int seconds = message.getDuration() % 60;
- textToShow = context.getString(R.string.call_ended_message);
+ textToShow = context.getString(R.string.call_ended_message);
- if(hours != 0){
- String textHours = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_hours, hours, hours);
- textToShow = textToShow + textHours;
- if((minutes != 0)||(seconds != 0)){
- textToShow = textToShow+", ";
+ if(hours != 0){
+ String textHours = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_hours, hours, hours);
+ textToShow = textToShow + textHours;
+ if((minutes != 0)||(seconds != 0)){
+ textToShow = textToShow+", ";
+ }
}
- }
- if(minutes != 0){
- String textMinutes = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_minutes, minutes, minutes);
- textToShow = textToShow + textMinutes;
- if(seconds != 0){
- textToShow = textToShow+", ";
+ if(minutes != 0){
+ String textMinutes = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_minutes, minutes, minutes);
+ textToShow = textToShow + textMinutes;
+ if(seconds != 0){
+ textToShow = textToShow+", ";
+ }
}
- }
- if(seconds != 0){
- String textSeconds = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_seconds, seconds, seconds);
- textToShow = textToShow + textSeconds;
- }
- 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:{
+ if(seconds != 0){
+ String textSeconds = context.getResources().getQuantityString(R.plurals.plural_call_ended_messages_seconds, seconds, seconds);
+ textToShow = textToShow + textSeconds;
+ }
+ 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) {
+ }
- ((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) {
+ break;
}
+ case MegaChatMessage.END_CALL_REASON_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) {
+ }
- 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;
}
}
@@ -2632,6 +2645,7 @@ public void bindContainsMetaMessage(ViewHolderMessageChat holder, AndroidMegaCha
MegaChatContainsMeta meta = message.getContainsMeta();
if (meta == null) {
bindNoTypeMessage(holder, androidMessage, position);
+
} else if (meta != null && meta.getType() == MegaChatContainsMeta.CONTAINS_META_RICH_PREVIEW) {
String urlString = meta.getRichPreview().getUrl();
try {
@@ -3136,7 +3150,215 @@ public void bindContainsMetaMessage(ViewHolderMessageChat holder, AndroidMegaCha
}
}
}
- } else {
+ } else if (meta != null && meta.getType() == MegaChatContainsMeta.CONTAINS_META_INVALID) {
+ if (message.getUserHandle() == myUserHandle) {
+ holder.layoutAvatarMessages.setVisibility(View.GONE);
+ holder.titleOwnMessage.setGravity(Gravity.RIGHT);
+
+ if(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
+ holder.titleOwnMessage.setPadding(0,0,Util.scaleWidthPx(PADDING_RIGHT_HOUR_OF_OWN_MESSAGE_LAND, outMetrics),0);
+ }else{
+ holder.titleOwnMessage.setPadding(0,0,Util.scaleWidthPx(PADDING_RIGHT_HOUR_OF_OWN_MESSAGE_PORT, outMetrics),0);
+ }
+
+ if (messages.get(position - 1).getInfoToShow() != -1) {
+ switch (messages.get(position - 1).getInfoToShow()) {
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_ALL: {
+ holder.dateLayout.setVisibility(View.VISIBLE);
+ holder.dateText.setText(TimeUtils.formatDate(message.getTimestamp(), TimeUtils.DATE_SHORT_FORMAT));
+ holder.titleOwnMessage.setVisibility(View.VISIBLE);
+ holder.timeOwnText.setText(TimeUtils.formatTime(message));
+ break;
+ }
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_TIME: {
+ log("CHAT_ADAPTER_SHOW_TIME");
+ holder.dateLayout.setVisibility(View.GONE);
+ holder.titleOwnMessage.setVisibility(View.VISIBLE);
+ holder.timeOwnText.setText(TimeUtils.formatTime(message));
+ break;
+ }
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_NOTHING: {
+ log("CHAT_ADAPTER_SHOW_NOTHING");
+ holder.dateLayout.setVisibility(View.GONE);
+ holder.titleOwnMessage.setVisibility(View.GONE);
+ break;
+ }
+ }
+ }
+
+ holder.ownMessageLayout.setVisibility(View.VISIBLE);
+ holder.contactMessageLayout.setVisibility(View.GONE);
+ holder.ownManagementMessageLayout.setVisibility(View.GONE);
+ holder.contentOwnMessageLayout.setVisibility(View.VISIBLE);
+
+ //Forward element (own message)
+ holder.forwardOwnRichLinks.setVisibility(View.GONE);
+ holder.forwardOwnPortrait.setVisibility(View.GONE);
+ holder.forwardOwnLandscape.setVisibility(View.GONE);
+ holder.forwardOwnFile.setVisibility(View.GONE);
+ holder.forwardOwnContact.setVisibility(View.GONE);
+
+ holder.contentOwnMessageLayout.setVisibility(View.VISIBLE);
+ holder.ownManagementMessageLayout.setVisibility(View.GONE);
+ holder.contentOwnMessageText.setVisibility(View.VISIBLE);
+
+ holder.previewFrameLand.setVisibility(View.GONE);
+ holder.previewFramePort.setVisibility(View.GONE);
+
+ holder.contentOwnMessageFileLayout.setVisibility(View.GONE);
+ holder.contentOwnMessageContactLayout.setVisibility(View.GONE);
+
+ int status = message.getStatus();
+
+ if ((status == MegaChatMessage.STATUS_SERVER_REJECTED) || (status == MegaChatMessage.STATUS_SENDING_MANUAL)) {
+ log("Show triangle retry!");
+ holder.contentOwnMessageText.setTextColor(ContextCompat.getColor(context, R.color.white));
+ holder.contentOwnMessageText.setBackground(ContextCompat.getDrawable(context, R.drawable.light_rounded_chat_own_message));
+ holder.triangleIcon.setVisibility(View.VISIBLE);
+ holder.retryAlert.setVisibility(View.VISIBLE);
+
+ } else if ((status == MegaChatMessage.STATUS_SENDING)) {
+ holder.contentOwnMessageText.setTextColor(ContextCompat.getColor(context, R.color.white));
+ holder.contentOwnMessageText.setBackground(ContextCompat.getDrawable(context, R.drawable.light_rounded_chat_own_message));
+ holder.triangleIcon.setVisibility(View.GONE);
+ holder.retryAlert.setVisibility(View.GONE);
+
+ } else {
+ log("Status: " + message.getStatus());
+
+ holder.contentOwnMessageText.setTextColor(ContextCompat.getColor(context, R.color.white));
+ holder.contentOwnMessageText.setBackground(ContextCompat.getDrawable(context, R.drawable.dark_rounded_chat_own_message));
+ holder.triangleIcon.setVisibility(View.GONE);
+ holder.retryAlert.setVisibility(View.GONE);
+ }
+
+ holder.contentOwnMessageText.setTextColor(ContextCompat.getColor(context, R.color.white));
+ holder.contentOwnMessageText.setText(context.getString(R.string.error_meta_message_invalid));
+
+ if (Util.isOnline(context)) {
+ if(isMultipleSelect()){
+ holder.contentOwnMessageText.setLinksClickable(false);
+ }else{
+ holder.contentOwnMessageText.setLinksClickable(true);
+ Linkify.addLinks(holder.contentOwnMessageText, Linkify.WEB_URLS);
+ holder.contentOwnMessageText.setLinkTextColor(ContextCompat.getColor(context, R.color.white));
+ }
+ }else {
+ holder.contentOwnMessageText.setLinksClickable(false);
+ }
+
+
+ }else{
+ long userHandle = message.getUserHandle();
+ log("Contact message!!: " + userHandle);
+
+ if (((ChatActivityLollipop) context).isGroup()) {
+
+ holder.fullNameTitle = cC.getFullName(userHandle, 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: " + message.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: " + message.getUserHandle());
+ }
+ }
+
+ holder.nameContactText.setVisibility(View.VISIBLE);
+ holder.nameContactText.setText(((ViewHolderMessageChat) holder).fullNameTitle);
+ } else {
+ holder.fullNameTitle = chatRoom.getTitle();
+ holder.nameContactText.setVisibility(View.GONE);
+ }
+
+ if(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
+ holder.titleContactMessage.setPadding(Util.scaleWidthPx(CONTACT_MESSAGE_LAND,outMetrics),0,0,0);
+ }else{
+ holder.titleContactMessage.setPadding(Util.scaleWidthPx(CONTACT_MESSAGE_PORT, outMetrics),0,0,0);
+ }
+
+ //forward element (contact message)
+ holder.forwardContactRichLinks.setVisibility(View.GONE);
+ holder.forwardContactContact.setVisibility(View.GONE);
+ holder.forwardContactPreviewLandscape.setVisibility(View.GONE);
+ holder.forwardContactPreviewPortrait.setVisibility(View.GONE);
+ holder.forwardContactFile.setVisibility(View.GONE);
+
+ if (messages.get(position - 1).getInfoToShow() != -1) {
+ switch (messages.get(position - 1).getInfoToShow()) {
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_ALL: {
+ log("CHAT_ADAPTER_SHOW_ALL");
+ ((ViewHolderMessageChat) holder).dateLayout.setVisibility(View.VISIBLE);
+ ((ViewHolderMessageChat) holder).dateText.setText(TimeUtils.formatDate(message.getTimestamp(), TimeUtils.DATE_SHORT_FORMAT));
+ ((ViewHolderMessageChat) holder).titleContactMessage.setVisibility(View.VISIBLE);
+ ((ViewHolderMessageChat) holder).timeContactText.setText(TimeUtils.formatTime(message));
+ ((ViewHolderMessageChat) holder).timeContactText.setVisibility(View.VISIBLE);
+ break;
+ }
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_TIME: {
+ log("CHAT_ADAPTER_SHOW_TIME--");
+ ((ViewHolderMessageChat) holder).dateLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).titleContactMessage.setVisibility(View.VISIBLE);
+ ((ViewHolderMessageChat) holder).timeContactText.setText(TimeUtils.formatTime(message));
+ ((ViewHolderMessageChat) holder).timeContactText.setVisibility(View.VISIBLE);
+ break;
+ }
+ case AndroidMegaChatMessage.CHAT_ADAPTER_SHOW_NOTHING: {
+ log("CHAT_ADAPTER_SHOW_NOTHING");
+ ((ViewHolderMessageChat) holder).dateLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).timeContactText.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).titleContactMessage.setVisibility(View.GONE);
+ break;
+ }
+ }
+ }
+
+ holder.ownMessageLayout.setVisibility(View.GONE);
+ holder.contactMessageLayout.setVisibility(View.VISIBLE);
+
+ holder.contactManagementMessageLayout.setVisibility(View.GONE);
+ holder.contentContactMessageLayout.setVisibility(View.VISIBLE);
+
+
+ if (messages.get(position - 1).isShowAvatar()) {
+ ((ViewHolderMessageChat) holder).layoutAvatarMessages.setVisibility(View.VISIBLE);
+ setContactAvatar(((ViewHolderMessageChat) holder), userHandle, ((ViewHolderMessageChat) holder).fullNameTitle);
+ } else {
+ ((ViewHolderMessageChat) holder).layoutAvatarMessages.setVisibility(View.GONE);
+ }
+
+
+ ((ViewHolderMessageChat) holder).ownMessageLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).contactMessageLayout.setVisibility(View.VISIBLE);
+
+ ((ViewHolderMessageChat) holder).contactManagementMessageLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).contentContactMessageLayout.setVisibility(View.VISIBLE);
+
+ ((ViewHolderMessageChat) holder).contentContactMessageText.setVisibility(View.VISIBLE);
+
+ ((ViewHolderMessageChat) holder).contentContactMessageAttachLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).urlContactMessageLayout.setVisibility(View.GONE);
+ ((ViewHolderMessageChat) holder).contentContactMessageContactLayout.setVisibility(View.GONE);
+
+ //COlor always status SENT
+ ((ViewHolderMessageChat) holder).contentContactMessageText.setTextColor(ContextCompat.getColor(context, R.color.name_my_account));
+ ((ViewHolderMessageChat) holder).contentContactMessageText.setText(context.getString(R.string.error_meta_message_invalid));
+
+ }
+
+ }else {
log("Link to bind as a no type message");
bindNoTypeMessage(holder, androidMessage, position);
}
@@ -5179,7 +5401,7 @@ public void bindNodeAttachmentMessage(ViewHolderMessageChat holder, AndroidMegaC
holder.videoTimecontentContactMessageThumbPort.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(node.getName()).isVideo()) {
- log("Contact message - Is video preview");
+ log("(1)Contact message - Is video preview");
holder.gradientContactMessageThumbPort.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbPort.setVisibility(View.VISIBLE);
holder.videoTimecontentContactMessageThumbPort.setText(timeVideo(node));
@@ -5243,7 +5465,7 @@ public void bindNodeAttachmentMessage(ViewHolderMessageChat holder, AndroidMegaC
holder.videoTimecontentContactMessageThumbLand.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(node.getName()).isVideo()) {
- log("Contact message - Is video preview");
+ log("(2)Contact message - Is video preview");
holder.gradientContactMessageThumbLand.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbLand.setVisibility(View.VISIBLE);
holder.videoTimecontentContactMessageThumbLand.setText(timeVideo(node));
@@ -6400,28 +6622,23 @@ public void bindNoTypeMessage(ViewHolderMessageChat holder, AndroidMegaChatMessa
((ViewHolderMessageChat) holder).ownMessageLayout.setVisibility(View.VISIBLE);
((ViewHolderMessageChat) holder).contactMessageLayout.setVisibility(View.GONE);
-
((ViewHolderMessageChat) holder).contentOwnMessageText.setTextColor(ContextCompat.getColor(context, R.color.tour_bar_red));
+
if(message.getType()==MegaChatMessage.TYPE_INVALID){
if(message.getCode()==MegaChatMessage.INVALID_FORMAT){
((ViewHolderMessageChat) holder).contentOwnMessageText.setText(context.getString(R.string.error_message_invalid_format));
- }
- else if(message.getCode()==MegaChatMessage.INVALID_SIGNATURE){
+ }else if(message.getCode()==MegaChatMessage.INVALID_SIGNATURE){
((ViewHolderMessageChat) holder).contentOwnMessageText.setText(context.getString(R.string.error_message_invalid_signature));
- }
- else{
+ }else{
((ViewHolderMessageChat) holder).contentOwnMessageText.setText(context.getString(R.string.error_message_unrecognizable));
}
- }
- else{
+ }else{
((ViewHolderMessageChat) holder).contentOwnMessageText.setText(context.getString(R.string.error_message_unrecognizable));
}
((ViewHolderMessageChat) holder).contentOwnMessageLayout.setVisibility(View.VISIBLE);
-
((ViewHolderMessageChat) holder).ownManagementMessageLayout.setVisibility(View.GONE);
-
((ViewHolderMessageChat) holder).contentOwnMessageLayout.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
((ViewHolderMessageChat) holder).previewFrameLand.setVisibility(View.GONE);
@@ -6532,18 +6749,16 @@ else if(message.getCode()==MegaChatMessage.INVALID_SIGNATURE){
((ViewHolderMessageChat) holder).contactManagementMessageLayout.setVisibility(View.GONE);
((ViewHolderMessageChat) holder).contentContactMessageText.setTextColor(ContextCompat.getColor(context, R.color.tour_bar_red));
+
if(message.getType()==MegaChatMessage.TYPE_INVALID){
if(message.getCode()==MegaChatMessage.INVALID_FORMAT){
((ViewHolderMessageChat) holder).contentContactMessageText.setText(context.getString(R.string.error_message_invalid_format));
- }
- else if(message.getCode()==MegaChatMessage.INVALID_SIGNATURE){
+ }else if(message.getCode()==MegaChatMessage.INVALID_SIGNATURE){
((ViewHolderMessageChat) holder).contentContactMessageText.setText(context.getString(R.string.error_message_invalid_signature));
- }
- else{
+ }else{
((ViewHolderMessageChat) holder).contentContactMessageText.setText(context.getString(R.string.error_message_unrecognizable));
}
- }
- else{
+ }else{
((ViewHolderMessageChat) holder).contentContactMessageText.setText(context.getString(R.string.error_message_unrecognizable));
}
@@ -7044,7 +7259,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");
@@ -7233,7 +7448,7 @@ private void setContactPreview(MegaChatLollipopAdapter.ViewHolderMessageChat hol
holder.videoTimecontentContactMessageThumbPort.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(node.getName()).isVideo()) {
- log("Contact message - Is video preview");
+ log("(3)Contact message - Is video preview");
holder.gradientContactMessageThumbPort.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbPort.setVisibility(View.VISIBLE);
holder.videoTimecontentContactMessageThumbPort.setText(timeVideo(node));
@@ -7300,7 +7515,7 @@ private void setContactPreview(MegaChatLollipopAdapter.ViewHolderMessageChat hol
holder.videoTimecontentContactMessageThumbLand.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(node.getName()).isVideo()) {
- log("Contact message - Is video preview");
+ log("(4)Contact message - Is video preview");
holder.gradientContactMessageThumbLand.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbLand.setVisibility(View.VISIBLE);
holder.videoTimecontentContactMessageThumbLand.setText(timeVideo(node));
@@ -7354,7 +7569,7 @@ private void setContactPreview(MegaChatLollipopAdapter.ViewHolderMessageChat hol
}
}
- private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageChat holder) {
+ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageChat holder, MegaNode node) {
log("setPreview() handle: " + handle);
if (holder != null) {
@@ -7373,7 +7588,6 @@ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageCh
if (holder.userHandle == megaChatApi.getMyUserHandle()) {
String name = holder.contentOwnMessageFileName.getText().toString();
- MegaNode node = megaApi.getNodeByHandle(handle);
log("Update my preview: " + name);
if (bitmap.getWidth() < bitmap.getHeight()) {
@@ -7487,7 +7701,6 @@ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageCh
} else {
log("Update my contacts preview");
String name = holder.contentContactMessageFileName.getText().toString();
- MegaNode node = megaApi.getNodeByHandle(handle);
if (bitmap.getWidth() < bitmap.getHeight()) {
@@ -7504,7 +7717,7 @@ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageCh
holder.videoTimecontentContactMessageThumbPort.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(name).isVideo()) {
- log("Contact message - Is video preview");
+ log("(5)Contact message - Is video preview");
holder.gradientContactMessageThumbPort.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbPort.setVisibility(View.VISIBLE);
@@ -7579,7 +7792,7 @@ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageCh
holder.videoTimecontentContactMessageThumbLand.setVisibility(View.GONE);
} else if (MimeTypeList.typeForName(name).isVideo()) {
- log("Contact message - Is video preview");
+ log("(6)Contact message - Is video preview");
holder.gradientContactMessageThumbLand.setVisibility(View.VISIBLE);
holder.videoIconContactMessageThumbLand.setVisibility(View.VISIBLE);
@@ -7587,6 +7800,7 @@ private void setPreview(long handle, MegaChatLollipopAdapter.ViewHolderMessageCh
holder.videoTimecontentContactMessageThumbLand.setText(timeVideo(node));
holder.videoTimecontentContactMessageThumbLand.setVisibility(View.VISIBLE);
} else {
+ log("setPreview:Landscape:Node is NULL");
holder.videoTimecontentContactMessageThumbLand.setVisibility(View.GONE);
}
@@ -7790,8 +8004,6 @@ private void setUploadingPreview(MegaChatLollipopAdapter.ViewHolderMessageChat h
holder.errorUploadingLandscape.setVisibility(View.VISIBLE);
holder.transparentCoatingLandscape.setVisibility(View.VISIBLE);
-
-
}
} else {
log("Message is in progress state");
@@ -7837,11 +8049,13 @@ private class PreviewDownloadListener implements MegaRequestListenerInterface {
Context context;
MegaChatLollipopAdapter.ViewHolderMessageChat holder;
MegaChatLollipopAdapter adapter;
+ MegaNode node;
- PreviewDownloadListener(Context context, MegaChatLollipopAdapter.ViewHolderMessageChat holder, MegaChatLollipopAdapter adapter) {
+ PreviewDownloadListener(Context context, MegaChatLollipopAdapter.ViewHolderMessageChat holder, MegaChatLollipopAdapter adapter, MegaNode node) {
this.context = context;
this.holder = holder;
this.adapter = adapter;
+ this.node = node;
}
@Override
@@ -7861,7 +8075,7 @@ public void onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e) {
long handle = request.getNodeHandle();
pendingPreviews.remove(handle);
- setPreview(handle, holder);
+ setPreview(handle, holder, node);
} else {
log("ERROR: " + e.getErrorCode() + "___" + e.getErrorString());
}
@@ -7880,23 +8094,27 @@ public void onRequestUpdate(MegaApiJava api, MegaRequest request) {
}
public String timeVideo(MegaNode n) {
- int duration = n.getDuration();
- String timeString = "";
-
- if (duration > 0) {
- int hours = duration / 3600;
- int minutes = (duration % 3600) / 60;
- int seconds = duration % 60;
+ log("timeVideo");
+ if(n!=null){
+ int duration = n.getDuration();
+ String timeString = "";
+ log("duration: "+n.getDuration());
+ if (duration > 0) {
+ int hours = duration / 3600;
+ int minutes = (duration % 3600) / 60;
+ int seconds = duration % 60;
+
+ if (hours > 0) {
+ timeString = String.format("%d:%d:%02d", hours, minutes, seconds);
+ } else {
+ timeString = String.format("%d:%02d", minutes, seconds);
+ }
- 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);
}
-
- log("The duration is: " + hours + " " + minutes + " " + seconds);
+ return timeString;
}
- return timeString;
+ return "";
}
public void checkItem (View v, ViewHolderMessageChat holder, int[] screenPosition, int[] dimens) {
@@ -7990,7 +8208,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:
@@ -8079,7 +8297,6 @@ public boolean onLongClick(View view) {
//
// }
}else{
- log("CONTAINS_META_INVALID");
}
}else{
log("OTHER TYPE ");
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 5aee8f2a6fb..ee4f459d407 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
@@ -9,7 +9,6 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
-import android.hardware.camera2.CameraManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
@@ -238,8 +237,13 @@ public void onBindViewHolder(ViewHolderChatList holder, int position) {
if (chat.getTitle().length() > 0){
String chatTitle = chat.getTitle().trim();
- String firstLetter = chatTitle.charAt(0) + "";
- firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+
+ String firstLetter = "";
+ if(!chatTitle.isEmpty()){
+ firstLetter = chatTitle.charAt(0) + "";
+ firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+ }
+
((ViewHolderNormalChatList)holder).contactInitialLetter.setText(firstLetter);
}
@@ -1116,15 +1120,19 @@ public void setTitle(int position, ViewHolderChatList holder) {
else{
if (title.length() > 0){
String chatTitle = title.trim();
- String firstLetter = chatTitle.charAt(0) + "";
- firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+
+ String firstLetter = "";
+ if(!chatTitle.isEmpty()){
+ firstLetter = chatTitle.charAt(0) + "";
+ firstLetter = firstLetter.toUpperCase(Locale.getDefault());
+ }
+
((ViewHolderNormalChatList)holder).contactInitialLetter.setText(firstLetter);
}
createGroupChatAvatar(holder);
}
}
-
}
else{
log("Holder is NULL: "+position);
@@ -1908,6 +1916,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();
@@ -2141,7 +2161,6 @@ else if(messageType==MegaChatMessage.TYPE_CALL_ENDED){
((ViewHolderNormalChatList)holder).textViewContent.setText(lastMessageString);
}
-
}
}
}
@@ -2151,16 +2170,16 @@ else if(messageType==MegaChatMessage.TYPE_CALL_ENDED){
}
}
- public void setChats (ArrayList chats){
- log("SETCONTACTS!!!!");
- this.chats = chats;
- if(chats!=null)
- {
- log("num requests: "+chats.size());
- }
+ public void setChats (ArrayList updatedChats){
+ log("setChats: "+ updatedChats.size());
+ this.chats = updatedChats;
positionClicked = -1;
-// listFragment.invalidate();
+
+ if(listFragment!=null){
+ listFragment.invalidate();
+ }
+
notifyDataSetChanged();
}
diff --git a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaParticipantsChatLollipopAdapter.java b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaParticipantsChatLollipopAdapter.java
index 1999c944b97..dce02b65de8 100644
--- a/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaParticipantsChatLollipopAdapter.java
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/MegaParticipantsChatLollipopAdapter.java
@@ -29,6 +29,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.MarqueeTextView;
import mega.privacy.android.app.components.RoundedImageView;
import mega.privacy.android.app.lollipop.listeners.ChatParticipantAvatarListener;
import mega.privacy.android.app.lollipop.megachat.GroupChatInfoActivityLollipop;
@@ -91,7 +92,7 @@ public ViewHolderParticipantsList(View v) {
}
RoundedImageView imageView;
TextView contactInitialLetter;
- TextView textViewContent;
+ MarqueeTextView textViewContent;
RelativeLayout threeDotsLayout;
ImageView imageButtonThreeDots;
ImageView statusImage;
@@ -138,7 +139,7 @@ public ViewHolderParticipants onCreateViewHolder(ViewGroup parent, int viewType)
holderList.imageView = (RoundedImageView) v.findViewById(R.id.participant_list_thumbnail);
holderList.contactInitialLetter = (TextView) v.findViewById(R.id.participant_list_initial_letter);
holderList.textViewContactName = (TextView) v.findViewById(R.id.participant_list_name);
- holderList.textViewContent = (TextView) v.findViewById(R.id.participant_list_content);
+ holderList.textViewContent = (MarqueeTextView) v.findViewById(R.id.participant_list_content);
holderList.threeDotsLayout = (RelativeLayout) v.findViewById(R.id.participant_list_three_dots_layout);
holderList.imageButtonThreeDots = (ImageView) v.findViewById(R.id.participant_list_three_dots);
holderList.permissionsIcon = (ImageView) v.findViewById(R.id.participant_list_permissions);
@@ -154,6 +155,7 @@ public ViewHolderParticipants onCreateViewHolder(ViewGroup parent, int viewType)
holderList.textViewContent.setMaxWidth(Util.scaleWidthPx(180, outMetrics));
}
+ holderList.itemLayout.setOnClickListener(this);
holderList.itemLayout.setTag(holderList);
v.setTag(holderList);
return holderList;
@@ -243,6 +245,7 @@ else if(userStatus == MegaChatApi.STATUS_INVALID){
if(userStatus != MegaChatApi.STATUS_ONLINE && userStatus != MegaChatApi.STATUS_BUSY && userStatus != MegaChatApi.STATUS_INVALID){
if(!participant.getLastGreen().isEmpty()){
((ViewHolderParticipantsList)holder).textViewContent.setText(participant.getLastGreen());
+ ((ViewHolderParticipantsList)holder).textViewContent.isMarqueeIsNecessary(context);
}
}
@@ -624,7 +627,8 @@ public void onClick(View v) {
}
switch (v.getId()){
- case R.id.participant_list_three_dots_layout:{
+ case R.id.participant_list_three_dots_layout:
+ case R.id.participant_list_item_layout:{
log("contact_list_three_dots");
ViewHolderParticipantsList holder = (ViewHolderParticipantsList) v.getTag();
int currentPosition = holder.currentPosition;
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..1f1508d7957
--- /dev/null
+++ b/app/src/main/java/mega/privacy/android/app/lollipop/megachat/chatAdapters/NodeAttachmentHistoryAdapter.java
@@ -0,0 +1,976 @@
+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.text.TextUtils;
+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.controllers.ChatController;
+import mega.privacy.android.app.lollipop.listeners.ChatNonContactNameListener;
+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;
+
+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;
+ MegaChatApiAndroid megaChatApi;
+
+ // int positionClicked;
+ ArrayList messages;
+
+ Object fragment;
+ long parentHandle = -1;
+ DisplayMetrics outMetrics;
+
+ private SparseBooleanArray selectedItems;
+
+ RecyclerView listFragment;
+
+ DatabaseHandler dbH = null;
+ boolean multipleSelect;
+
+ ChatController cC;
+
+ int adapterType;
+
+ public static class ViewHolderBrowser extends RecyclerView.ViewHolder {
+
+ public ViewHolderBrowser(View v) {
+ super(v);
+ }
+
+ public ImageView savedOffline;
+ public ImageView publicLinkImage;
+ public TextView textViewFileName;
+ public TextView textViewMessageInfo;
+ public long document;
+ public RelativeLayout itemLayout;
+ String fullNameTitle;
+ boolean nameRequestedAction = false;
+ }
+
+ public static class ViewHolderBrowserList extends NodeAttachmentHistoryAdapter.ViewHolderBrowser {
+
+ public ViewHolderBrowserList(View v) {
+ super(v);
+ }
+ public ImageView imageView;
+ public RelativeLayout threeDotsLayout;
+ public ImageView versionsIcon;
+ ImageView threeDotsImageView;
+ }
+
+ 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");
+
+ ((NodeAttachmentHistoryActivity)context).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) {
+ ((NodeAttachmentHistoryActivity)context).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) {
+ ((NodeAttachmentHistoryActivity)context).hideMultipleSelect();
+ }
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+
+ }
+ });
+
+ view.imageView.startAnimation(flipAnimation);
+
+ } else {
+ log("view is null - not animation");
+ if (selectedItems.size() <= 0) {
+ ((NodeAttachmentHistoryActivity)context).hideMultipleSelect();
+ }
+ }
+ } else {
+ log("adapter type is GRID");
+
+ if (selectedItems.size() <= 0) {
+ ((NodeAttachmentHistoryActivity)context).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 ArrayList 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();
+ }
+
+ if (megaChatApi == null) {
+ megaChatApi = ((MegaApplication) ((Activity) context).getApplication()).getMegaChatApi();
+ }
+
+ cC = new ChatController(context);
+ }
+
+ public void setMessages(ArrayList messages) {
+ this.messages = messages;
+ 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.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.textViewMessageInfo = (TextView)v.findViewById(R.id.file_list_filesize);
+ holderList.threeDotsLayout = (RelativeLayout)v.findViewById(R.id.file_list_three_dots_layout);
+ 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);
+ 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.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);
+ 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.textViewMessageInfo.setMaxWidth(Util.scaleWidthPx(70,outMetrics));
+ } else {
+ holderGrid.textViewMessageInfo.setMaxWidth(Util.scaleWidthPx(130,outMetrics));
+ }
+
+ if (holderGrid.textViewMessageInfo != null) {
+ holderGrid.textViewMessageInfo.setVisibility(View.VISIBLE);
+ } else {
+ 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);
+
+ 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.textViewMessageInfo.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.textViewMessageInfo.setVisibility(View.GONE);
+
+ holder.textViewFileNameForFile.setText(node.getName());
+ long nodeSize = node.getSize();
+ holder.textViewMessageInfo.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.textViewMessageInfo.setText("");
+
+ 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_shared_file_chat, holder.fullNameTitle, date);
+
+ holder.textViewMessageInfo.setText(secondRowInfo);
+ holder.textViewMessageInfo.setVisibility(View.VISIBLE);
+
+ 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,m);
+ break;
+ }
+ case R.id.file_grid_three_dots_for_file: {
+ threeDotsClicked(currentPosition,m);
+ 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();
+
+ ((NodeAttachmentHistoryActivity)context).itemClick(currentPosition);
+ break;
+ }
+ }
+ }
+
+ 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);
+ ((NodeAttachmentHistoryActivity)context).showNodeAttachmentBottomSheet(m, currentPosition);
+ }
+
+ @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();
+
+ ((NodeAttachmentHistoryActivity)context).activateActionMode();
+ ((NodeAttachmentHistoryActivity)context).itemClick(currentPosition);
+
+ 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/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/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/ChatBottomSheetDialogFragment.java b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/ChatBottomSheetDialogFragment.java
index 54ef62b5083..8f04cec497b 100644
--- a/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/ChatBottomSheetDialogFragment.java
+++ b/app/src/main/java/mega/privacy/android/app/modalbottomsheet/chatmodalbottomsheet/ChatBottomSheetDialogFragment.java
@@ -311,6 +311,7 @@ else if(state == MegaChatApi.STATUS_INVALID){
archiveChatText.setText(getString(R.string.unarchive_chat_option));
archiveChatIcon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_b_unarchive));
optionInfoChat.setVisibility(View.GONE);
+ separatorInfo.setVisibility(View.GONE);
optionMuteChat.setVisibility(View.GONE);
optionLeaveChat.setVisibility(View.GONE);
optionClearHistory.setVisibility(View.GONE);
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 ca27fc925d8..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
@@ -3,7 +3,6 @@
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
-import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Bundle;
@@ -29,14 +28,13 @@
import mega.privacy.android.app.lollipop.controllers.ChatController;
import mega.privacy.android.app.lollipop.megachat.AndroidMegaChatMessage;
import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop;
-import mega.privacy.android.app.lollipop.megachat.NodeAttachmentActivityLollipop;
+import mega.privacy.android.app.lollipop.megachat.NodeAttachmentHistoryActivity;
import mega.privacy.android.app.modalbottomsheet.UtilsModalBottomSheet;
import mega.privacy.android.app.utils.ThumbnailUtils;
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.MegaChatRoom;
import nz.mega.sdk.MegaNode;
import nz.mega.sdk.MegaNodeList;
@@ -114,10 +112,9 @@ public void onCreate(Bundle savedInstanceState) {
chatId = ((ChatActivityLollipop) context).idChat;
messageId = ((ChatActivityLollipop) context).selectedMessageId;
}
- else{
- chatId = ((NodeAttachmentActivityLollipop) context).chatId;
- messageId = ((NodeAttachmentActivityLollipop) context).messageId;
- handle = ((NodeAttachmentActivityLollipop) context).selectedNode.getHandle();
+ else if(context instanceof NodeAttachmentHistoryActivity){
+ chatId = ((NodeAttachmentHistoryActivity) context).chatId;
+ messageId = ((NodeAttachmentHistoryActivity) context).selectedMessageId;
}
log("Id Chat and Message id: "+chatId+ "___"+messageId);
@@ -374,17 +371,12 @@ public void onClick(View v) {
if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop)context).showSnackbar(getString(R.string.error_server_connection_problem));
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop)context).showSnackbar(getString(R.string.error_server_connection_problem));
- }
}
else{
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:{
@@ -394,12 +386,8 @@ else if(context instanceof NodeAttachmentActivityLollipop){
return;
}
- if(context instanceof ChatActivityLollipop){
- chatC.prepareForChatDownload(nodeList);
- }
- else if(context instanceof NodeAttachmentActivityLollipop){
- chatC.prepareForChatDownload(node);
- }
+ chatC.prepareForChatDownload(nodeList);
+
break;
}
case R.id.option_import_layout:{
@@ -409,24 +397,10 @@ else if(context instanceof NodeAttachmentActivityLollipop){
return;
}
- if(context instanceof ChatActivityLollipop){
- ((ChatActivityLollipop)context).importNode(messageId);
- }
- else if(context instanceof NodeAttachmentActivityLollipop){
- ((NodeAttachmentActivityLollipop)context).importNode();
- }
+ chatC.importNode(messageId, chatId);
break;
}
- case R.id.option_view_layout:{
- log("View option");
- Intent i = new Intent(context, NodeAttachmentActivityLollipop.class);
- i.putExtra("chatId", chatId);
- i.putExtra("messageId", messageId);
- context.startActivity(i);
- dismissAllowingStateLoss();
- break;
- }
case R.id.option_save_offline_layout:{
log("Save for offline option");
if(node==null){
@@ -434,19 +408,13 @@ else if(context instanceof NodeAttachmentActivityLollipop){
return;
}
- if(context instanceof ChatActivityLollipop){
-
- if(message!=null){
- ArrayList messages = new ArrayList<>();
- messages.add(message);
- chatC.saveForOfflineWithMessages(messages);
- }
- else{
- log("Message is NULL");
- }
+ if(message!=null){
+ ArrayList messages = new ArrayList<>();
+ messages.add(message);
+ chatC.saveForOfflineWithAndroidMessages(messages);
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- chatC.saveForOffline(((NodeAttachmentActivityLollipop) context).selectedNode);
+ else{
+ log("Message is NULL");
}
break;
@@ -458,17 +426,11 @@ else if(context instanceof NodeAttachmentActivityLollipop){
return;
}
- MegaChatRoom mChatRoom = ((ChatActivityLollipop)context).getChatRoom();
- if(context instanceof ChatActivityLollipop){
-
- if(message!=null){
- chatC.deleteMessage(message.getMessage(), mChatRoom.getChatId());
- }
- else{
- log("Message is NULL");
- }
+ if(message!=null){
+ chatC.deleteMessage(message.getMessage(), chatId);
}
- else if(context instanceof NodeAttachmentActivityLollipop){
+ else{
+ log("Message is NULL");
}
break;
@@ -480,7 +442,6 @@ else if(context instanceof NodeAttachmentActivityLollipop){
mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}
-
@Override
public void onAttach(Activity activity) {
log("onAttach");
@@ -488,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/java/mega/privacy/android/app/providers/FileProviderActivity.java b/app/src/main/java/mega/privacy/android/app/providers/FileProviderActivity.java
index 8a187635f87..be7193e1d40 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(false);
}
}
}
@@ -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(false);
} else {
log("ERROR INIT CHAT: " + ret);
megaChatApi.logout(this);
diff --git a/app/src/main/java/mega/privacy/android/app/snackbarListeners/SnackbarNavigateOption.java b/app/src/main/java/mega/privacy/android/app/snackbarListeners/SnackbarNavigateOption.java
index 557bc3fdf34..9a5b160592c 100644
--- a/app/src/main/java/mega/privacy/android/app/snackbarListeners/SnackbarNavigateOption.java
+++ b/app/src/main/java/mega/privacy/android/app/snackbarListeners/SnackbarNavigateOption.java
@@ -14,7 +14,6 @@
import mega.privacy.android.app.lollipop.PdfViewerActivityLollipop;
import mega.privacy.android.app.lollipop.megachat.ChatActivityLollipop;
import mega.privacy.android.app.lollipop.megachat.ChatFullScreenImageViewer;
-import mega.privacy.android.app.lollipop.megachat.NodeAttachmentActivityLollipop;
import mega.privacy.android.app.utils.Constants;
public class SnackbarNavigateOption implements View.OnClickListener{
@@ -87,13 +86,6 @@ else if(context instanceof ChatActivityLollipop){
((ChatActivityLollipop)context).startActivity(settingIntent);
((ChatActivityLollipop)context).finish();
}
- else if(context instanceof NodeAttachmentActivityLollipop){
- Intent settingIntent = new Intent(context, ManagerActivityLollipop.class);
- settingIntent.setAction(Constants.ACTION_SHOW_SETTINGS_STORAGE);
- settingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- ((NodeAttachmentActivityLollipop)context).startActivity(settingIntent);
- ((NodeAttachmentActivityLollipop)context).finish();
- }
else if(context instanceof ChatFullScreenImageViewer){
Intent settingIntent = new Intent(context, ManagerActivityLollipop.class);
settingIntent.setAction(Constants.ACTION_SHOW_SETTINGS_STORAGE);
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 7bbdcdf68e5..fc25ae53662 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
@@ -190,6 +190,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";
@@ -215,7 +217,6 @@ public class Constants {
final public static int INCOMING_REQUEST_ADAPTER = 2012;
final public static int OUTGOING_REQUEST_ADAPTER = 2013;
final public static int CAMERA_UPLOAD_ADAPTER = 2014;
- final public static int NODE_ATTACHMENT_ADAPTER = 2015;
final public static int INCOMING_SHARES_PROVIDER_ADAPTER = 2016;
final public static int CLOUD_DRIVE_PROVIDER_ADAPTER = 2017;
final public static int SEARCH_BY_ADAPTER = 2018;
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..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
@@ -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;
@@ -411,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");
+ }
+ }
}
}
}
@@ -436,10 +447,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 +483,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 +883,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 +1256,10 @@ static class AttachThumbnailTaskGrid extends AsyncTask {
@@ -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/java/mega/privacy/android/app/utils/Util.java b/app/src/main/java/mega/privacy/android/app/utils/Util.java
index ce62ff10c9e..ec1aa4c0eb8 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/java/nz/mega/sdk/.gitignore b/app/src/main/java/nz/mega/sdk/.gitignore
index abf2ff67fb9..842b5f5a736 100644
--- a/app/src/main/java/nz/mega/sdk/.gitignore
+++ b/app/src/main/java/nz/mega/sdk/.gitignore
@@ -75,6 +75,7 @@
/MegaTransferData.java
/MegaChatContainsMeta.java
/MegaChatRichPreview.java
+/MegaChatGeolocation.java
/MegaBackupListener.java
/MegaBackup.java
diff --git a/app/src/main/java/nz/mega/sdk/MegaChatSession.java b/app/src/main/java/nz/mega/sdk/MegaChatSession.java
new file mode 100644
index 00000000000..de5e34322a6
--- /dev/null
+++ b/app/src/main/java/nz/mega/sdk/MegaChatSession.java
@@ -0,0 +1,76 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 3.0.12
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package nz.mega.sdk;
+
+public class MegaChatSession {
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
+
+ protected MegaChatSession(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr(MegaChatSession obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+
+ protected void finalize() {
+ delete();
+ }
+
+ protected synchronized void delete() {
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ megachatJNI.delete_MegaChatSession(swigCPtr);
+ }
+ swigCPtr = 0;
+ }
+}
+
+ MegaChatSession copy() {
+ long cPtr = megachatJNI.MegaChatSession_copy(swigCPtr, this);
+ return (cPtr == 0) ? null : new MegaChatSession(cPtr, false);
+ }
+
+ public int getStatus() {
+ return megachatJNI.MegaChatSession_getStatus(swigCPtr, this);
+ }
+
+ public long getPeerid() {
+ return megachatJNI.MegaChatSession_getPeerid(swigCPtr, this);
+ }
+
+ public boolean hasAudio() {
+ return megachatJNI.MegaChatSession_hasAudio(swigCPtr, this);
+ }
+
+ public boolean hasVideo() {
+ return megachatJNI.MegaChatSession_hasVideo(swigCPtr, this);
+ }
+
+ public int getNetworkQuality() {
+ return megachatJNI.MegaChatSession_getNetworkQuality(swigCPtr, this);
+ }
+
+ public boolean getAudioDetected() {
+ return megachatJNI.MegaChatSession_getAudioDetected(swigCPtr, this);
+ }
+
+ public MegaChatSession() {
+ this(megachatJNI.new_MegaChatSession(), true);
+ }
+
+ public final static int SESSION_STATUS_INVALID = 0xFF;
+ public final static int SESSION_STATUS_INITIAL = 0;
+ public final static int SESSION_STATUS_IN_PROGRESS = SESSION_STATUS_INITIAL + 1;
+ public final static int SESSION_STATUS_DESTROYED = SESSION_STATUS_IN_PROGRESS + 1;
+
+}
diff --git a/app/src/main/java/org/webrtc/SurfaceViewRenderer.java b/app/src/main/java/org/webrtc/SurfaceViewRenderer.java
index ccfb9d0641e..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/jni/build.sh b/app/src/main/jni/build.sh
index 700c2a98213..b329c035517 100755
--- a/app/src/main/jni/build.sh
+++ b/app/src/main/jni/build.sh
@@ -16,11 +16,11 @@ APP_PLATFORM=`grep APP_PLATFORM Application.mk | cut -d '=' -f 2`
LOG_FILE=/dev/null
CRYPTOPP=cryptopp
-CRYPTOPP_VERSION=563
+CRYPTOPP_VERSION=800
CRYPTOPP_SOURCE_FILE=cryptopp${CRYPTOPP_VERSION}.zip
CRYPTOPP_SOURCE_FOLDER=${CRYPTOPP}/${CRYPTOPP}
CRYPTOPP_DOWNLOAD_URL=http://www.cryptopp.com/${CRYPTOPP_SOURCE_FILE}
-CRYPTOPP_SHA1="f2fcd1fbf884bed70a69b565970ecd8b33a68cc4"
+CRYPTOPP_SHA1="dd0dc0586c0a3e0696cd323efc6fa2e2945ad920"
SQLITE=sqlite
SQLITE_VERSION=3120200
@@ -289,6 +289,7 @@ echo "* Setting up Crypto++"
if [ ! -f ${CRYPTOPP}/${CRYPTOPP_SOURCE_FILE}.ready ]; then
mkdir -p ${CRYPTOPP}/${CRYPTOPP}
downloadCheckAndUnpack ${CRYPTOPP_DOWNLOAD_URL} ${CRYPTOPP}/${CRYPTOPP_SOURCE_FILE} ${CRYPTOPP_SHA1} ${CRYPTOPP}/${CRYPTOPP}
+ cp ${NDK_ROOT}/sources/android/cpufeatures/cpu-features.h ${CRYPTOPP}/${CRYPTOPP}/
touch ${CRYPTOPP}/${CRYPTOPP_SOURCE_FILE}.ready
fi
echo "* Crypto++ is ready"
diff --git a/app/src/main/jni/cryptopp/Android.mk b/app/src/main/jni/cryptopp/Android.mk
index eb4610501c4..1157124c54d 100644
--- a/app/src/main/jni/cryptopp/Android.mk
+++ b/app/src/main/jni/cryptopp/Android.mk
@@ -3,9 +3,10 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp
-LOCAL_CFLAGS := -DCRYPTOPP_DISABLE_X86ASM -DCRYPTOPP_DISABLE_SSSE3 -DCRYPTOPP_DISABLE_AESNI -D__ILP32__=0 -D_ILP32=0 -Wno-macro-redefined -fvisibility=hidden -fvisibility-inlines-hidden -fdata-sections -ffunction-sections
-LOCAL_SRC_FILES := $(addprefix cryptopp/, 3way.cpp crc.cpp eax.cpp idea.cpp mqv.cpp rabin.cpp safer.cpp socketft.cpp twofish.cpp zinflate.cpp bfinit.cpp cryptlib_bds.cpp ec2n.cpp gcm.cpp integer.cpp nbtheory.cpp randpool.cpp salsa.cpp sosemanuk.cpp zlib.cpp adler32.cpp blowfish.cpp cryptlib.cpp eccrypto.cpp gf2_32.cpp iterhash.cpp network.cpp rc2.cpp seal.cpp square.cpp algebra.cpp blumshub.cpp ecp.cpp gf256.cpp luc.cpp oaep.cpp rc5.cpp seed.cpp squaretb.cpp algparam.cpp camellia.cpp default.cpp elgamal.cpp gf2n.cpp mars.cpp osrng.cpp rc6.cpp serpent.cpp strciphr.cpp vmac.cpp arc4.cpp cast.cpp des.cpp emsa2.cpp gfpcrypt.cpp marss.cpp panama.cpp rdtables.cpp sha3.cpp tea.cpp wait.cpp asn.cpp casts.cpp dessp.cpp eprecomp.cpp gost.cpp md2.cpp pch.cpp shacal2.cpp wake.cpp authenc.cpp cbcmac.cpp dh2.cpp esign.cpp gzip.cpp md4.cpp pkcspad.cpp rijndael.cpp sha.cpp tftables.cpp whrlpool.cpp base32.cpp ccm.cpp dh.cpp files.cpp hex.cpp md5.cpp polynomi.cpp ripemd.cpp sharkbox.cpp tiger.cpp winpipes.cpp base64.cpp channels.cpp dll.cpp filters.cpp hmac.cpp misc.cpp pssr.cpp rng.cpp shark.cpp tigertab.cpp xtr.cpp basecode.cpp cmac.cpp fips140.cpp hrtimer.cpp modes.cpp pubkey.cpp rsa.cpp simple.cpp trdlocal.cpp xtrcrypt.cpp cpu.cpp dsa.cpp fipsalgt.cpp ida.cpp mqueue.cpp queue.cpp rw.cpp skipjack.cpp ttmac.cpp zdeflate.cpp)
+LOCAL_CFLAGS := -DCRYPTOPP_DISABLE_ASM -fvisibility=hidden -fvisibility-inlines-hidden -fdata-sections -ffunction-sections
+LOCAL_SRC_FILES := $(addprefix cryptopp/, cryptlib.cpp cpu.cpp integer.cpp 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp aria.cpp aria_simd.cpp ariatab.cpp asn.cpp authenc.cpp base32.cpp base64.cpp basecode.cpp bfinit.cpp blake2.cpp blake2b_simd.cpp blake2s_simd.cpp blowfish.cpp blumshub.cpp camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp chacha.cpp chacha_avx.cpp chacha_simd.cpp cham.cpp cham_simd.cpp channels.cpp cmac.cpp crc.cpp crc_simd.cpp darn.cpp default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dll.cpp donna_32.cpp donna_64.cpp donna_sse.cpp dsa.cpp eax.cpp ec2n.cpp eccrypto.cpp ecp.cpp elgamal.cpp emsa2.cpp eprecomp.cpp esign.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gcm.cpp gcm_simd.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp hc128.cpp hc256.cpp hex.cpp hight.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp iterhash.cpp kalyna.cpp kalynatab.cpp keccak.cpp keccakc.cpp lea.cpp lea_simd.cpp luc.cpp mars.cpp marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp neon_simd.cpp oaep.cpp osrng.cpp padlkrng.cpp panama.cpp pkcspad.cpp poly1305.cpp polynomi.cpp ppc_power7.cpp ppc_power8.cpp ppc_power9.cpp ppc_simd.cpp pssr.cpp pubkey.cpp queue.cpp rabbit.cpp rabin.cpp randpool.cpp rc2.cpp rc5.cpp rc6.cpp rdrand.cpp rdtables.cpp rijndael.cpp rijndael_simd.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp scrypt.cpp seal.cpp seed.cpp serpent.cpp sha.cpp sha3.cpp sha_simd.cpp shacal2.cpp shacal2_simd.cpp shark.cpp sharkbox.cpp simeck.cpp simeck_simd.cpp simon.cpp simon128_simd.cpp simon64_simd.cpp skipjack.cpp sm3.cpp sm4.cpp sm4_simd.cpp sosemanuk.cpp speck.cpp speck128_simd.cpp speck64_simd.cpp square.cpp squaretb.cpp sse_simd.cpp strciphr.cpp tea.cpp tftables.cpp threefish.cpp tiger.cpp tigertab.cpp ttmac.cpp tweetnacl.cpp twofish.cpp vmac.cpp wake.cpp whrlpool.cpp xed25519.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp zinflate.cpp zlib.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_EXPORT_CFLAGS := -DCRYPTOPP_DISABLE_X86ASM -DCRYPTOPP_DISABLE_SSSE3 -DCRYPTOPP_DISABLE_AESNI -D__ILP32__=0 -D_ILP32=0 -Wno-macro-redefined
+LOCAL_EXPORT_CFLAGS := -DCRYPTOPP_DISABLE_ASM
include $(BUILD_STATIC_LIBRARY)
+
diff --git a/app/src/main/jni/mega/sdk b/app/src/main/jni/mega/sdk
index 41d84f2b662..bc871137935 160000
--- a/app/src/main/jni/mega/sdk
+++ b/app/src/main/jni/mega/sdk
@@ -1 +1 @@
-Subproject commit 41d84f2b6627591e448001c2129a2244c9a83e98
+Subproject commit bc87113793532637ba645291cb2ee00b885cd3ea
diff --git a/app/src/main/jni/megachat/sdk b/app/src/main/jni/megachat/sdk
index 9c9b9ccef93..58ba59f76f8 160000
--- a/app/src/main/jni/megachat/sdk
+++ b/app/src/main/jni/megachat/sdk
@@ -1 +1 @@
-Subproject commit 9c9b9ccef937a0fb26194b236d310dba382cc7e8
+Subproject commit 58ba59f76f8d072df47b3ae452720cfe2f57de8a
diff --git a/app/src/main/res/drawable-hdpi/ic_mic_off_contact.png b/app/src/main/res/drawable-hdpi/ic_mic_off_contact.png
new file mode 100644
index 00000000000..ed008111dfe
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_mic_off_contact.png differ
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 00000000000..35cb1cd8590
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_storage_full.png differ
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 00000000000..d399674bed9
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_w_end_call.png differ
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 00000000000..e67d977647d
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_mic_off_contact.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_storage_full.png b/app/src/main/res/drawable-mdpi/ic_storage_full.png
new file mode 100644
index 00000000000..b3a72231122
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_storage_full.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_w_end_call.png b/app/src/main/res/drawable-mdpi/ic_w_end_call.png
new file mode 100644
index 00000000000..be11a909a79
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_w_end_call.png differ
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 00000000000..fd0943db8b7
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_mic_off_contact.png differ
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 00000000000..f7b29c6e99e
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_storage_full.png differ
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 00000000000..fc09ad5841e
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_w_end_call.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_mic_off_contact.png b/app/src/main/res/drawable-xxhdpi/ic_mic_off_contact.png
new file mode 100644
index 00000000000..969b774432e
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_mic_off_contact.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_storage_full.png b/app/src/main/res/drawable-xxhdpi/ic_storage_full.png
new file mode 100644
index 00000000000..0bfb6c8848a
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_storage_full.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_w_end_call.png b/app/src/main/res/drawable-xxhdpi/ic_w_end_call.png
new file mode 100644
index 00000000000..008664697a5
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_w_end_call.png differ
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 00000000000..59a018247d7
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_mic_off_contact.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_storage_full.png b/app/src/main/res/drawable-xxxhdpi/ic_storage_full.png
new file mode 100644
index 00000000000..c255571d9d6
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_storage_full.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_w_end_call.png b/app/src/main/res/drawable-xxxhdpi/ic_w_end_call.png
new file mode 100644
index 00000000000..77b8c0c7b1a
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_w_end_call.png differ
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/drawable/background_item_grid_new.xml b/app/src/main/res/drawable/background_item_grid_new.xml
index 7c856d88453..ee120fab443 100644
--- a/app/src/main/res/drawable/background_item_grid_new.xml
+++ b/app/src/main/res/drawable/background_item_grid_new.xml
@@ -1,7 +1,7 @@
-
-
+
+ android:bottomLeftRadius="5dp"
+ android:bottomRightRadius="5dp"
+ android:topLeftRadius="5dp"
+ android:topRightRadius="5dp"/>
\ No newline at end of file
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/drawable/icon_quality.xml b/app/src/main/res/drawable/icon_quality.xml
new file mode 100644
index 00000000000..c00609dd74f
--- /dev/null
+++ b/app/src/main/res/drawable/icon_quality.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
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 d1933e8f74a..637b40baa4e 100644
--- a/app/src/main/res/layout/activity_calls_chat.xml
+++ b/app/src/main/res/layout/activity_calls_chat.xml
@@ -1,84 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ android:fitsSystemWindows="true">
-
+ android:layout_height="match_parent">
-
-
-
+
-
+
+
+
-
-
-
+ android:gravity="center"
+ android:orientation="vertical">
-
-
-
+ android:nestedScrollingEnabled="false"
+ android:horizontalSpacing="0dp"
+ android:verticalSpacing="0dp"
+ android:numColumns="auto_fit"
+ android:stretchMode="columnWidth"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+ android:background="@drawable/shape_call_chat">
-
+
+
+
+
+
-
-
-
+
+
-
-
-
+ android:layout_marginBottom="24dp"
+ android:layout_below="@+id/linear_arrow_call"
+ android:scaleType="center"
+ android:src="@drawable/ic_phone_white"
+ app:backgroundTint="@color/accentColor"
+ app:borderWidth="0dp"
+ app:elevation="6dp"
+ app:fabSize="normal"
+ app:pressedTranslationZ="12dp" />
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
+ 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|center_horizontal"
+ android:visibility="gone"
+ android:background="@null">
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml
index 3a3a513fd2e..91ee92abcae 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">
-
-
-
-
-
-
@@ -401,39 +395,15 @@
android:background="@color/accentColor">
+ android:layout_centerHorizontal="true"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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..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,7 +133,7 @@
android:singleLine="true"
android:textAppearance="@style/ToolbarTitle.Secondary" />
-
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/activity_node_history.xml b/app/src/main/res/layout/activity_node_history.xml
new file mode 100644
index 00000000000..621f9fac1b2
--- /dev/null
+++ b/app/src/main/res/layout/activity_node_history.xml
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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"/>
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
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/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
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/fragment_remote_camera_call_full_screen.xml b/app/src/main/res/layout/fragment_remote_camera_call_full_screen.xml
new file mode 100644
index 00000000000..c3d6db46b94
--- /dev/null
+++ b/app/src/main/res/layout/fragment_remote_camera_call_full_screen.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
\ 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..de2a3020f0b
--- /dev/null
+++ b/app/src/main/res/layout/item_camera_group_call.xml
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/item_contact_grid.xml b/app/src/main/res/layout/item_contact_grid.xml
index 85a9463fe4c..388b788b37f 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">
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/item_contact_list.xml b/app/src/main/res/layout/item_contact_list.xml
index b85b65e48e1..9154877a695 100644
--- a/app/src/main/res/layout/item_contact_list.xml
+++ b/app/src/main/res/layout/item_contact_list.xml
@@ -94,14 +94,14 @@
android:background="@null"
android:src="@drawable/circle_status_contact_offline" />
-
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..f1f0d867e4a 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:layout_height="172dp">
+ android:scaleType="fitXY"
+ android:paddingTop="1dp"
+ android:paddingRight="1dp"
+ android:paddingLeft="1dp"/>
+ android:layout_marginTop="7dp"/>
+ android:visibility="gone"/>
+ android:scaleType="fitXY"
+ android:paddingTop="1dp"
+ android:paddingRight="1dp"
+ android:paddingLeft="1dp"/>
+ android:layout_marginTop="7dp"/>
-
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" >