Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMSDelivery View changed to Dialog And Contact Picker implemented #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=Google Inc.:Google APIs:4
target=Google Inc.:Google APIs:8
81 changes: 81 additions & 0 deletions res/layout/sms_delivery_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="70sp" >

<com.sahana.geosmser.widget.AutoCompleteSMSTextView
android:id="@+id/AutoEditTextSMSPhoneNumber"
android:maxLines="1"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/geosms_delivery_message_receiver_hint" />
<Button android:id="@+id/contact"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact"
android:layout_alignRight="@+id/AutoEditTextSMSPhoneNumber"
android:gravity="center"
/>
</RelativeLayout>

<TableLayout android:id="@+id/TableLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/RelativeLayout01"
android:shrinkColumns="0"
android:stretchColumns="0">
<TableRow android:id="@+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<RelativeLayout android:id="@+id/RelativeLayout02"
android:background="@android:drawable/edit_text"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:addStatesFromChildren="true"
android:layout_width="0dip">

<EditText
android:maxLines="4"
android:inputType="textMultiLine"
android:id="@+id/EditTextSMSMessage"
android:autoText="true"
android:capitalize="sentences"
android:background="@null"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/geosms_delivery_message_body_hint"
android:minLines="2"
android:textColor="#000000"
android:gravity="top"></EditText>
<TextView
android:id="@+id/TextViewSMSMessageCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#88000000"
android:textColor="#ffffffff"
android:textSize="11sp"
android:textStyle="bold"
android:paddingLeft="3dip"
android:paddingRight="3dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:visibility="gone"/>
</RelativeLayout>
<Button android:layout_width="wrap_content"
android:text="@string/geosms_delivery_message_send_button"
android:id="@+id/ButtonSMSSend"
android:layout_height="fill_parent"
android:layout_gravity="top"></Button>
</TableRow>
</TableLayout>

</RelativeLayout>

34 changes: 21 additions & 13 deletions src/com/sahana/geosmser/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.sahana.geosmser.gps.MyLocation;
import com.sahana.geosmser.gps.MyLocation.ProvideType;
import com.sahana.geosmser.view.ReverseGeocoderView;
import com.sahana.geosmser.view.SMSDeliveryView;
import com.sahana.geosmser.view.SMSDeliveryView.HanMessageSentDialogPack;
import com.sahana.geosmser.view.SMSDeliveryDialog;
import com.sahana.geosmser.view.SMSDeliveryDialog.HanMessageSentDialogPack;

import android.app.Activity;
import android.app.AlertDialog;
Expand All @@ -41,6 +41,9 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand All @@ -53,7 +56,7 @@
import android.widget.LinearLayout;
import android.widget.Toast;

