From 64d98aefb4dee7fd510e828b0fc131b2e2e55acc Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 1 Jul 2021 19:47:06 +0200 Subject: [PATCH] - set bottom margin for grid for voicecall - temporarily comment out setOnTouchListener for grid (disables toggle of controls for now) - set android:scrollbars="vertical" for gridview - add callControlsHeight for item height calculation - add fake height to item that scrolling is testable Signed-off-by: Marcel Hibbe --- .../talk/adapters/ParticipantsAdapter.java | 18 +++++++-- .../talk/controllers/CallController.java | 38 ++++++++++++------- app/src/main/res/layout/controller_call.xml | 2 + 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java index 83a8ec453..eb14d8cc0 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java @@ -33,18 +33,21 @@ public class ParticipantsAdapter extends BaseAdapter { private final ArrayList participantDisplayItems; private final RelativeLayout gridViewWrapper; private final LinearLayout callInfosLinearLayout; + private final LinearLayout callControlsLinearLayout; private final int columns; private final boolean isVoiceOnlyCall; public ParticipantsAdapter(Context mContext, Map participantDisplayItems, RelativeLayout gridViewWrapper, - LinearLayout linearLayout, + LinearLayout callInfosLinearLayout, + LinearLayout callControlsLinearLayout, int columns, boolean isVoiceOnlyCall) { this.mContext = mContext; this.gridViewWrapper = gridViewWrapper; - this.callInfosLinearLayout = linearLayout; + this.callInfosLinearLayout = callInfosLinearLayout; + this.callControlsLinearLayout = callControlsLinearLayout; this.columns = columns; this.isVoiceOnlyCall = isVoiceOnlyCall; @@ -136,11 +139,18 @@ public class ParticipantsAdapter extends BaseAdapter { private int scaleGridViewItemHeight() { int headerHeight = 0; + int callControlsHeight = 0; if (callInfosLinearLayout.getVisibility() == View.VISIBLE && isVoiceOnlyCall) { headerHeight = callInfosLinearLayout.getHeight(); } - int itemHeight = (gridViewWrapper.getHeight() - headerHeight) / getRowsCount(getCount()); - return itemHeight; + if (callControlsLinearLayout.getVisibility() == View.VISIBLE && isVoiceOnlyCall) { + callControlsHeight = callControlsLinearLayout.getHeight(); + } + int itemHeight = (gridViewWrapper.getHeight() - headerHeight - callControlsHeight) / getRowsCount(getCount()); +// if (itemHeight < 9000) { +// itemHeight = 9000; +// } + return itemHeight + 10; } private int getRowsCount(int items) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index b100793f8..10f67e371 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -49,10 +49,6 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - import com.bluelinelabs.logansquare.LoganSquare; import com.facebook.drawee.view.SimpleDraweeView; import com.nextcloud.talk.R; @@ -143,6 +139,9 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import autodagger.AutoInjector; import butterknife.BindView; import butterknife.OnClick; @@ -484,8 +483,10 @@ public class CallController extends BaseController { cameraControlButton.setVisibility(View.GONE); pipVideoView.setVisibility(View.GONE); - RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.BELOW, R.id.callInfosLinearLayout); + params.setMargins(0,0,0,400); gridView.setLayoutParams(params); } else { callControlEnableSpeaker.setVisibility(View.GONE); @@ -502,15 +503,15 @@ public class CallController extends BaseController { pipVideoView.setOnTouchListener(new SelfVideoTouchListener()); } - gridView.setOnTouchListener(new View.OnTouchListener() { - public boolean onTouch(View v, MotionEvent me) { - int action = me.getActionMasked(); - if (action == MotionEvent.ACTION_DOWN) { - showCallControls(); - } - return true; - } - }); +// gridView.setOnTouchListener(new View.OnTouchListener() { +// public boolean onTouch(View v, MotionEvent me) { +// int action = me.getActionMasked(); +// if (action == MotionEvent.ACTION_DOWN) { +// showCallControls(); +// } +// return true; +// } +// }); initGridAdapter(); } @@ -561,11 +562,20 @@ public class CallController extends BaseController { } }); + LinearLayout callControlsLinearLayout = controllerCallLayout.findViewById(R.id.callControlsLinearLayout); + callControlsLinearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + callControlsLinearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); + } + }); + participantsAdapter = new ParticipantsAdapter( this.getActivity(), participantDisplayItems, gridViewWrapper, callInfosLinearLayout, + callControlsLinearLayout, columns, isVoiceOnlyCall); gridView.setAdapter(participantsAdapter); diff --git a/app/src/main/res/layout/controller_call.xml b/app/src/main/res/layout/controller_call.xml index 573f91bdf..0da8af1f5 100644 --- a/app/src/main/res/layout/controller_call.xml +++ b/app/src/main/res/layout/controller_call.xml @@ -52,6 +52,8 @@ android:gravity="center" android:stretchMode="columnWidth" android:numColumns="2" + android:scrollbars="vertical" + android:background="#fff000" />