package com.autochime.autochimeapplication;

import android.os.Build;
import android.telephony.SmsManager;

/**
 * Created by tianaim on 8/27/16.
 */
public class SMSManager {
    SmsManager smsManager = null;

    private String dummyPhoneNo = null;
    private String dummyPhoneNo2 = null;
    private String dummyMessageBody = null;

    public SMSManager() {
        smsManager = SmsManager.getDefault();

        dummyPhoneNo = "5554"; // first emulator
        dummyPhoneNo2 = "5556"; // second emulator
        dummyMessageBody = "Your friend Kelly may be in danger -  listen to this recording from her phone. https://rec.autochime.com/c3a564b6. If you think she is in danger....";
    }

    public void sendHardcode() {
        if (Build.VERSION.SDK_INT < 23) {
            try {
                smsManager.sendTextMessage(dummyPhoneNo, null, dummyMessageBody, null, null);
                smsManager.sendTextMessage(dummyPhoneNo2, null, dummyMessageBody, null, null); // send to both just in case the emulators get mixed up during demos
            } catch (Exception e) {
                e.printStackTrace();
            }
       }
    }

    public void send(String userName, String phoneNo, String messageBody) {
        if (Build.VERSION.SDK_INT < 23) {
            try {
                SmsManager smsManager = SmsManager.getDefault();
                smsManager.sendTextMessage(phoneNo, null, messageBody + " " + userName, null, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

@@ -101,16 +101,45 @@
 nager;%0A%0A
+import java.util.ArrayList;%0A%0A
 /**%0A * C
@@ -704,19 +704,92 @@
 n danger
-...
+, click here to send her help. If you think she is fine, ignore this message
 .%22;%0A    
@@ -891,32 +891,58 @@
 %0A               
+ ArrayList%3CString%3E parts =
  smsManager.send
@@ -933,32 +933,30 @@
  smsManager.
-sendText
+divide
 Message(dumm
@@ -960,51 +960,19 @@
 ummy
-PhoneNo, null, dummyMessageBody, null, null
+MessageBody
 );%0A 
@@ -993,32 +993,41 @@
  smsManager.send
+Multipart
 TextMessage(dumm
@@ -1038,17 +1038,16 @@
 neNo
-2
 , null, 
 dumm
@@ -1046,107 +1046,120 @@
 ll, 
-dummyMessageBody, null, null); // send to both just in case the emulators get mixed up during demos
+parts, null, null);%0A                smsManager.sendMultipartTextMessage(dummyPhoneNo2, null, parts, null, null);
 %0A   

handle longer texts