Messaging Mods

From WebOS Internals
Revision as of 05:10, 23 July 2009 by HattCzech (talk | contribs) (→‎Character Counter: added image)
Jump to navigation Jump to search

All files are located in /usr/palm/applications/com.palm.app.messaging/

Add Timestamps to All Messages

Introduction

A number of users have requested adding timestamps to each message that arrives on the device. Palm actually goes out of their way to group messages that have arrived during various time intervals, but if you'd prefer to see a timestamp on each message, simply follow the instructions below.

Procedure

  1. Gain root access to your device
  2. Remount the file system as read/write
  3. cd to /usr/palm/applications/com.palm.app.messaging/app/controllers/
  4. Backup chatview-assistant.js (just to be safe)
  5. Open chatview-assistant.js and comment out the following lines:
    • 1169 - line that starts with: if(!ChatFlags.
    • 1177 - line that starts with: if(today-msg.
    • 1179 - first closing bracket on its own line: }
    • 1180 - second closing bracket on its own line: }
  6. Save the file and exit the editor
  7. Remount the file system as read-only
  8. Logout of your root session
  9. Reboot the device

You should now see a full timestamp on all received messages.

Acknowledgements

Thanks to tk102 and scuba_steve on PreCentral for the mod.


New Card For Each Conversation

Introduction

The message app can be a pain when you have multiple conversations going on. You often have to swipe back and then pick someone else. It gets annoying fast. This modification modifies the messaging application so that a new card is created whenever you click into a conversation.

Procedure

Edit /usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js and replace the launchChatView function with the following function:

launchChatView: function(chatThreadId) {
    //Need to jump to that stage if it exists
    var stageController = Mojo.Controller.appController.getStageController("messaging"+chatThreadId);
        if (stageController) {
            stageController.activate();
            return;
        }

    var params = {name: 'messaging' + chatThreadId,
            lightweight: Mojo.Controller.appInfo.lwStages
    };

    var callback = function(controller) {
        controller.pushScene('chatview',chatThreadId,{
                    focusWindow: true
                });        
    };

    Mojo.Controller.getAppController().createStageWithCallback(params, callback); //doesnt create ifit exists sooo
  },

  clearListBadgeForChatThreadId: function(chatThreadId) {
    var badgeContainers = ["buddyBageContainer","historyBageContainer"];
    var listItem;
    for (var i = 0; i < badgeContainers.length; i++) {
        listItem = this.controller.get(badgeContainers[i] + chatThreadId);
        if (listItem && !listItem.hasClassName('hide-unread-count')) {
            listItem.addClassName('hide-unread-count');
        }
    }    
  },

Now in /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js, comment out lines 246 and 247. This change will ensure that if you use the "back gesture" in a chat, the application doesn't bring you back to the conversation list...or do anything else.

To "comment out" a line, add // at the beginning. Example:

printf("This is code");
//printf("This is commented out");

Concerns

There is some delay in creating the new cards. I'm not sure why though. As stated above, the cards are only opened when you click into the conversation. Responding to a notification will result in the reuse of the buddy list window, and you have disabled the back gesture.

Acknolwedgements

Thanks to mikedg for the mod.

chris_phelps is continuing to work on this modification to get it working more completely. The first step is to clean up the other launchChatNNN functionality in app-assistant.js which accepts Luna System calls from the notification dashboard items which are created when a new message is received on the phone. These code modifications are being tested currently, and will be posted when we figure out how to clear the new message counters in the main listview-assistant.js.


Character Counter

Character Counter

Introduction

One of the features I liked about my old Treo was the character counter built-in to the messaging application. I thought it would be useful on the Pre, so I modified the messaging application to show the current character count. I made this a separate page from the other modifications because it requires many code changes. Maybe the other messaging modifications could be rolled into this page as well.

Procedure

This modification is the same for both files, just inserted on different lines.
app/controllers/chatview-assistant.js Line 157:
app/controllers/compose-assistant.js Line 115: <source lang="JavaScript"> }, charCounter: { charCountContainer: this.controller.get('charCounterContainer'), charCountElement: this.controller.get('charCounter'), setTextFieldValueFn: this.setTextFieldValue.bind(this) </source>


app/utilities/CharacterCounter.js Line 40: <source lang="JavaScript"> var charCounterUI = { containerElement: null, valueElement: null }; </source>

Line 188:

<source lang="JavaScript"> var setCurrentCharCount = function(newCharCount) { if(charCounterUI.valueElement) { if (newCharCount > 0) charCounterUI.valueElement.update(newCharCount); else charCounterUI.valueElement.update(); } if(charCounterUI.containerElement) { if (newCharCount == 0) { if (charCounterUI.containerElement.visible()) charCounterUI.containerElement.hide(); } else { if (!charCounterUI.containerElement.visible()) charCounterUI.containerElement.show(); } } }; </source>

Line 286:

<source lang="JavaScript"> if(params.charCounter) { charCounterUI.containerElement = params.charCounter.charCountContainer; charCounterUI.valueElement = params.charCounter.charCountElement; if(params.charCounter.setTextFieldValueFn) { setTextFieldValueFn = params.charCounter.setTextFieldValueFn; } } </source>

Line 331:

<source lang="JavaScript"> setCurrentCharCount(rawCharacterData.count); </source>


Again, same code for both files, inserted on different lines.
app/views/chatview/chatview-scene.html Line 25:
app/views/compose/compose-scene.html Line 8: <source lang="HTML4Strict">

</source>


stylesheets/messaging.css Line 839: <source lang="CSS">

  1. messageContainer #charCounterContainer {

line-height: 20px; display:block; height: 20px; border-width: 0px 10px 0px 9px; -webkit-border-image: url(../images/message-segment-badge.png) 0 10 0 9 stretch stretch; position: absolute; z-index: 3; top: 2px; left: 2px; }

  1. messageContainer #charCounterContainer #charCounter {

font-size: 12px; font-weight: bold; color: #679BC2; margin: 0px -4px 3px -3px; } </source> If you don't like the location of the character counter (I have it configured for the top left of the text area), you can modify the #messageContainer #charCounterContainer section above.


These modifications will require LunaSysMgr to be restarted. A rescan will not work. After you've made the modifications listed above, run the following command: <source lang="bash"> pkill LunaSysMgr </source>

Acknowledgements


Force Offline Send Without Dialog

sudo mount -o remount,rw /
sudo vi /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
/forceSendIfOffline =

Change the line to true (below) , writequit , remount, reload , enjoy

forceSendIfOffline = true; 
:wq 
sudo mount -o remount,ro /
sudo stop LunaSysMgr ; sudo start LunaSysMgr