diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java index 70ccb7814..2799361af 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java @@ -25,9 +25,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Bitmap; -import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.ColorDrawable; import android.media.AudioAttributes; import android.media.MediaPlayer; import android.net.Uri; @@ -46,14 +44,12 @@ import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.imagepipeline.core.ImagePipeline; import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber; import com.facebook.imagepipeline.image.CloseableImage; -import com.facebook.imagepipeline.postprocessors.BlurPostProcessor; import com.facebook.imagepipeline.request.ImageRequest; import com.nextcloud.talk.R; import com.nextcloud.talk.api.NcApi; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.databinding.CallNotificationActivityBinding; import com.nextcloud.talk.events.CallNotificationClick; -import com.nextcloud.talk.events.ConfigurationChangeEvent; import com.nextcloud.talk.models.RingtoneSettings; import com.nextcloud.talk.models.database.CapabilitiesUtil; import com.nextcloud.talk.models.database.UserEntity; @@ -66,12 +62,8 @@ import com.nextcloud.talk.utils.DisplayUtils; import com.nextcloud.talk.utils.DoNotDisturbUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.preferences.AppPreferences; -import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder; import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; -import org.michaelevans.colorart.library.ColorArt; import org.parceler.Parcels; import java.io.IOException; @@ -82,7 +74,6 @@ import javax.inject.Inject; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import androidx.constraintlayout.widget.ConstraintLayout; import autodagger.AutoInjector; import butterknife.OnClick; import io.reactivex.Observer; @@ -91,10 +82,11 @@ import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import okhttp3.Cache; +@SuppressLint("LongLogTag") @AutoInjector(NextcloudTalkApplication.class) public class CallNotificationActivity extends CallActivityBase { - public static final String TAG = "CallNotificationA"; + public static final String TAG = "CallNotificationActivity"; @Inject NcApi ncApi; @@ -159,7 +151,6 @@ public class CallNotificationActivity extends CallActivityBase { initClickListeners(); } - @SuppressLint({"LongLogTag"}) @Override public void onStart() { super.onStart(); @@ -177,11 +168,13 @@ public class CallNotificationActivity extends CallActivityBase { private void initClickListeners() { binding.callAnswerVoiceOnlyView.setOnClickListener(l -> { + Log.d(TAG, "accept call (voice only)"); originalBundle.putBoolean(BundleKeys.INSTANCE.getKEY_CALL_VOICE_ONLY(), true); proceedToCall(); }); binding.callAnswerCameraView.setOnClickListener(l -> { + Log.d(TAG, "accept call (with video)"); originalBundle.putBoolean(BundleKeys.INSTANCE.getKEY_CALL_VOICE_ONLY(), false); proceedToCall(); }); @@ -305,7 +298,6 @@ public class CallNotificationActivity extends CallActivityBase { } } - @SuppressLint("LongLogTag") @Override public void onError(@io.reactivex.annotations.NonNull Throwable e) { Log.e(TAG, e.getMessage(), e); @@ -326,80 +318,40 @@ public class CallNotificationActivity extends CallActivityBase { private void setUpAfterConversationIsKnown() { binding.conversationNameTextView.setText(currentConversation.getDisplayName()); -// loadAvatar(); // TODO: loadAvatar always makes problems! also now for PIP mode! needs to be rewritten! + if(currentConversation.getType() == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL){ + setAvatarForOneToOneCall(); + } else { + binding.avatarImageView.setImageResource(R.drawable.ic_circular_group); + } + checkIfAnyParticipantsRemainInRoom(); showAnswerControls(); } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onMessageEvent(ConfigurationChangeEvent configurationChangeEvent) { - ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.avatarImageView.getLayoutParams(); - int dimen = (int) getResources().getDimension(R.dimen.avatar_size_very_big); + private void setAvatarForOneToOneCall() { + ImageRequest imageRequest = + DisplayUtils.getImageRequestForUrl( + ApiUtils.getUrlForAvatarWithName(userBeingCalled.getBaseUrl(), + currentConversation.getName(), + R.dimen.avatar_size_big), null); - layoutParams.width = dimen; - layoutParams.height = dimen; - binding.avatarImageView.setLayoutParams(layoutParams); - } + ImagePipeline imagePipeline = Fresco.getImagePipeline(); + DataSource> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); - private void loadAvatar() { - switch (currentConversation.getType()) { - case ROOM_TYPE_ONE_TO_ONE_CALL: - binding.avatarImageView.setVisibility(View.VISIBLE); + dataSource.subscribe(new BaseBitmapDataSubscriber() { + @Override + protected void onNewResultImpl(@Nullable Bitmap bitmap) { + binding.avatarImageView.getHierarchy().setImage( + new BitmapDrawable(getResources(), bitmap), + 100, + true); + } - ImageRequest imageRequest = - DisplayUtils.getImageRequestForUrl( - ApiUtils.getUrlForAvatarWithName(userBeingCalled.getBaseUrl(), - currentConversation.getName(), - R.dimen.avatar_size_very_big), - null); - - ImagePipeline imagePipeline = Fresco.getImagePipeline(); - DataSource> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); - - dataSource.subscribe(new BaseBitmapDataSubscriber() { - @Override - protected void onNewResultImpl(@Nullable Bitmap bitmap) { - binding.avatarImageView.getHierarchy().setImage(new BitmapDrawable(bitmap), 100, - true); - if (getResources() != null) { - binding.incomingCallRelativeLayout.setBackground( - getResources().getDrawable(R.drawable.incoming_gradient)); - } - - if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 200 || - AvatarStatusCodeHolder.getInstance().getStatusCode() == 0) { - - Bitmap backgroundBitmap = bitmap.copy(bitmap.getConfig(), true); - new BlurPostProcessor(5, context).process(backgroundBitmap); - binding.backgroundImageView.setImageDrawable(new BitmapDrawable(backgroundBitmap)); - - } else if (AvatarStatusCodeHolder.getInstance().getStatusCode() == 201) { - ColorArt colorArt = new ColorArt(bitmap); - int color = colorArt.getBackgroundColor(); - - float[] hsv = new float[3]; - Color.colorToHSV(color, hsv); - hsv[2] *= 0.75f; - color = Color.HSVToColor(hsv); - - binding.backgroundImageView.setImageDrawable(new ColorDrawable(color)); - } - } - - @Override - protected void onFailureImpl(DataSource> dataSource) { - // unused atm - } - }, UiThreadImmediateExecutorService.getInstance()); - - break; - case ROOM_GROUP_CALL: - binding.avatarImageView.setImageResource(R.drawable.ic_circular_group); - case ROOM_PUBLIC_CALL: - binding.avatarImageView.setImageResource(R.drawable.ic_circular_group); - break; - default: - } + @Override + protected void onFailureImpl(DataSource> dataSource) { + Log.e(TAG, "failed to load avatar"); + } + }, UiThreadImmediateExecutorService.getInstance()); } private void endMediaNotifications() { @@ -415,7 +367,6 @@ public class CallNotificationActivity extends CallActivityBase { @Override public void onDestroy() { - AvatarStatusCodeHolder.getInstance().setStatusCode(0); leavingScreen = true; if (handler != null) { handler.removeCallbacksAndMessages(null); @@ -436,7 +387,6 @@ public class CallNotificationActivity extends CallActivityBase { } } - @SuppressLint("LongLogTag") private void playRingtoneSound() { String callRingtonePreferenceString = appPreferences.getCallRingtoneUri(); Uri ringtoneUri; diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java b/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java index 49dc31ec9..467ff1876 100644 --- a/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java +++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java @@ -33,7 +33,6 @@ import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.LoggingUtils; import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.preferences.AppPreferences; -import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder; import com.nextcloud.talk.utils.ssl.MagicKeyManager; import com.nextcloud.talk.utils.ssl.MagicTrustManager; import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat; @@ -253,10 +252,6 @@ public class RestModule { Response response = chain.proceed(request); - if (request.url().encodedPath().contains("/avatar/")) { - AvatarStatusCodeHolder.getInstance().setStatusCode(response.code()); - } - return response; } } diff --git a/app/src/main/res/layout/call_notification_activity.xml b/app/src/main/res/layout/call_notification_activity.xml index 8d08a6841..76c3f710c 100644 --- a/app/src/main/res/layout/call_notification_activity.xml +++ b/app/src/main/res/layout/call_notification_activity.xml @@ -24,16 +24,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/controllerCallNotificationLayout" android:layout_width="match_parent" - android:layout_height="match_parent"> - - + android:layout_height="match_parent" + android:background="@color/grey950"> + app:roundAsCircle="true" /> diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml index 6c0f8d926..374fcf2b7 100644 --- a/app/src/main/res/values-land/dimens.xml +++ b/app/src/main/res/values-land/dimens.xml @@ -21,6 +21,4 @@ 24dp - - 120dp diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 61a76806e..e52c554ed 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -33,8 +33,6 @@ 40dp 30dp 96dp - @dimen/avatar_fetching_size_very_big - 180dp 14sp 6dp