Recording audio file is now supported.
This commit is contained in:
@@ -348,8 +348,12 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
private int xDelta;
|
||||
private String mAudioFilePath;
|
||||
private int mMaxMarginRight;
|
||||
private Rect mDialogContainer;
|
||||
private int mStartMarginLeft = 0;
|
||||
private int mInitialMarginX = 0;
|
||||
private int mInitialLeft = 0;
|
||||
private int mInitialMarginLeft = 0;
|
||||
|
||||
private void selectFile(int requestCode) {
|
||||
final String[] zipFileTypes = {".zip", ".rar", ".7z"};
|
||||
final String[] pdfFileTypes = {".pdf"};
|
||||
@@ -395,13 +399,6 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.setOnShowListener(dialog1 -> {
|
||||
mMaxMarginRight = ((GridLayout.LayoutParams) attachRecordAudioImageView.getLayoutParams()).leftMargin;
|
||||
mDialogContainer = ViewUtils.getRectFromView(dialog.findViewById(R.id.dialogGridLayout));
|
||||
});
|
||||
|
||||
Log.d("ON_TOUCH", "Upload max size: " + mUploadMaxSize.get());
|
||||
|
||||
final long duration = ((mUploadMaxSize.get() / 10 * 9) * 8) / (Constants.RECORDING_BIT_RATE_IN_MS / 1000); // 10% Overhead
|
||||
CountDownTimer countDownTimer = new CountDownTimer(duration, 10) {
|
||||
@Override
|
||||
@@ -440,6 +437,20 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
GridLayout.LayoutParams layoutParams1 = (GridLayout.LayoutParams) v.getLayoutParams();
|
||||
xDelta = x - layoutParams1.leftMargin;
|
||||
|
||||
Log.d("ON_TOUCH", "starting value of left margin: " + layoutParams1.leftMargin);
|
||||
|
||||
mInitialMarginLeft = ((GridLayout.LayoutParams) attachRecordAudioImageView.getLayoutParams()).leftMargin;
|
||||
|
||||
mDialogContainer = ViewUtils.getRectFromView(dialog.findViewById(R.id.dialogGridLayout));
|
||||
|
||||
|
||||
mInitialLeft = ViewUtils.getRectFromView(attachRecordAudioImageView).left;
|
||||
mInitialMarginX = mInitialLeft - mInitialMarginLeft;
|
||||
Log.d("ON_TOUCH", "initial left x value from audio recording button: " + mInitialMarginX + "; initial left: " + mInitialLeft);
|
||||
|
||||
Log.d("ON_TOUCH", "xDelta: " + xDelta);
|
||||
|
||||
|
||||
attachRecordAudioImageView.setImageResource(R.mipmap.ic_file_dialog_record_audio_pressed);
|
||||
limitTextView.setVisibility(View.VISIBLE);
|
||||
attachDocumentImageView.setVisibility(View.INVISIBLE);
|
||||
@@ -509,10 +520,9 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
int newLeft = x - xDelta;
|
||||
|
||||
int buttonLeft = ViewUtils.getRectFromView(attachRecordAudioImageView).left;
|
||||
int nextX = mInitialLeft + newLeft - (mInitialMarginLeft * 2);
|
||||
|
||||
boolean isMovingToRight = layoutParams2.leftMargin > newLeft;
|
||||
boolean isMovingWithinBounds = buttonLeft > mDialogContainer.left && newLeft < mMaxMarginRight;
|
||||
boolean isMovingWithinBounds = nextX >= mDialogContainer.left && newLeft < mInitialMarginLeft;
|
||||
|
||||
if(isMovingWithinBounds) {
|
||||
layoutParams2.leftMargin = newLeft;
|
||||
@@ -520,10 +530,6 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
v.setLayoutParams(layoutParams2);
|
||||
|
||||
dialog.findViewById(R.id.dialogGridLayout).invalidate();
|
||||
|
||||
Log.d("ON_TOUCH", "button left: " + buttonLeft + "; newLeft: " + newLeft);
|
||||
} else {
|
||||
Log.d("ON_TOUCH", "not moving within bounds: buttonLeft: " + buttonLeft + "; left border: " + mDialogContainer.left);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat_item_file"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="120dp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/chat_item_time"
|
||||
|
||||
@@ -92,8 +92,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat_item_file"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="120dp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/chat_item_time"
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat_item_file"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_below="@id/chat_item_time"
|
||||
android:layout_marginTop="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat_item_file"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/chat_item_time"
|
||||
android:layout_marginTop="4dp"
|
||||
|
||||
Reference in New Issue
Block a user