#SD-185 - Make the UI compatible with SMS parsing changes #4
@ -6,7 +6,6 @@ import java.util.Calendar;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -19,20 +18,18 @@ import com.safemobile.lib.Msg;
|
||||
import com.safemobile.lib.R;
|
||||
import com.safemobile.lib.SM;
|
||||
|
||||
public class ConversationGridViewAdapter extends BaseAdapter
|
||||
{
|
||||
private ArrayList<Msg> listMessages;
|
||||
private Activity activity;
|
||||
//public String time;
|
||||
private ArrayList<Boolean> dispatcher_positions = new ArrayList<Boolean>();
|
||||
private ArrayList<Boolean> ackPositions = new ArrayList<Boolean>();
|
||||
private Hashtable<Integer, View> hash = new Hashtable<Integer, View>();
|
||||
public class ConversationGridViewAdapter extends BaseAdapter {
|
||||
private final ArrayList<Msg> listMessages;
|
||||
private final Activity activity;
|
||||
private final ArrayList<Boolean> dispatcherPositions;
|
||||
private final ArrayList<Boolean> ackPositions;
|
||||
private final Hashtable<Integer, View> hash = new Hashtable<>();
|
||||
|
||||
|
||||
public ConversationGridViewAdapter(Activity activity, ArrayList<Msg> listMessages, Context context, long sc_id, int unit_type, ArrayList<Boolean> dispatcher_positions, ArrayList<Boolean> ackPositions) {
|
||||
public ConversationGridViewAdapter(Activity activity, ArrayList<Msg> listMessages, ArrayList<Boolean> dispatcherPositions, ArrayList<Boolean> ackPositions) {
|
||||
this.activity = activity;
|
||||
this.listMessages = listMessages;
|
||||
this.dispatcher_positions = dispatcher_positions;
|
||||
this.dispatcherPositions = dispatcherPositions;
|
||||
this.ackPositions = ackPositions;
|
||||
}
|
||||
|
||||
@ -51,149 +48,230 @@ public class ConversationGridViewAdapter extends BaseAdapter
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static class ViewHolder
|
||||
{
|
||||
public ImageView imgViewContact;
|
||||
public TextView txtViewMsg;
|
||||
public TextView txtViewDateTime;
|
||||
public ImageView imgViewReceivedContact;
|
||||
public TextView txtViewReceivedMsg;
|
||||
public TextView txtViewReceivedDateTime;
|
||||
public ImageView imageAck;
|
||||
public TextView textViewNotACK;
|
||||
public LinearLayout layoutSend;
|
||||
public LinearLayout layoutReceived;
|
||||
public static class ViewHolder {
|
||||
private ImageView imgViewContact;
|
||||
private TextView txtViewMsg;
|
||||
private TextView txtViewDateTime;
|
||||
private ImageView imgViewReceivedContact;
|
||||
private TextView txtViewReceivedMsg;
|
||||
private TextView txtViewReceivedDateTime;
|
||||
private ImageView imageAck;
|
||||
private TextView textViewNotACK;
|
||||
private LinearLayout layoutSend;
|
||||
private LinearLayout layoutReceived;
|
||||
|
||||
public ImageView getImgViewContact() {
|
||||
return imgViewContact;
|
||||
}
|
||||
|
||||
public void setImgViewContact(ImageView imgViewContact) {
|
||||
this.imgViewContact = imgViewContact;
|
||||
}
|
||||
|
||||
public TextView getTxtViewMsg() {
|
||||
return txtViewMsg;
|
||||
}
|
||||
|
||||
public void setTxtViewMsg(TextView txtViewMsg) {
|
||||
this.txtViewMsg = txtViewMsg;
|
||||
}
|
||||
|
||||
public TextView getTxtViewDateTime() {
|
||||
return txtViewDateTime;
|
||||
}
|
||||
|
||||
public void setTxtViewDateTime(TextView txtViewDateTime) {
|
||||
this.txtViewDateTime = txtViewDateTime;
|
||||
}
|
||||
|
||||
public ImageView getImgViewReceivedContact() {
|
||||
return imgViewReceivedContact;
|
||||
}
|
||||
|
||||
public void setImgViewReceivedContact(ImageView imgViewReceivedContact) {
|
||||
this.imgViewReceivedContact = imgViewReceivedContact;
|
||||
}
|
||||
|
||||
public TextView getTxtViewReceivedMsg() {
|
||||
return txtViewReceivedMsg;
|
||||
}
|
||||
|
||||
public void setTxtViewReceivedMsg(TextView txtViewReceivedMsg) {
|
||||
this.txtViewReceivedMsg = txtViewReceivedMsg;
|
||||
}
|
||||
|
||||
public TextView getTxtViewReceivedDateTime() {
|
||||
return txtViewReceivedDateTime;
|
||||
}
|
||||
|
||||
public void setTxtViewReceivedDateTime(TextView txtViewReceivedDateTime) {
|
||||
this.txtViewReceivedDateTime = txtViewReceivedDateTime;
|
||||
}
|
||||
|
||||
public ImageView getImageAck() {
|
||||
return imageAck;
|
||||
}
|
||||
|
||||
public void setImageAck(ImageView imageAck) {
|
||||
this.imageAck = imageAck;
|
||||
}
|
||||
|
||||
public TextView getTextViewNotACK() {
|
||||
return textViewNotACK;
|
||||
}
|
||||
|
||||
public void setTextViewNotACK(TextView textViewNotACK) {
|
||||
this.textViewNotACK = textViewNotACK;
|
||||
}
|
||||
|
||||
public LinearLayout getLayoutSend() {
|
||||
return layoutSend;
|
||||
}
|
||||
|
||||
public void setLayoutSend(LinearLayout layoutSend) {
|
||||
this.layoutSend = layoutSend;
|
||||
}
|
||||
|
||||
public LinearLayout getLayoutReceived() {
|
||||
return layoutReceived;
|
||||
}
|
||||
|
||||
public void setLayoutReceived(LinearLayout layoutReceived) {
|
||||
this.layoutReceived = layoutReceived;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder view;
|
||||
LayoutInflater inflator = activity.getLayoutInflater();
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
|
||||
if(convertView==null)
|
||||
{
|
||||
if (convertView == null) {
|
||||
view = new ViewHolder();
|
||||
convertView = inflator.inflate(R.layout.row_conversation, null);
|
||||
convertView = inflater.inflate(R.layout.row_conversation, null);
|
||||
|
||||
view.imgViewContact = (ImageView) convertView.findViewById(R.id.imageViewSenderIco);
|
||||
view.txtViewMsg = (TextView) convertView.findViewById(R.id.textViewSendMsg);
|
||||
view.txtViewDateTime = (TextView) convertView.findViewById(R.id.textViewSendDate);
|
||||
view.imgViewReceivedContact = (ImageView) convertView.findViewById(R.id.imageViewReceivedIco);
|
||||
view.txtViewReceivedMsg = (TextView) convertView.findViewById(R.id.textViewReceivedMsg);
|
||||
view.txtViewReceivedDateTime = (TextView) convertView.findViewById(R.id.textViewReceivedDate);
|
||||
view.layoutSend = (LinearLayout) convertView.findViewById(R.id.layoutSend);
|
||||
view.layoutReceived = (LinearLayout) convertView.findViewById(R.id.layoutReceived);
|
||||
view.textViewNotACK = (TextView) convertView.findViewById(R.id.textViewNotACKSendMsg);
|
||||
view.imageAck = (ImageView) convertView.findViewById(R.id.imageAck);
|
||||
view.setImgViewContact(convertView.findViewById(R.id.imageViewSenderIco));
|
||||
view.setTxtViewMsg(convertView.findViewById(R.id.textViewSendMsg));
|
||||
view.setTxtViewDateTime(convertView.findViewById(R.id.textViewSendDate));
|
||||
view.setImgViewReceivedContact(convertView.findViewById(R.id.imageViewReceivedIco));
|
||||
view.setTxtViewReceivedMsg(convertView.findViewById(R.id.textViewReceivedMsg));
|
||||
view.setTxtViewReceivedDateTime(convertView.findViewById(R.id.textViewReceivedDate));
|
||||
view.setLayoutSend(convertView.findViewById(R.id.layoutSend));
|
||||
view.setLayoutReceived(convertView.findViewById(R.id.layoutReceived));
|
||||
view.setTextViewNotACK(convertView.findViewById(R.id.textViewNotACK));
|
||||
view.setImageAck(convertView.findViewById(R.id.imageAck));
|
||||
|
||||
convertView.setTag(view);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
view = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
hash.put(position, convertView);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm MMM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
if(listMessages.get(position).received.after(calendar.getTime()))
|
||||
if (listMessages.get(position).received.after(calendar.getTime()))
|
||||
sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
else
|
||||
sdf = new SimpleDateFormat("HH:mm MMM-dd");
|
||||
|
||||
|
||||
//view.imgViewContact.setImageResource(getIcon(listMessages.get(position).from.user_type));
|
||||
view.imgViewContact.setImageResource(R.drawable.peoplegreen_large);
|
||||
view.txtViewMsg.setText(listMessages.get(position).message);
|
||||
view.txtViewDateTime.setText(sdf.format(listMessages.get(position).received));
|
||||
//view.imgViewReceivedContact.setImageResource(getIcon(listMessages.get(position).from.user_type));
|
||||
view.imgViewReceivedContact.setImageResource(listMessages.get(position).from.getLargeIcon());
|
||||
view.txtViewReceivedMsg.setText(listMessages.get(position).message);
|
||||
view.txtViewReceivedDateTime.setText(sdf.format(listMessages.get(position).received));
|
||||
view.getImgViewContact().setImageResource(R.drawable.peoplegreen_large);
|
||||
view.getTxtViewMsg().setText(listMessages.get(position).message);
|
||||
view.getTxtViewDateTime().setText(sdf.format(listMessages.get(position).received));
|
||||
view.getImgViewReceivedContact().setImageResource(listMessages.get(position).from.getLargeIcon());
|
||||
view.getTxtViewReceivedMsg().setText(listMessages.get(position).message);
|
||||
view.getTxtViewReceivedDateTime().setText(sdf.format(listMessages.get(position).received));
|
||||
|
||||
if(ackPositions.size() > 0)
|
||||
switch(ackPositions.get(position) ? 1: 0) {
|
||||
if (!ackPositions.isEmpty())
|
||||
switch (Boolean.TRUE.equals(ackPositions.get(position)) ? 1 : 0) {
|
||||
case 0:
|
||||
// show not ack
|
||||
view.textViewNotACK.setVisibility(View.VISIBLE);
|
||||
view.imageAck.setVisibility(View.VISIBLE);
|
||||
view.getTextViewNotACK().setVisibility(View.VISIBLE);
|
||||
view.getImageAck().setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 1:
|
||||
// show not ack
|
||||
view.textViewNotACK.setVisibility(View.INVISIBLE);
|
||||
view.imageAck.setVisibility(View.INVISIBLE);
|
||||
view.getTextViewNotACK().setVisibility(View.INVISIBLE);
|
||||
view.getImageAck().setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + (Boolean.TRUE.equals(ackPositions.get(position)) ? 1 : 0));
|
||||
}
|
||||
|
||||
switch(dispatcher_positions.get(position) ? 1 : 0) {
|
||||
switch (Boolean.TRUE.equals(dispatcherPositions.get(position)) ? 1 : 0) {
|
||||
case 1:
|
||||
view.layoutReceived.setVisibility(View.GONE);
|
||||
view.layoutSend.setVisibility(View.VISIBLE);
|
||||
view.getLayoutReceived().setVisibility(View.GONE);
|
||||
view.getLayoutSend().setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 0:
|
||||
view.layoutReceived.setVisibility(View.VISIBLE);
|
||||
view.layoutSend.setVisibility(View.GONE);
|
||||
view.getLayoutReceived().setVisibility(View.VISIBLE);
|
||||
view.getLayoutSend().setVisibility(View.GONE);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + (Boolean.TRUE.equals(dispatcherPositions.get(position)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
SM.Exception(ex.toString());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public void setACK(String seqID)
|
||||
{
|
||||
int position = -1, i=0;
|
||||
public void setACK(String seqID) {
|
||||
int position = -1;
|
||||
int i = 0;
|
||||
|
||||
for(Msg msg: listMessages)
|
||||
{
|
||||
if(msg.seqID.equals(seqID))
|
||||
for (Msg msg : listMessages) {
|
||||
if (msg.seqID.equals(seqID))
|
||||
position = i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if(position > -1 && position < ackPositions.size()) {
|
||||
if (position > -1 && position < ackPositions.size()) {
|
||||
ackPositions.remove(position);
|
||||
ackPositions.add(position, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeView(String seqID)
|
||||
{
|
||||
int position = -1, i=0;
|
||||
public void changeView(String seqID) {
|
||||
int position = -1;
|
||||
int i = 0;
|
||||
|
||||
for(Msg msg: listMessages)
|
||||
{
|
||||
if(msg.seqID.equals(seqID))
|
||||
for (Msg msg : listMessages) {
|
||||
if (msg.seqID.equals(seqID))
|
||||
position = i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if(position != -1 && hash.size() > position)
|
||||
{
|
||||
if (position != -1 && hash.size() > position) {
|
||||
SM.Debug("POSITON : " + position);
|
||||
View con = hash.get(position);
|
||||
ViewHolder view = (ViewHolder) con.getTag();
|
||||
ViewHolder view = null;
|
||||
if (con != null) {
|
||||
view = (ViewHolder) con.getTag();
|
||||
}
|
||||
|
||||
switch(ackPositions.get(position) ? 1 : 0)
|
||||
{
|
||||
switch (Boolean.TRUE.equals(ackPositions.get(position)) ? 1 : 0) {
|
||||
case 1:
|
||||
view.imageAck.setVisibility(View.INVISIBLE);
|
||||
view.textViewNotACK.setVisibility(View.INVISIBLE);
|
||||
if (view != null) {
|
||||
view.getImageAck().setVisibility(View.INVISIBLE);
|
||||
view.getTextViewNotACK().setVisibility(View.INVISIBLE);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
view.imageAck.setVisibility(View.VISIBLE);
|
||||
view.textViewNotACK.setVisibility(View.VISIBLE);
|
||||
if (view != null) {
|
||||
view.getImageAck().setVisibility(View.VISIBLE);
|
||||
view.getTextViewNotACK().setVisibility(View.VISIBLE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + (Boolean.TRUE.equals(ackPositions.get(position)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -18,15 +17,11 @@ import com.safemobile.lib.Msg;
|
||||
import com.safemobile.lib.R;
|
||||
import com.safemobile.lib.SM;
|
||||
|
||||
public class MessagesGridViewAdapter extends BaseAdapter
|
||||
{
|
||||
private ArrayList<Msg> listMessages;
|
||||
private Activity activity;
|
||||
//public String time;
|
||||
//private int[] colors = new int[] { Color.parseColor("#FFFFFF"), Color.parseColor("#D2E4FC") };
|
||||
public class MessagesGridViewAdapter extends BaseAdapter {
|
||||
private final ArrayList<Msg> listMessages;
|
||||
private final Activity activity;
|
||||
|
||||
|
||||
public MessagesGridViewAdapter(Activity activity, ArrayList<Msg> listMessages, Context context) {
|
||||
public MessagesGridViewAdapter(Activity activity, ArrayList<Msg> listMessages) {
|
||||
super();
|
||||
this.activity = activity;
|
||||
this.listMessages = listMessages;
|
||||
@ -47,8 +42,7 @@ public class MessagesGridViewAdapter extends BaseAdapter
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static class ViewHolder
|
||||
{
|
||||
public static class ViewHolder {
|
||||
public ImageView imgViewContact;
|
||||
public TextView txtViewContact;
|
||||
public TextView txtViewDateTime;
|
||||
@ -62,71 +56,44 @@ public class MessagesGridViewAdapter extends BaseAdapter
|
||||
ViewHolder view;
|
||||
LayoutInflater inflator = activity.getLayoutInflater();
|
||||
|
||||
if(convertView==null)
|
||||
{
|
||||
if (convertView == null) {
|
||||
view = new ViewHolder();
|
||||
convertView = inflator.inflate(R.layout.row_message, null);
|
||||
|
||||
view.imgViewContact = (ImageView) convertView.findViewById(R.id.imageViewContact);
|
||||
view.txtViewContact = (TextView) convertView.findViewById(R.id.textViewContact);
|
||||
view.txtViewDateTime = (TextView) convertView.findViewById(R.id.textViewLastDate);
|
||||
view.txtViewLastMsg = (TextView) convertView.findViewById(R.id.textViewLastMsg);
|
||||
view.layoutMessage = (LinearLayout) convertView.findViewById(R.id.layoutMessage);
|
||||
view.imgViewContact = convertView.findViewById(R.id.imageViewContact);
|
||||
view.txtViewContact = convertView.findViewById(R.id.textViewContact);
|
||||
view.txtViewDateTime = convertView.findViewById(R.id.textViewLastDate);
|
||||
view.txtViewLastMsg = convertView.findViewById(R.id.textViewLastMsg);
|
||||
view.layoutMessage = convertView.findViewById(R.id.layoutMessage);
|
||||
|
||||
convertView.setTag(view);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
view = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
view.imgViewContact.setImageResource(listMessages.get(position).from.getLargeIcon());
|
||||
//view.imgViewContact.setImageResource(R.drawable.peopleblue);
|
||||
view.txtViewContact.setText(listMessages.get(position).from.name+ " :");
|
||||
if(listMessages.get(position).message.length() > 25)
|
||||
view.txtViewLastMsg.setText(listMessages.get(position).message.substring(0, 25) + "...");
|
||||
view.txtViewContact.setText(String.format("%s :", listMessages.get(position).from.name));
|
||||
if (listMessages.get(position).message.length() > 25)
|
||||
view.txtViewLastMsg.setText(String.format("%s...", listMessages.get(position).message.substring(0, 25)));
|
||||
else
|
||||
view.txtViewLastMsg.setText(listMessages.get(position).message);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
if(listMessages.get(position).received.after(calendar.getTime()))
|
||||
if (listMessages.get(position).received.after(calendar.getTime()))
|
||||
sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
else
|
||||
sdf = new SimpleDateFormat("MMM-dd HH:mm");
|
||||
|
||||
view.txtViewDateTime.setText(sdf.format(listMessages.get(position).received));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
SM.Exception(ex.toString());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public int getIcon(int user_type, String username)
|
||||
{
|
||||
// if request was send by MessagesActivity -> Spinner
|
||||
if(user_type == -1)
|
||||
{
|
||||
// get unit_type for selected username
|
||||
for (Msg mes: listMessages)
|
||||
{
|
||||
// if user is selected
|
||||
if(mes.from.name.equals(username))
|
||||
{
|
||||
user_type = (int) mes.from.driver_id; // save user_type
|
||||
|
||||
return mes.from.getLargeIcon();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,215 +0,0 @@
|
||||
package com.safemobile.adapters;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.safemobile.lib.R;
|
||||
import com.safemobile.lib.SM;
|
||||
import com.safemobile.libpad.PadTextMessage;
|
||||
|
||||
public class PadConversationGridViewAdapter extends BaseAdapter
|
||||
{
|
||||
private ArrayList<PadTextMessage> listMessages;
|
||||
private Activity activity;
|
||||
//public String time;
|
||||
private ArrayList<Boolean> outgoingPositions = new ArrayList<Boolean>();
|
||||
private ArrayList<Boolean> ackPositions = new ArrayList<Boolean>();
|
||||
private Hashtable<Integer, View> hash = new Hashtable<Integer, View>();
|
||||
|
||||
|
||||
public PadConversationGridViewAdapter(Activity activity, ArrayList<PadTextMessage> listMessages, Context context, ArrayList<Boolean> outgoingPositions, ArrayList<Boolean> ackPositions) {
|
||||
this.activity = activity;
|
||||
this.listMessages = listMessages;
|
||||
this.outgoingPositions = outgoingPositions;
|
||||
this.ackPositions = ackPositions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return listMessages.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PadTextMessage getItem(int position) {
|
||||
return listMessages.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** return the list of messages in the adapter
|
||||
* @return an ArrayList of PadTextMessages
|
||||
*/
|
||||
public ArrayList<PadTextMessage> getMessages() {
|
||||
return listMessages;
|
||||
}
|
||||
|
||||
public static class ViewHolder
|
||||
{
|
||||
public ImageView imgViewContact;
|
||||
public TextView txtViewMsg;
|
||||
public TextView txtViewDateTime;
|
||||
public ImageView imgViewReceivedContact;
|
||||
public TextView txtViewReceivedMsg;
|
||||
public TextView txtViewReceivedDateTime;
|
||||
public ImageView imageAck;
|
||||
public TextView textViewNotACK;
|
||||
public LinearLayout layoutSend;
|
||||
public LinearLayout layoutReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder view;
|
||||
LayoutInflater inflator = activity.getLayoutInflater();
|
||||
|
||||
if(convertView==null)
|
||||
{
|
||||
view = new ViewHolder();
|
||||
convertView = inflator.inflate(R.layout.row_conversation, null);
|
||||
|
||||
view.imgViewContact = (ImageView) convertView.findViewById(R.id.imageViewSenderIco);
|
||||
view.txtViewMsg = (TextView) convertView.findViewById(R.id.textViewSendMsg);
|
||||
view.txtViewDateTime = (TextView) convertView.findViewById(R.id.textViewSendDate);
|
||||
view.imgViewReceivedContact = (ImageView) convertView.findViewById(R.id.imageViewReceivedIco);
|
||||
view.txtViewReceivedMsg = (TextView) convertView.findViewById(R.id.textViewReceivedMsg);
|
||||
view.txtViewReceivedDateTime = (TextView) convertView.findViewById(R.id.textViewReceivedDate);
|
||||
view.layoutSend = (LinearLayout) convertView.findViewById(R.id.layoutSend);
|
||||
view.layoutReceived = (LinearLayout) convertView.findViewById(R.id.layoutReceived);
|
||||
view.textViewNotACK = (TextView) convertView.findViewById(R.id.textViewNotACKSendMsg);
|
||||
view.imageAck = (ImageView) convertView.findViewById(R.id.imageAck);
|
||||
|
||||
convertView.setTag(view);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
try
|
||||
{
|
||||
hash.put(position, convertView);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm MMM-dd", Locale.getDefault());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
Date date = new Date(listMessages.get(position).timeGMT * 1000);
|
||||
|
||||
if(date.after(calendar.getTime()))
|
||||
sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
else
|
||||
sdf = new SimpleDateFormat("HH:mm MMM-dd", Locale.getDefault());
|
||||
|
||||
// set gmt time
|
||||
//sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
||||
//view.imgViewContact.setImageResource(getIcon(listMessages.get(position).from.user_type));
|
||||
view.imgViewContact.setImageResource(R.drawable.peoplegreen_large);
|
||||
view.txtViewMsg.setText(listMessages.get(position).message);
|
||||
view.txtViewDateTime.setText(sdf.format(date));
|
||||
//view.imgViewReceivedContact.setImageResource(getIcon(listMessages.get(position).from.user_type));
|
||||
view.imgViewReceivedContact.setImageResource(R.drawable.peopleblue_large);
|
||||
view.txtViewReceivedMsg.setText(listMessages.get(position).message);
|
||||
|
||||
view.txtViewReceivedDateTime.setText(sdf.format(date));
|
||||
|
||||
if(ackPositions.size() > 0)
|
||||
switch(ackPositions.get(position) ? 1: 0) {
|
||||
case 0:
|
||||
// show not ack
|
||||
view.textViewNotACK.setVisibility(View.VISIBLE);
|
||||
view.imageAck.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 1:
|
||||
// show not ack
|
||||
view.textViewNotACK.setVisibility(View.INVISIBLE);
|
||||
view.imageAck.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
switch(outgoingPositions.get(position) ? 1 : 0) {
|
||||
case 1:
|
||||
view.layoutReceived.setVisibility(View.GONE);
|
||||
view.layoutSend.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 0:
|
||||
view.layoutReceived.setVisibility(View.VISIBLE);
|
||||
view.layoutSend.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
SM.Exception(ex.toString());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setACK(String seqID)
|
||||
{
|
||||
int position = -1, i=0;
|
||||
|
||||
for(Msg msg: listMessages)
|
||||
{
|
||||
if(msg.seqID.equals(seqID))
|
||||
position = i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
ackPositions.remove(position);
|
||||
ackPositions.add(position, true);
|
||||
}
|
||||
|
||||
public void changeView(String seqID)
|
||||
{
|
||||
int position = -1, i=0;
|
||||
|
||||
for(Msg msg: listMessages)
|
||||
{
|
||||
if(msg.seqID.equals(seqID))
|
||||
position = i;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if(position != -1 && hash.size() > position)
|
||||
{
|
||||
SM.Debug("POSITON : " + position);
|
||||
View con = hash.get(position);
|
||||
ViewHolder view = (ViewHolder) con.getTag();
|
||||
|
||||
switch(ackPositions.get(position) ? 1 : 0)
|
||||
{
|
||||
case 1:
|
||||
view.imageAck.setVisibility(View.INVISIBLE);
|
||||
view.textViewNotACK.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
case 0:
|
||||
view.imageAck.setVisibility(View.VISIBLE);
|
||||
view.textViewNotACK.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
@ -53,7 +54,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/imageAckSendMsg"
|
||||
android:id="@+id/imageAck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
@ -61,16 +62,18 @@
|
||||
android:paddingTop="2dp"
|
||||
android:src="@drawable/exclamation_small"
|
||||
android:layout_weight="0"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="invisible"
|
||||
tools:ignore="DuplicateIds" />
|
||||
<TextView
|
||||
android:id="@+id/textViewNotACKSendMsg"
|
||||
android:id="@+id/textViewNotACK"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/notAck"
|
||||
android:textColor="#000000"
|
||||
android:textSize="13dp"
|
||||
android:layout_toRightOf="@+id/imageAck"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="invisible"
|
||||
tools:ignore="DuplicateIds" />
|
||||
<TextView
|
||||
android:id="@+id/textViewSendDate"
|
||||
android:layout_width="wrap_content"
|
||||
@ -113,7 +116,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/imageAckReceiveMsg"
|
||||
android:id="@+id/imageAck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
@ -121,16 +124,18 @@
|
||||
android:paddingTop="2dp"
|
||||
android:src="@drawable/exclamation_small"
|
||||
android:layout_weight="0"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="invisible"
|
||||
tools:ignore="DuplicateIds" />
|
||||
<TextView
|
||||
android:id="@+id/textViewNotACKReceiveMsg"
|
||||
android:id="@+id/textViewNotACK"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/notAck"
|
||||
android:textColor="#000000"
|
||||
android:textSize="13dp"
|
||||
android:layout_toRightOf="@+id/imageAck"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="invisible"
|
||||
tools:ignore="DuplicateIds" />
|
||||
<TextView
|
||||
android:id="@+id/textViewReceivedDate"
|
||||
android:layout_width="wrap_content"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -405,7 +405,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
tabHost.setCurrentTabByTag("Text");
|
||||
AppParams.crtTab = AppParams.Tabs.message;
|
||||
|
||||
if (AppParams.DEMO && messageActivity.allVehicle.size()== 0) {
|
||||
if (AppParams.DEMO && messageActivity.getAllVehicle().size()== 0) {
|
||||
// select button
|
||||
buttonText.setSelected(true);
|
||||
// deselect other buttons
|
||||
@ -419,9 +419,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
tabHost.setCurrentTabByTag("Text");
|
||||
AppParams.crtTab = AppParams.Tabs.message;
|
||||
|
||||
if (AppParams.DEMO && messageActivity.allVehicle.size()== 0) {
|
||||
messageActivity.UpdateVehs(getAllVehicle());
|
||||
messageActivity.UpdateSMS(listSMS);
|
||||
if (AppParams.DEMO && messageActivity.getAllVehicle().size()== 0) {
|
||||
messageActivity.updateVehicles(getAllVehicle());
|
||||
messageActivity.updateSMS(listSMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -674,8 +674,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
//list for SMS
|
||||
if(currentActivity instanceof MessagesActivity)
|
||||
{
|
||||
// run update showSMS4unit(int sc_id) form MessageActivity
|
||||
((MessagesActivity)currentActivity).showSMS4unit(getVehicle4Imei(imei).sc_id);
|
||||
// run update showSMS4unit(int scId) form MessageActivity
|
||||
((MessagesActivity)currentActivity).showSMS4unit(getVehicle4Imei(imei).scId);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -821,9 +821,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
tabHost.setCurrentTabByTag("Text");
|
||||
AppParams.crtTab = AppParams.Tabs.message;
|
||||
|
||||
messageActivity.sc_id = getVehicle4Imei(getImei()).sc_id;
|
||||
messageActivity.setScId(getVehicle4Imei(getImei()).sc_id);
|
||||
messageActivity.LASTMESSAGES = false;
|
||||
messageActivity.GetLastSMS();
|
||||
messageActivity.getLastSMS();
|
||||
|
||||
// disable notification
|
||||
if(mNotificationManager!=null)
|
||||
@ -1019,7 +1019,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
if(radioActivity!=null)
|
||||
radioActivity.onCreate(radioActivity.savedInstanceState);
|
||||
if(messageActivity!=null)
|
||||
messageActivity.onCreate(messageActivity.savedInstanceState);
|
||||
messageActivity.onCreate(messageActivity.getSavedInstanceState());
|
||||
if(recordingsActivity!=null)
|
||||
recordingsActivity.onCreate(recordingsActivity.savedInstanceState);
|
||||
if(alarmActivity!=null)
|
||||
@ -1319,9 +1319,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
//list for SMS
|
||||
if(AppParams.crtTab == AppParams.Tabs.message)
|
||||
{
|
||||
//SM.Debug("currentActivity instanceof MessagesActivity - NewSMS");
|
||||
//SM.Debug("currentActivity instanceof MessagesActivity - newSMS");
|
||||
if(messageActivity != null)
|
||||
messageActivity.UpdateSMS(sms.smsList);
|
||||
messageActivity.updateSMS(sms.smsList);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@ -1370,7 +1370,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
{
|
||||
SM.Debug("currentActivity instanceof MessagesActivity");
|
||||
if(messageActivity != null)
|
||||
messageActivity.UpdateVehs(vMSG.vehList);
|
||||
messageActivity.updateVehicles(vMSG.vehList);
|
||||
}
|
||||
setAllVehicle(vMSG.vehList);
|
||||
}
|
||||
@ -1387,7 +1387,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
{
|
||||
//SM.Debug("currentActivity instanceof MessagesActivity");
|
||||
if(messageActivity != null)
|
||||
messageActivity.UpdateSMS(sms.smsList);
|
||||
messageActivity.updateSMS(sms.smsList);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1433,7 +1433,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
SM.Debug("Got smsComfirm msg.data:" + msg.data);
|
||||
|
||||
if (messageActivity != null)
|
||||
messageActivity.ConfirmSMS(sms.data, msg.seqID);
|
||||
messageActivity.confirmSMS(sms.data, msg.seqID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1466,8 +1466,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
});
|
||||
//list for SMS
|
||||
if(AppParams.crtTab == AppParams.Tabs.message && messageActivity!= null) {
|
||||
SM.Debug("currentActivity instanceof MessagesActivity - NewSMS | " + tempArr[0] + " | " + tempArr[1]);
|
||||
messageActivity.NewSMS(tempArr[0], tempArr[1], time);
|
||||
SM.Debug("currentActivity instanceof MessagesActivity - newSMS | " + tempArr[0] + " | " + tempArr[1]);
|
||||
messageActivity.newSMS(tempArr[0], tempArr[1], time);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1858,7 +1858,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
//list for SMS
|
||||
if(AppParams.crtTab == AppParams.Tabs.alarms)
|
||||
{
|
||||
SM.Debug("currentActivity instanceof AlarmActivity - NewSMS | " + tempArr[0] + " | " + tempArr[1]);
|
||||
SM.Debug("currentActivity instanceof AlarmActivity - newSMS | " + tempArr[0] + " | " + tempArr[1]);
|
||||
getAlarms(AppParams.USERID);
|
||||
}
|
||||
// if tab is not TextTab
|
||||
@ -2315,19 +2315,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
}
|
||||
|
||||
public void optionForUnit(int radioCode, int opCode, int sc_id, int value)
|
||||
public void optionForUnit(int radioCode, int opCode, int scId, int value)
|
||||
{
|
||||
boolean res = tcp.Write("0.0", "#"+radioCode+"#"+opCode+"#" + sc_id+"#" +value + "#");
|
||||
boolean res = tcp.Write("0.0", "#"+radioCode+"#"+opCode+"#" + scId+"#" +value + "#");
|
||||
if(res){
|
||||
SM.Debug("Message (optionForUnit) sent to app server radioCode:"+radioCode+ " opCode:"+opCode+ " sc_id:"+sc_id+ " value:"+value);
|
||||
SM.Debug("Message (optionForUnit) sent to app server radioCode:"+radioCode+ " opCode:"+opCode+ " scId:"+scId+ " value:"+value);
|
||||
}else{
|
||||
SM.Debug("Could not send message(optionForUnit)!!");
|
||||
}
|
||||
}
|
||||
|
||||
public void getSMS4unit(int sc_id, long timeGMT)
|
||||
public void getSMS4unit(int scId, long timeGMT)
|
||||
{
|
||||
boolean res = tcp.Write("0.0", "#22#"+sc_id+"#" +timeGMT+"#");
|
||||
boolean res = tcp.Write("0.0", "#22#"+scId+"#" +timeGMT+"#");
|
||||
if(res){
|
||||
SM.Debug("Message (getLastSMS) sent to app server");
|
||||
}else{
|
||||
@ -2345,11 +2345,11 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
}
|
||||
|
||||
public void SendSMS(String seqID,int sc_id, String txt)
|
||||
public void SendSMS(String seqID,int scId, String txt)
|
||||
{
|
||||
boolean res = tcp.Write(seqID, "#24#" + AppParams.USERID + "#" + sc_id + "#" + txt + "#");
|
||||
boolean res = tcp.Write(seqID, "#24#" + AppParams.USERID + "#" + scId + "#" + txt + "#");
|
||||
if(res){
|
||||
SM.Debug("Message (SendSMS) sent to app server sc_id:"+sc_id+ " txt:"+txt);
|
||||
SM.Debug("Message (SendSMS) sent to app server scId:"+scId+ " txt:"+txt);
|
||||
}else{
|
||||
SM.Debug("Could not send message(getLastSMS)!!");
|
||||
}
|
||||
@ -2385,10 +2385,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
}
|
||||
|
||||
public void getHistoryPos(int sc_id, long timeGMTStart, long timeGMTStop)
|
||||
public void getHistoryPos(int scId, long timeGMTStart, long timeGMTStop)
|
||||
{
|
||||
HistSeqID = "1."+Integer.toString((int) (System.currentTimeMillis() / 1000L));
|
||||
boolean res = tcp.Write(HistSeqID,"#26#"+sc_id+"#"+timeGMTStart+"#"+timeGMTStop+"#");
|
||||
boolean res = tcp.Write(HistSeqID,"#26#"+scId+"#"+timeGMTStart+"#"+timeGMTStop+"#");
|
||||
if(res){
|
||||
SM.Debug("Message (getHistoryPos) sent to app server");
|
||||
}else{
|
||||
|
@ -188,7 +188,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent">
|
||||
<TextView
|
||||
android:id="@+id/textViewSendMsg"
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
@ -210,7 +210,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:inputType="text" >
|
||||
android:inputType="text"
|
||||
android:autofillHints="">
|
||||
</EditText>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -186,7 +186,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent">
|
||||
<TextView
|
||||
android:id="@+id/textViewSendMsg"
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
@ -209,7 +209,8 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:inputType="text"
|
||||
android:maxLength="255" >
|
||||
android:maxLength="255"
|
||||
android:autofillHints="">
|
||||
</EditText>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
Loading…
Reference in New Issue
Block a user