Commit d6c18db9 authored by Torsten Grote's avatar Torsten Grote

[android] set image preview size to 1/4 of screen height

parent 8fe49d99
......@@ -259,7 +259,7 @@ public class ConversationActivity extends BriarActivity
textInputView.setEnabled(false);
textInputView.setListener(this);
if (FEATURE_FLAG_IMAGE_ATTACHMENTS) {
textInputView.setAttachImageListener(this);
textInputView.setAttachImageListener(this, getWindowManager());
}
}
......
......@@ -12,8 +12,11 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.AbsSavedState;
import android.support.v7.graphics.Palette;
import android.support.v7.widget.AppCompatImageButton;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.ImageView;
import com.bumptech.glide.load.DataSource;
......@@ -79,8 +82,16 @@ class TextAttachmentController extends TextSendController {
});
}
public void setAttachImageListener(AttachImageListener imageListener) {
public void setAttachImageListener(AttachImageListener imageListener,
WindowManager windowManager) {
this.imageListener = imageListener;
// set preview size based on screen height
DisplayMetrics displayMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.height = displayMetrics.heightPixels / 4;
imageView.setLayoutParams(layoutParams);
// show image button
showImageButton(true);
}
......
......@@ -15,6 +15,7 @@ import android.support.v7.widget.AppCompatImageButton;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import com.vanniktech.emoji.EmojiEditText;
import com.vanniktech.emoji.RecentEmoji;
......@@ -143,9 +144,10 @@ public class TextInputView extends KeyboardAwareLinearLayout {
textSendController.setSendListener(listener);
}
public void setAttachImageListener(AttachImageListener imageListener) {
public void setAttachImageListener(AttachImageListener imageListener,
WindowManager windowManager) {
attachmentController = (TextAttachmentController) textSendController;
attachmentController.setAttachImageListener(imageListener);
attachmentController.setAttachImageListener(imageListener, windowManager);
}
public void onImageReceived(@Nullable Intent resultData) {
......
......@@ -23,6 +23,7 @@
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="@dimen/text_input_image_height"
android:minHeight="@dimen/button_size"
tools:background="@color/msg_status_bubble_background"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/avatars"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment