//TODO: make texts scroll-able //display the sender (inbox)/recipient (output), date time, and content of message void SetViewToTextMessage(TextMessage txt) { //update the json file that this text has been read if (!txt.HasBeenRead()) { Debug.Log ("-\n-\n"); JSONArray array = (JSONArray)savedTexts["texts"]; for (int i = 0; i < array.Count; i++) { //setting to strings, because otherwise a "==" comparision always returns false, even when it should return true string sender = array[i]["sender"]; string timestamp = array[i]["timestamp"]; string message = array[i]["message"]; if (sender == txt.GetSender() && timestamp == (""+txt.GetTimestamp()) && message == txt.GetMessage()) { array[i]["isRead"] = "True"; break; } } savedTexts["texts"] = array; SaveJson(); txt.SetHasBeenRead(true); } //need to check for unread texts here, in case the user presses the "red" button, to go back to the main menu. //this would bypass going back to the lists of texts which previously checked for unread texts if (ps.hasUnreadTexts && collectionType == CollectionType.Inbox) { bool newHasUnreadTexts = false; for (int i = 0; i < textsLength; i++) { if (!texts[i].HasBeenRead()) { newHasUnreadTexts = true; break; } } ps.hasUnreadTexts = newHasUnreadTexts; } ps.HandleHasUnreadMessages (); PhoneState.SetState(PhoneState.State.TextMessageDisplay); string str = ""; if (collectionType == CollectionType.Inbox) { //PhoneState.SetState(PhoneState.State.TextMessageInboxDisplay); string senderNumber = txt.GetSender(); str = "From: " + GetContactFromNumber(senderNumber, txt.IsTraceable()) + "\n"; } else { //PhoneState.SetState(PhoneState.State.TextMessageOutboxDisplay); string recipNumber = txt.GetRecipient(); str = "To: " + GetContactFromNumber(recipNumber, true) + "\n"; } str += "Time: " + GetDateTimeFromTimestamp(txt.GetTimestamp()) +"\n"; str += txt.GetMessage (); cs.SetScreenText(str); cs.SetHeadingText("Message"); cs.SetNavLeftText ("Back"); cs.SetNavRightText ("Options"); }