Improved scrollToEnd and thumbnail bitmap for chat view

This commit is contained in:
Sylvain Berfini 2015-05-18 11:02:44 +02:00
parent 617beb7db6
commit b6771b24dc
3 changed files with 6 additions and 11 deletions

View file

@ -187,6 +187,7 @@
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:cacheColorHint="@color/transparent"
android:dividerHeight="1dp"
android:layout_above="@id/remoteComposing"

View file

@ -210,7 +210,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
LinphoneAddress from = cr.getPeerAddress();
if (from.asStringUriOnly().equals(sipUri)) {
invalidate();
scrollToEnd();
}
}
@ -507,9 +506,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
invalidate();
Log.i("Sent message current status: " + message.getStatus());
scrollToEnd();
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
}
@ -618,6 +615,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
private void invalidate() {
adapter.refreshHistory();
adapter.notifyDataSetChanged();
chatRoom.markAsRead();
}
private void resendMessage(int id) {
@ -635,11 +633,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
}
private void scrollToEnd() {
messagesList.smoothScrollToPosition(messagesList.getCount());
chatRoom.markAsRead();
}
private void copyTextMessageToClipboard(int id) {
String msg = LinphoneActivity.instance().getChatStorage().getTextMessageForId(chatRoom, id);
if (msg != null) {

View file

@ -39,6 +39,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.MediaStore;
@ -356,9 +357,9 @@ public class BubbleChat {
if (bm != null) {
if (bm.getWidth() >= bm.getHeight() && bm.getWidth() > SIZE_MAX) {
bm = Bitmap.createScaledBitmap(bm, SIZE_MAX, (SIZE_MAX * bm.getHeight()) / bm.getWidth(), false);
bm = ThumbnailUtils.extractThumbnail(bm, SIZE_MAX, (SIZE_MAX * bm.getHeight()) / bm.getWidth());
} else if (bm.getHeight() >= bm.getWidth() && bm.getHeight() > SIZE_MAX) {
bm = Bitmap.createScaledBitmap(bm, (SIZE_MAX * bm.getWidth()) / bm.getHeight(), SIZE_MAX, false);
bm = ThumbnailUtils.extractThumbnail(bm, (SIZE_MAX * bm.getWidth()) / bm.getHeight(), SIZE_MAX);
}
}
return bm;