Fixed spacing between images in files upload list
This commit is contained in:
parent
d29c6e9740
commit
cb99b78ae5
3 changed files with 16 additions and 2 deletions
|
@ -59,6 +59,7 @@ import org.linphone.LinphoneManager;
|
||||||
import org.linphone.settings.LinphonePreferences;
|
import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.utils.FileUtils;
|
import org.linphone.utils.FileUtils;
|
||||||
|
import org.linphone.utils.ImageUtils;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.LinphoneActivity;
|
import org.linphone.LinphoneActivity;
|
||||||
|
@ -838,6 +839,11 @@ public class ChatMessagesFragment extends Fragment implements ChatRoomListener,
|
||||||
mSendMessageButton.setEnabled(true);
|
mSendMessageButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bitmap scaleToFitHeight(Bitmap b, int height) {
|
||||||
|
float factor = height / (float) b.getHeight();
|
||||||
|
return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factor), height, true);
|
||||||
|
}
|
||||||
|
|
||||||
private void addImageToPendingList(String path) {
|
private void addImageToPendingList(String path) {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
Log.e("Can't add image to pending list because it's path is null...");
|
Log.e("Can't add image to pending list because it's path is null...");
|
||||||
|
@ -850,7 +856,7 @@ public class ChatMessagesFragment extends Fragment implements ChatRoomListener,
|
||||||
ImageView image = pendingImage.findViewById(R.id.pendingImageForUpload);
|
ImageView image = pendingImage.findViewById(R.id.pendingImageForUpload);
|
||||||
Bitmap bm = BitmapFactory.decodeFile(path);
|
Bitmap bm = BitmapFactory.decodeFile(path);
|
||||||
if (bm == null) return;
|
if (bm == null) return;
|
||||||
image.setImageBitmap(bm);
|
image.setImageBitmap(scaleToFitHeight(bm, (int) ImageUtils.dpToPixels(mContext, 100)));
|
||||||
|
|
||||||
ImageView remove = pendingImage.findViewById(R.id.remove);
|
ImageView remove = pendingImage.findViewById(R.id.remove);
|
||||||
remove.setTag(pendingImage);
|
remove.setTag(pendingImage);
|
||||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -29,6 +30,7 @@ import android.graphics.PorterDuffXfermode;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
@ -131,4 +133,10 @@ public class ImageUtils {
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float dpToPixels(Context context, float dp) {
|
||||||
|
Resources r = context.getResources();
|
||||||
|
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
|
||||||
|
return px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="100dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
Loading…
Reference in a new issue