public class Dashboard extends Activity {
public class Dashboard extends FragmentActivity {

private LinearLayout layoutIncidentReport;
private LinearLayout layoutTaskDispatch;
Expand Down Expand Up @@ -85,7 +88,7 @@ public class Dashboard extends Activity {
private HanMessageSentDialogPack hanMessageSentDialogPack;
private HanSMSDeliveryDialog mHanSMSDeliveryDialog;
private ReverseGeocoderView mReverseGeocoderView;
private SMSDeliveryView mSMSDeliveryView;
private SMSDeliveryDialog mSMSDeliveryView;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -182,13 +185,17 @@ public void onClick(View v) {


mReverseGeocoderView = new ReverseGeocoderView(this);
mSMSDeliveryView = (SMSDeliveryView) layoutInflaterFactory.inflate(R.layout.sms_delivery_view, null);
mSMSDeliveryView = new SMSDeliveryDialog(getApplicationContext());
evtDialogDisableKeyBack = new DialogEvtDisableKeyBackOnKeyListener();
hanMessageSentDialogPack = new HanMessageSentDialogPack();
mHanSMSDeliveryDialog = new HanSMSDeliveryDialog();
mSMSDeliveryView.registerSMSSendDeliveryReceiver();

/* not needed now as sent through SMSDeliveryDialog Constructor
mSMSDeliveryView.setOnSourceBindingListener(new SMSDVEvtOnSourceBindingListene());
mSMSDeliveryView.setMessageSentHandler(mHanSMSDeliveryDialog);
*/

}

//==================================================================
Expand All @@ -214,13 +221,14 @@ public void onClick(DialogInterface dialog, int arg1) {
return mReverseGeocoder;

case DIALOG_SMS_DELIVERY:
//LayoutInflater factory = LayoutInflater.from(this);
//final View textEntryView = factory.inflate(R.layout.sms_delivery_view, null);
return new AlertDialog.Builder(this)
.setTitle(R.string.dialog_sahana_incident_delivery_title)
.setView(mSMSDeliveryView)
.setOnKeyListener(new DialogEvtDisableSMSDeliveryDialogKeyBackOnKeyListener())
.create();
/*
* mHanSMSDelivery and SMSDVEvtOnSourceBindingListene are initialized
* when an SMSDeliveryDialog is launched or opened
*/
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
DialogFragment dialogFragment = new SMSDeliveryDialog(getApplicationContext(),new SMSDVEvtOnSourceBindingListene(),mHanSMSDeliveryDialog);
dialogFragment.show(ft, "openDialog");
break;
case DIALOG_SMS_DELIVERY_MESSAGESENDING:

case DIALOG_SMS_DELIVERY_MESSAGESENT:
Expand Down Expand Up @@ -287,7 +295,7 @@ protected void onPrepareDialog(int id, Dialog pDialog) {
super.onPrepareDialog(id, pDialog);
}

private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryView.ISMSDeliveryRenderer.OnSourceBindingListener {
private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryDialog.ISMSDeliveryRenderer.OnSourceBindingListener {
@Override
public void onSourceBind(GeoSMSPack pack) {
GeoSMSPack p = getCurrentSelectedGeoSMSPackForSMSDelivery();
Expand Down
31 changes: 19 additions & 12 deletions src/com/sahana/geosmser/TeamCommunication.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.telephony.SmsManager;
import android.util.AttributeSet;
import android.util.Log;
Expand All @@ -52,9 +55,9 @@
import com.sahana.geosmser.gps.MyLocation;
import com.sahana.geosmser.gps.MyLocation.ProvideType;
import com.sahana.geosmser.view.*;
import com.sahana.geosmser.view.SMSDeliveryView.HanMessageSentDialogPack;
import com.sahana.geosmser.view.SMSDeliveryDialog.HanMessageSentDialogPack;

public class TeamCommunication extends Activity{
public class TeamCommunication extends FragmentActivity{

private static final int DIALOG_REVERSE_GEOCODER = 100;

Expand All @@ -66,7 +69,7 @@ public class TeamCommunication extends Activity{
private TextView mTextWhereAreWeTitle, mTextWhereAmITitle, mTextWhereAreYouTitle;
private LinearLayout mLayoutWhereAreWe, mLayoutWhereAmI, mLayoutWhereAreYou;

private SMSDeliveryView mSMSDeliveryView;
private SMSDeliveryDialog mSMSDeliveryView;
private SMSQueryView mSMSQueryView;

private HanMessageSentDialogPack hanMessageSentDialogPack;
Expand Down Expand Up @@ -175,19 +178,22 @@ public void initialEvent() {

mReverseGeocoderView = new ReverseGeocoderView(this);

mSMSDeliveryView = (SMSDeliveryView) layoutInflaterFactory.inflate(R.layout.sms_delivery_view, null);
mSMSDeliveryView = new SMSDeliveryDialog(getApplicationContext());
evtDialogDisableKeyBack = new DialogEvtDisableKeyBackOnKeyListener();
hanMessageSentDialogPack = new HanMessageSentDialogPack();
mHanSMSDeliveryDialog = new HanSMSDeliveryDialog();
mSMSDeliveryView.registerSMSSendDeliveryReceiver();

/* not needed now as sent through SMSDeliveryDialog Constructor
mSMSDeliveryView.setOnSourceBindingListener(new SMSDVEvtOnSourceBindingListene());
mSMSDeliveryView.setMessageSentHandler(mHanSMSDeliveryDialog);
*/

mSMSQueryView.setMessageSentHandler(mHanSMSQueryDialog);
mSMSQueryView.smsWriter.open();
}

private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryView.ISMSDeliveryRenderer.OnSourceBindingListener {
private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryDialog.ISMSDeliveryRenderer.OnSourceBindingListener {
@Override
public void onSourceBind(GeoSMSPack pack) {
GeoSMSPack p = getCurrentSelectedGeoSMSPackForSMSDelivery();
Expand Down Expand Up @@ -255,13 +261,14 @@ public void onClick(DialogInterface dialog, int arg1) {
return mReverseGeocoder;

case WhereToMeet.DIALOG_SMS_DELIVERY:
//LayoutInflater factory = LayoutInflater.from(this);
//final View textEntryView = factory.inflate(R.layout.sms_delivery_view, null);
return new AlertDialog.Builder(this)
.setTitle(R.string.dialog_geosms_mylocation_delivery_title)
.setView(mSMSDeliveryView)
.setOnKeyListener(new DialogEvtDisableSMSDeliveryDialogKeyBackOnKeyListener())
.create();
/*
* mHanSMSDelivery and SMSDVEvtOnSourceBindingListene are initialized
* when an SMSDeliveryDialog is launched or opened
*/
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
DialogFragment dialogFragment = new SMSDeliveryDialog(getApplicationContext(),new SMSDVEvtOnSourceBindingListene(),mHanSMSDeliveryDialog);
dialogFragment.show(ft, "openDialog");
break;
case WhereToMeet.DIALOG_SMS_DELIVERY_MESSAGESENDING:

case WhereToMeet.DIALOG_SMS_DELIVERY_MESSAGESENT:
Expand Down
51 changes: 35 additions & 16 deletions src/com/sahana/geosmser/WhereToMeet.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import com.sahana.geosmser.overlay.IDel.IGeoSMSPackBinder;
import com.sahana.geosmser.overlay.IDel.IMenuEvtOverlayLocation;
import com.sahana.geosmser.view.GeoSMSInformationPanel;
import com.sahana.geosmser.view.SMSDeliveryView;
import com.sahana.geosmser.view.SMSDeliveryDialog;
import com.sahana.geosmser.view.SMSQueryView;
import com.sahana.geosmser.view.SMSDeliveryView.HanMessageSentDialogPack;
import com.sahana.geosmser.view.SMSDeliveryDialog.HanMessageSentDialogPack;

import android.app.Activity;
import android.app.AlertDialog;
Expand All @@ -56,6 +56,9 @@
import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -106,7 +109,7 @@ public class WhereToMeet extends MapActivity {
private GeoSMSServiceController geosmsServiceController;

private LayoutInflater layoutInflaterFactory;
private SMSDeliveryView mSMSDeliveryView;
private SMSDeliveryDialog mSMSDeliveryView;
private GeoSMSPack curSelectedGeoSMSPackForSMSDelivery;

private SMSQueryView mSMSQueryView;
Expand Down Expand Up @@ -299,13 +302,9 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
protected Dialog onCreateDialog(int id) {
switch(id) {
case DIALOG_SMS_DELIVERY:
//LayoutInflater factory = LayoutInflater.from(this);
//final View textEntryView = factory.inflate(R.layout.sms_delivery_view, null);
return new AlertDialog.Builder(me)
.setTitle(R.string.dialog_geosms_delivery_title)
.setView(mSMSDeliveryView)
.setOnKeyListener(new DialogEvtDisableSMSDeliveryDialogKeyBackOnKeyListener())
.create();
SMSDelivery sDelivery = (SMSDelivery) new FragmentActivity();
sDelivery.showDialog();
break;
case DIALOG_SMS_DELIVERY_MESSAGESENDING:
case DIALOG_SMS_QUERY_MESSAGESENDING:
pdSMSDVMessageSending = new ProgressDialog(me);
Expand Down Expand Up @@ -445,7 +444,7 @@ private void init() {
geosmsServiceController = new GeoSMSServiceController();

layoutInflaterFactory = LayoutInflater.from(this);
mSMSDeliveryView = (SMSDeliveryView) layoutInflaterFactory.inflate(R.layout.sms_delivery_view, null);
mSMSDeliveryView = new SMSDeliveryDialog(getApplicationContext());

evtDialogDisableKeyBack = new DialogEvtDisableKeyBackOnKeyListener();
hanMessageSentDialogPack = new HanMessageSentDialogPack();
Expand All @@ -465,9 +464,11 @@ private void initEvents() {
fingerLocationController.bindMapView(mainMap);

mSMSDeliveryView.registerSMSSendDeliveryReceiver();
mSMSDeliveryView.setOnSourceBindingListener(new SMSDVEvtOnSourceBindingListene());
mSMSDeliveryView.setMessageSentHandler(mHanSMSDeliveryDialog);

/* not needed now as sent through SMSDeliveryDialog Constructor
mSMSDeliveryView.setOnSourceBindingListener(new SMSDVEvtOnSourceBindingListene());
mSMSDeliveryView.setMessageSentHandler(mHanSMSDeliveryDialog);
*/

mSMSQueryView.setMessageSentHandler(mHanSMSQueryDialog);
mSMSQueryView.smsWriter.open();
}
Expand Down Expand Up @@ -1123,7 +1124,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
}


private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryView.ISMSDeliveryRenderer.OnSourceBindingListener {
private class SMSDVEvtOnSourceBindingListene implements SMSDeliveryDialog.ISMSDeliveryRenderer.OnSourceBindingListener {
@Override
public void onSourceBind(GeoSMSPack pack) {
GeoSMSPack p = getCurrentSelectedGeoSMSPackForSMSDelivery();
Expand All @@ -1139,7 +1140,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
me.dismissDialog(DIALOG_SMS_DELIVERY);
if(!mSMSDeliveryView.getMessageFieldText().trim().equals("")
|| !mSMSDeliveryView.getPhoneFieldText().trim().equals("")
|| !mSMSDeliveryView.getReverseCodeFieldText().trim().equals("")
// || !mSMSDeliveryView.getReverseCodeFieldText().trim().equals("")
) {
me.showDialog(DIALOG_SMS_DELIVERY_EXIT_SMS_CONFORM);
}
Expand Down Expand Up @@ -1309,5 +1310,23 @@ public int describeContents() {
return 0;
}
}

/*
* Cannot instantiate fragment inside MapActivty so created external
* class extending Fragment and open the SMSDeliveryDialog from there
*/

private class SMSDelivery extends FragmentActivity{

public void showDialog(){
/*
* mHanSMSDelivery and SMSDVEvtOnSourceBindingListene are initialized
* when an SMSDeliveryDialog is launched or opened
*/
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
DialogFragment dialogFragment = new SMSDeliveryDialog(getApplicationContext(),new SMSDVEvtOnSourceBindingListene(),mHanSMSDeliveryDialog);
dialogFragment.show(ft, "openDialog");
}
}

}
Loading