gt: 						scalledH = (int) target;
context: package eu.siacs.conversations.ui;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Set;
  
  import net.java.otr4j.session.SessionStatus;
  import eu.siacs.conversations.R;
  import eu.siacs.conversations.crypto.PgpEngine;
  import eu.siacs.conversations.entities.Contact;
  import eu.siacs.conversations.entities.Conversation;
  import eu.siacs.conversations.entities.Message;
  import eu.siacs.conversations.entities.MucOptions;
  import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
  import eu.siacs.conversations.services.ImageProvider;
  import eu.siacs.conversations.services.XmppConnectionService;
  import eu.siacs.conversations.utils.UIHelper;
  import eu.siacs.conversations.xmpp.jingle.JingleConnection;
  import android.app.AlertDialog;
  import android.app.Fragment;
  import android.app.PendingIntent;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.IntentSender;
  import android.content.SharedPreferences;
  import android.content.IntentSender.SendIntentException;
  import android.graphics.Bitmap;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.text.Editable;
  import android.text.Selection;
  import android.util.DisplayMetrics;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.LinearLayout;
  import android.widget.ListView;
  import android.widget.ImageButton;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class ConversationFragment extends Fragment {
  
  	protected Conversation conversation;
  	protected ListView messagesView;
  	protected LayoutInflater inflater;
  	protected List<Message> messageList = new ArrayList<Message>();
  	protected ArrayAdapter<Message> messageListAdapter;
  	protected Contact contact;
  	protected BitmapCache mBitmapCache = new BitmapCache();
  
  	protected String queuedPqpMessage = null;
  
  	private EditText chatMsg;
  	private String pastedText = null;
  
  	protected Bitmap selfBitmap;
  
  	private boolean useSubject = true;
  
  	private IntentSender askForPassphraseIntent = null;
  
  	private OnClickListener sendMsgListener = new OnClickListener() {
  
  		@Override
  		public void onClick(View v) {
  			if (chatMsg.getText().length() < 1)
  				return;
  			Message message = new Message(conversation, chatMsg.getText()
  					.toString(), conversation.getNextEncryption());
  			if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) {
  				sendOtrMessage(message);
  			} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
  				sendPgpMessage(message);
  			} else {
  				sendPlainTextMessage(message);
  			}
  		}
  	};
  	protected OnClickListener clickToDecryptListener = new OnClickListener() {
  
  		@Override
  		public void onClick(View v) {
  			if (askForPassphraseIntent != null) {
  				try {
  					getActivity().startIntentSenderForResult(
  							askForPassphraseIntent,
  							ConversationActivity.REQUEST_DECRYPT_PGP, null, 0,
  							0, 0);
  				} catch (SendIntentException e) {
  					Log.d("xmppService", "couldnt fire intent");
  				}
  			}
  		}
  	};
  
  	private LinearLayout pgpInfo;
  	private LinearLayout mucError;
  	private TextView mucErrorText;
  	private OnClickListener clickToMuc = new OnClickListener() {
  
  		@Override
  		public void onClick(View v) {
  			Intent intent = new Intent(getActivity(), MucDetailsActivity.class);
  			intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
  			intent.putExtra("uuid", conversation.getUuid());
  			startActivity(intent);
  		}
  	};
  	private ConversationActivity activity;
  
  	public void hidePgpPassphraseBox() {
  		pgpInfo.setVisibility(View.GONE);
  	}
  
  	public void updateChatMsgHint() {
  		if (conversation.getMode() == Conversation.MODE_MULTI) {
  			chatMsg.setHint(getString(R.string.send_message_to_conference));
  		} else {
  			switch (conversation.getNextEncryption()) {
  			case Message.ENCRYPTION_NONE:
  				chatMsg.setHint(getString(R.string.send_plain_text_message));
  				break;
  			case Message.ENCRYPTION_OTR:
  				chatMsg.setHint(getString(R.string.send_otr_message));
  				break;
  			case Message.ENCRYPTION_PGP:
  				chatMsg.setHint(getString(R.string.send_pgp_message));
  				break;
  			default:
  				break;
  			}
  		}
  	}
  
  	@Override
  	public View onCreateView(final LayoutInflater inflater,
  			ViewGroup container, Bundle savedInstanceState) {
  
  		final DisplayMetrics metrics = getResources().getDisplayMetrics();
  
  		this.inflater = inflater;
  
  		final View view = inflater.inflate(R.layout.fragment_conversation,
  				container, false);
  		chatMsg = (EditText) view.findViewById(R.id.textinput);
  
  		ImageButton sendButton = (ImageButton) view
  				.findViewById(R.id.textSendButton);
  		sendButton.setOnClickListener(this.sendMsgListener);
  
  		pgpInfo = (LinearLayout) view.findViewById(R.id.pgp_keyentry);
  		pgpInfo.setOnClickListener(clickToDecryptListener);
  		mucError = (LinearLayout) view.findViewById(R.id.muc_error);
  		mucError.setOnClickListener(clickToMuc);
  		mucErrorText = (TextView) view.findViewById(R.id.muc_error_msg);
  
  		messagesView = (ListView) view.findViewById(R.id.messages_view);
  
  		messageListAdapter = new ArrayAdapter<Message>(this.getActivity()
  				.getApplicationContext(), R.layout.message_sent,
  				this.messageList) {
  
  			private static final int SENT = 0;
  			private static final int RECIEVED = 1;
  
  			@Override
  			public int getViewTypeCount() {
  				return 2;
  			}
  
  			@Override
  			public int getItemViewType(int position) {
  				if (getItem(position).getStatus() <= Message.STATUS_RECIEVED) {
  					return RECIEVED;
  				} else {
  					return SENT;
  				}
  			}
  
  			private void displayStatus(ViewHolder viewHolder, Message message) {
  				String filesize = null;
  				String info = null;
  				boolean error = false;
  				if (message.getType() == Message.TYPE_IMAGE) {
  					String[] fileParams = message.getBody().split(",");
  					try {
  						long size = Long.parseLong(fileParams[0]);
  						filesize = size / 1024 + " KB";
  					} catch (NumberFormatException e) {
  						filesize = "0 KB";
  					}
  				}
  				switch (message.getStatus()) {
  				case Message.STATUS_UNSEND:
  					info = getString(R.string.sending);
  					break;
  				case Message.STATUS_OFFERED:
  					info = getString(R.string.offering);
  					break;
  				case Message.STATUS_SEND_FAILED:
  					info = getString(R.string.send_failed);
  					error = true;
  					break;
  				case Message.STATUS_SEND_REJECTED:
  					info = getString(R.string.send_rejected);
  					error = true;
  					break;
  				default:
  					if ((message.getConversation().getMode() == Conversation.MODE_MULTI)
  							&& (message.getStatus() <= Message.STATUS_RECIEVED)) {
  						info = message.getCounterpart();
  					}
  					break;
  				}
  				if (error) {
  					viewHolder.time.setTextColor(0xFFe92727);
  				} else {
  					viewHolder.time.setTextColor(0xFF8e8e8e);
  				}
  				if (message.getEncryption() == Message.ENCRYPTION_NONE) {
  					viewHolder.indicator.setVisibility(View.GONE);
  				} else {
  					viewHolder.indicator.setVisibility(View.VISIBLE);
  				}
  
  				String formatedTime = UIHelper.readableTimeDifference(message
  						.getTimeSent());
  				if (message.getStatus() <= Message.STATUS_RECIEVED) {
  					if ((filesize != null) && (info != null)) {
  						viewHolder.time.setText(filesize + " \u00B7 " + info);
  					} else if ((filesize == null) && (info != null)) {
  						viewHolder.time.setText(formatedTime + " \u00B7 "
  								+ info);
  					} else if ((filesize != null) && (info == null)) {
  						viewHolder.time.setText(formatedTime + " \u00B7 "
  								+ filesize);
  					} else {
  						viewHolder.time.setText(formatedTime);
  					}
  				} else {
  					if ((filesize != null) && (info != null)) {
  						viewHolder.time.setText(filesize + " \u00B7 " + info);
  					} else if ((filesize == null) && (info != null)) {
  						viewHolder.time.setText(info + " \u00B7 "
  								+ formatedTime);
  					} else if ((filesize != null) && (info == null)) {
  						viewHolder.time.setText(filesize + " \u00B7 "
  								+ formatedTime);
  					} else {
  						viewHolder.time.setText(formatedTime);
  					}
  				}
  			}
  
  			private void displayInfoMessage(ViewHolder viewHolder, int r) {
  				if (viewHolder.download_button!=null) {
  					viewHolder.download_button.setVisibility(View.GONE);
  				}
  				viewHolder.image.setVisibility(View.GONE);
  				viewHolder.messageBody.setVisibility(View.VISIBLE);
  				viewHolder.messageBody.setText(getString(r));
  				viewHolder.messageBody.setTextColor(0xff33B5E5);
  				viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
  			}
  
  			private void displayDecryptionFailed(ViewHolder viewHolder) {
  				viewHolder.download_button.setVisibility(View.GONE);
  				viewHolder.image.setVisibility(View.GONE);
  				viewHolder.messageBody.setVisibility(View.VISIBLE);
  				viewHolder.messageBody
  						.setText(getString(R.string.decryption_failed));
  				viewHolder.messageBody.setTextColor(0xFFe92727);
  				viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
  			}
  
  			private void displayTextMessage(ViewHolder viewHolder, String text) {
  				if (viewHolder.download_button != null) {
  					viewHolder.download_button.setVisibility(View.GONE);
  				}
  				viewHolder.image.setVisibility(View.GONE);
  				viewHolder.messageBody.setVisibility(View.VISIBLE);
  				if (text != null) {
  					viewHolder.messageBody.setText(text.trim());
  				} else {
  					viewHolder.messageBody.setText("");
  				}
  				viewHolder.messageBody.setTextColor(0xff333333);
  				viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
  			}
  
  			private void displayImageMessage(ViewHolder viewHolder,
  					final Message message) {
  				if (viewHolder.download_button != null) {
  					viewHolder.download_button.setVisibility(View.GONE);
  				}
  				viewHolder.messageBody.setVisibility(View.GONE);
  				viewHolder.image.setVisibility(View.VISIBLE);
  				String[] fileParams = message.getBody().split(",");
  				if (fileParams.length == 3) {
  					double target = metrics.density * 288;
  					int w = Integer.parseInt(fileParams[1]);
  					int h = Integer.parseInt(fileParams[2]);
  					int scalledW;
  					int scalledH;
  					if (w <= h) {
  						scalledW = (int) (w / ((double) h / target));
  