Пример #1
0
        public override MessageToSend getOutputScreenMessage(
            UserSession us,
            MenuPage mp,
            MessageToSend ms,
            InputHandlerResult ihr)
        {
            ms.Append(MessageBuilder.Elements.CreateClearScreen());
            if (!mp.GetType().FullName.Equals("MxitTestApp.OptionMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            OptionMenuPage omp = (OptionMenuPage)mp;
            ms.Append(omp.title + "\r\n", TextMarkup.Bold);
            if (ihr.action == InputHandlerResult.INVALID_MENU_ACTION
                && ihr.error != null)
            {
                ms.Append((string)ihr.error + "\r\n");
            }
            else
            {
                ms.Append(parseMessage(us, omp.message) + "\r\n");
            }
            List<MenuOptionItem> options = omp.options;
            int count =1 ;
            foreach (MenuOptionItem option in options)
            {
                ms.Append(createMessageLink(MENU_LINK_NAME, count + ") ", option.link_val));
                ms.Append(option.display_text + "\r\n");
                count++;
            }
            appendBackMainLinks(us,  ms);
            appendMessageConfig(true, ms);
            return ms;
            //return output;
        }
        //in here we should rather call a this method and from here call the implemented output screen
        //message method so that we can do common things in here. anyway too late now.
        public override MessageToSend getOutputScreenMessage(
            UserSession us,
            MenuPage mp,
            MessageToSend ms,
            InputHandlerResult ihr)
        {
            ms.Append(MessageBuilder.Elements.CreateClearScreen());
            if (!mp.GetType().FullName.Equals("MxitTestApp.DynMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            DynMenuPage dmp = (DynMenuPage)mp;
            ms.Append(dmp.title + "\r\n", TextMarkup.Bold);
            if (ihr.action == InputHandlerResult.CONF_PAGE_ACTION
                 && ihr.message != null)
            {
                ms.Append(ihr.message + "\r\n");
                ms.Append(createMessageLink(MENU_LINK_NAME, "Y", "Yes"));
                ms.Append(" | ");
                ms.Append(createMessageLink(MENU_LINK_NAME, "N", "No"));
            }
            else
            {
                if (ihr.action == InputHandlerResult.INVALID_MENU_ACTION
                && ihr.error != null)
                {
                    ms.Append((string)ihr.error + "\r\n");
                }
                else
                {
                    ms.Append(parseMessage(us, dmp.message) + "\r\n");
                }
                /*List<MenuOptionItem> options = dmp.options;
                int count =1 ;
                foreach (MenuOptionItem option in options)
                {
                    ms.Append(createMessageLink(MENU_LINK_NAME, count + ") ", option.link_val));
                    ms.Append(option.display_text + "\r\n");
                    count++;
                }*/
                List<MenuOptionItem> dyn_options = dmp.dynamic_set.getOptionList(us);
                if (dyn_options.Count() == 0)
                {
                    String empty_msg = dmp.dynamic_set.getListEmptyMessage();
                    if (empty_msg != null && empty_msg != "")
                        ms.Append(dmp.dynamic_set.getListEmptyMessage() + "\r\n");
                }
                addLinksToMessageFromList(us, dyn_options,  ms);

                appendPaginateLinks(us, ms, dyn_options.Count);
                appendExtraCommandLinks(dmp.dynamic_set.getExtraCommandString(), ms);
                appendBackMainLinks(us, ms);
                appendMessageConfig(true,  ms);
            }
            return ms;
            //return output;
        }
        public override MessageToSend getOutputScreenMessage(
            UserSession us,
            MenuPage mp,
            MessageToSend ms,
            InputHandlerResult ihr)
        {
            ms.Append(MessageBuilder.Elements.CreateClearScreen());
            if (!mp.GetType().FullName.Equals("MxitTestApp.VerseMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            VerseMenuPage omp = (VerseMenuPage)mp;
            ms.Append(omp.title + "\r\n", TextMarkup.Bold);
            ms.Append("\r\n");
            ms.Append("\r\n");
            if (ihr.error != null && ihr.action == InputHandlerResult.INVALID_MENU_ACTION)
            {
                ms.Append((string)ihr.error + "\r\n");
            }

            Boolean should_display_conf_message = displayMessage(us, ms, ihr);
            if (should_display_conf_message)
            {
                return ms;
            }
            ms.Append(parseMessage(us, omp.message) + "\r\n");

            /*else if (us.getVariable(FriendHandler.DELETED_FRIEND_NAME) != null)
            {
                friend_name = (String)us.removeVariable(FriendHandler.DELETED_FRIEND_NAME);
                ms.Append("You have removed " + friend_name + " from you buddy list.");
                ms.Append("\r\n");
                ms.Append("\r\n");
            }*/

            if (us.friend_manager.getFriends().Count <= 0)
            {
                ms.Append("You dont have any buddies added, you need to first invite buddies in order to send Verses to them.");
                ms.Append("\r\n");
                ms.Append("\r\n");
            }
            else
            {
                Boolean recip_is_set = false;
                //check if recipient is set already

                if (us.hasVariable(ChooseFriendHandler.RECIPIENT_LIST) && ((List<long>)us.getVariableObject(ChooseFriendHandler.RECIPIENT_LIST)).Count > 0)
                {
                    String friend_list = getCurrentSendList(us);
                    ms.Append("To: ");
                    ms.Append(friend_list);
                    ms.Append(" ");
                    ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", VerseMessageSendHandler.CHOOSE_FRIEND_ID));
                    recip_is_set = true;
                }
                else
                {
                    ms.Append("To: ");
                    ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", VerseMessageSendHandler.CHOOSE_FRIEND_ID));
                    ms.Append(" *");
                }

                ms.Append("\r\n");
                ms.Append("\r\n");

                VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
                if (vs == null)
                {
                    Console.WriteLine("Expected Browse.verse_section present, but not found");
                }
                else
                {
                    Verse start_verse = vs.start_verse;
                    Verse end_verse = vs.end_verse;
                    if (end_verse == null)
                    {
                        end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
                    }

                    ms.Append("Verse: ");
                    ms.Append(BibleHelper.getVerseSectionReference(start_verse, end_verse), TextMarkup.Bold);
                    ms.Append("\r\n");
                    ms.Append("\r\n");
                }

                if (us.hasVariable(MESSAGE_SUBJECT))
                {
                    String subject = us.getVariable(MESSAGE_SUBJECT);
                    ms.Append("Subject: ");
                    ms.Append(subject);
                    ms.Append(" ");
                }
                else
                {
                    ms.Append("Subject: ");
                }
                ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", VerseMessageSendHandler.ENTER_MESSAGE_SUBJECT));
                ms.Append("\r\n");
                ms.Append("\r\n");

                if (us.hasVariable(MESSAGE_TEXT))
                {
                    String message = us.getVariable(MESSAGE_TEXT);
                    ms.Append("Message: ");
                    ms.Append(message);
                    ms.Append(" ");
                }
                else
                {
                    ms.Append("Message: ");
                }
                ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", VerseMessageSendHandler.ENTER_MESSAGE));
                ms.Append("\r\n");
                ms.Append("\r\n");

                if (!recip_is_set)
                    ms.AppendLine("Fields marked with * has to be set before you can send the message");
                else
                    ms.AppendLine(createMessageLink(MENU_LINK_NAME, "Send Message", VerseMessageSendHandler.SEND_MESSAGE));
            }
            ms.AppendLine("");
            appendBackMainLinks(us, ms);
            appendMessageConfig(true,  ms);
            return ms;
            //return output;
        }
        public override MessageToSend getOutputScreenMessage(
            UserSession us,
            MenuPage mp,
            MessageToSend ms,
            InputHandlerResult ihr)
        {
            ms.Append(MessageBuilder.Elements.CreateClearScreen());
            if (!mp.GetType().FullName.Equals("MxitTestApp.VerseMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            VerseMenuPage omp = (VerseMenuPage)mp;
            ms.Append(omp.title + "\r\n", TextMarkup.Bold);
            ms.Append("\r\n");
            ms.Append("\r\n");
            if (ihr.error != null && ihr.action == InputHandlerResult.INVALID_MENU_ACTION)
            {
                ms.Append((string)ihr.error + "\r\n");
            }

            Boolean should_display_conf_message = displayMessage(us, ms, ihr);
            if (should_display_conf_message)
            {
                return ms;
            }
            ms.Append(parseMessage(us, omp.message) + "\r\n");

            /*else if (us.getVariable(FriendHandler.DELETED_FRIEND_NAME) != null)
            {
                friend_name = (String)us.removeVariable(FriendHandler.DELETED_FRIEND_NAME);
                ms.Append("You have removed " + friend_name + " from you buddy list.");
                ms.Append("\r\n");
                ms.Append("\r\n");
            }*/

                Boolean recip_is_set = false;
                //check if recipient is set already
                if (us.hasVariable(RECIPIENT_ID))
                {
                    String friend_id = us.getVariable(RECIPIENT_ID);
                    long l_friend_id = long.Parse(friend_id);
                    String user_name = UserNameManager.getInstance().getUserName(l_friend_id);
                    ms.Append("To: ");
                    ms.Append(user_name, TextMarkup.Bold);
                    ms.Append(" ");
                    ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", NotifMessageSendHandler.CHOOSE_FRIEND_ID));
                    recip_is_set = true;
                }
                else
                {
                    ms.Append("To: ");
                    ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", NotifMessageSendHandler.CHOOSE_FRIEND_ID));
                    ms.Append(" *");
                }

                ms.Append("\r\n");
                ms.Append("\r\n");

                if (us.hasVariable(MESSAGE_SUBJECT))
                {
                    String subject = us.getVariable(MESSAGE_SUBJECT);
                    ms.Append("Subject: ");
                    ms.Append(subject);
                    ms.Append(" ");
                }
                else
                {
                    ms.Append("Subject: ");
                }
                ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", NotifMessageSendHandler.ENTER_MESSAGE_SUBJECT));
                ms.Append("\r\n");
                ms.Append("\r\n");

                if (us.hasVariable(MESSAGE_TEXT))
                {
                    String message = us.getVariable(MESSAGE_TEXT);
                    ms.Append("Message: ");
                    ms.Append(message);
                    ms.Append(" ");
                }
                else
                {
                    ms.Append("Message: ");
                }
                ms.Append(createMessageLink(MENU_LINK_NAME, "[ edit ]", NotifMessageSendHandler.ENTER_MESSAGE));
                ms.Append("\r\n");
                ms.Append("\r\n");

                if (!recip_is_set)
                    ms.AppendLine("Fields marked with * has to be set before you can send the message");
                else
                    ms.AppendLine(createMessageLink(MENU_LINK_NAME, "Send Message", NotifMessageSendHandler.SEND_MESSAGE));

            ms.AppendLine("");
            appendBackMainLinks(us, ms);
            appendMessageConfig(true,  ms);
            return ms;
            //return output;
        }
        public override MessageToSend getOutputScreenMessage(
            UserSession us,
            MenuPage mp,
            MessageToSend ms,
            InputHandlerResult ihr)
        {
            ms.Append(MessageBuilder.Elements.CreateClearScreen());
            if (!mp.GetType().FullName.Equals("MxitTestApp.OptionMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            OptionMenuPage omp = (OptionMenuPage)mp;
            ms.Append(omp.title + "\r\n", TextMarkup.Bold);
            if (ihr.action == InputHandlerResult.INVALID_MENU_ACTION
                && ihr.error != null)
            {
                ms.Append((string)ihr.error + "\r\n");
            }
            else
            {
                ms.Append(parseMessage(us, omp.message) + "\r\n");
            }

            ms.AppendLine("Refer a friend to the BibleApp on MXit by using the link below. ");
            ms.AppendLine(createMessageLink(MENU_LINK_NAME, "Spread The Word", MainMenuHandler.REFER_A_FRIEND));

            ms.AppendLine();

            if (us.user_profile.is_suspended)
            {
                ms.Append("\r\n");
                ms.Append("You have been suspended from this application. Please email us at [email protected].");
                ms.Append("\r\n");
                ms.Append("\r\n");
                return ms;
            }

            if (us.hasVariable(UserSession.GUEST_USER_NAME_ASSIGNED))
            {
                ms.Append("\r\n");
                ms.Append("You have been assigned a guest user name. To remove this message please change your user name in the profile option below.");
                ms.Append("\r\n");
                ms.Append("\r\n");
            }

            if (us.bookmark_manager.bookmark_verse != null)
            {
                ms.Append("To continue reading where you left off ");
                ms.Append(createMessageLink(MENU_LINK_NAME, "Click Here", "BOOKMARK"));
                ms.Append("\r\n");
                ms.Append("\r\n");
                ms.Append("Or choose an option below...\r\n");
            }
            else
            {
                ms.Append("Choose an option below...\r\n");
            }

            List<MenuOptionItem> options = omp.options;
            int count =1 ;
            foreach (MenuOptionItem option in options)
            {
                ms.Append(createMessageLink(MENU_LINK_NAME, count + ") ", option.link_val));
                if (option.menu_option_id == MY_PROFILE_OPTION_ID)
                {
                    if (us.hasNewEvent())
                    {
                        ms.Append(option.display_text + " (!)\r\n", TextMarkup.Bold);
                    }
                    else
                    {
                        ms.Append(option.display_text + "\r\n");
                    }
                }
                else
                {
                    ms.Append(option.display_text + "\r\n");
                }

                count++;
            }
            appendBackMainLinks(us,  ms);
            appendMessageConfig(true, ms);

            ms.AppendLine("");

            ms.AppendLine("");
            ms.AppendLine("Shortcuts...", TextMarkup.Bold);
            ms.Append(createMessageLink(MENU_LINK_NAME, "Inbox", MainMenuHandler.MESSAGE_INBOX));
            if (us.hasNewMessageEvent())
            {
                ms.Append(" (NEW)", TextMarkup.Bold);
            }

            if (us.hasNewFriendRequest())
            {
                ms.Append(" | ");
                ms.Append(createMessageLink(MENU_LINK_NAME, "Buddy Requests", MainMenuHandler.BUDDY_REQUESTS));
                ms.Append(" (NEW)", TextMarkup.Bold);
            }

            ms.Append(" | ");
            ms.Append(createMessageLink(MENU_LINK_NAME, "Help", MainMenuHandler.HELP));

            ms.Append(" | ");
            ms.Append(createMessageLink(MENU_LINK_NAME, "About Us", MainMenuHandler.ABOUT));

            ms.Append(" | ");
            ms.Append(createMessageLink(MENU_LINK_NAME, "Change Colours", MainMenuHandler.COLOUR_CHANGE));

            ms.AppendLine();
            ms.AppendLine();
            UserColourTheme uct = UserColourTheme.getColourTheme(us.user_profile.user_profile_custom.colour_theme);
            if (uct != null)
            {
                Color color = uct.getTipTextColour();
                ms.AppendLine("Tip: Check out the profile section and if your friends use the BibleApp add them as buddies so that you can send them verses. For a start add us, our code is CBTJXP. ",color);
            }
            else
            {
                ms.AppendLine("Tip: Check out the profile section and if your friends use the BibleApp add them as buddies so that you can send them verses. For a start add us, our code is CBTJXP. ");
            }
            ms.AppendLine();
            ms.AppendLine();
            //ADMIN AREA
            if (us.user_profile.is_admin)
            {
                ms.AppendLine("ADMIN AREA");
                ms.AppendLine("");
                ms.Append(createMessageLink(MENU_LINK_NAME, "Send Notification", MainMenuHandler.SEND_NOTIFICATION));
                //ms.AppendLine("");
                //ms.Append(createMessageLink(MENU_LINK_NAME, "Send Notification", MainMenuHandler.SEND_NOTIFICATION));
            }

            return ms;
            //return output;
        }
Пример #6
0
 public abstract MessageToSend getOutputScreenMessage(
     UserSession us,
     MenuPage mp,
     MessageToSend ms,
     InputHandlerResult ihr);
Пример #7
0
        public string getOutputScreen(MenuPage mp)
        {
            if (!mp.GetType().FullName.Equals("MxitTestApp.OptionMenuPage"))//TODO: Should be constant
                throw new Exception("Invalid menu page passed into getScreen method ");

            OptionMenuPage omp = (OptionMenuPage)mp;
            string output = "";
            output += omp.title + "\r\n";
            output += omp.message + "\r\n";
            List<MenuOptionItem> options = omp.options;
            foreach (MenuOptionItem option in options)
            {
                output += option.menu_option_id + ") " + option.display_text + "\r\n";
            }
            output += "\r\n Main Menu | Back \r\n";
            return output;
        }