[Android Apps and Games] halnovemila:
6) Let's customize the "action bar"

The contact number shown in the action bar below the contact name is so ridiculously small that it can't be easily read, especially because a sequence of number is less likely to be visually recognized than a word that have "patterns" that our brain can use to recognize it.

Unfortunately chomp SMS, among the many theme settings, doesn't provide any related to the action bar contents, apart from the color.

So, once again, we need to find out where, in the app resources or code, are saved the values that controls the action bar contents appearance.

Looking at the content of the layout folder we can find a file named conversation.xml that likely will contain the description of the layout of the Conversation view and possibily has a reference to the action bar.

Indeed we can find, at row 5, the following

<FrameLayout a:id="@id/conversation_header_holder" a:background="?fakeActionBarBackground"

Still in layout folder we can find another file that might be related, with name action_bar_holder.xml

here we see that the second row contains this attribute

layout_height="?initialActionbarHeight"

The question mark tell use that the value is saved in the styles.xml files which can be found in (C:\Decompression.chamber\com.p1.chompsms-1)\values

Opening styles.xml file and searching for "initialActionbarHeight" we'll find the following:

<item name="initialActionbarHeight">@dimen/actionbar_height</item>

That means that the value of initialActionbarHeight is saved in dimens.xml file that can be found in the same value folder as styles.xml is.

Opening dimens.xml and searching for actionbar_height we'll find this:

<dimen name="actionbar_height">48.0dip</dimen>

bingo! :D

So, let's make the action bar bigger... let's change 48.0 in 52.0

Searching for "actionbar" inside styles.xml we can find a number of styles and values but with some analysis and trial and error attempts you can realize that styles that has "convo_actionbar_customview" in their name are the ones relevant.

Among them the follow two are the one that we are looking for:

<style name="convo_actionbar_customview_title" parent="@style/ActionBarTitle">
<item name="android:ellipsize">end</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:maxLines">1</item>

<style name="convo_actionbar_customview_subtitle" parent="@style/ActionBarTitle">
<item name="android:textSize">12.0sp</item>
<item name="android:ellipsize">end</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:maxLines">1</item>

Here we can see that the subtitle (which actually is the contact phone number, while the title is the contact name) has a textSize of 12.0sp... to have it bigger we need to, well... you know what! ;)

Let's change it to 16.0sp and set a bit of free space at the bottom, to have it more vertically centered on the action bar, by adding the following line to the style

<item name="android:paddingBottom">3.0dip</item>

The convo_actionbar_customview_title style doesn't define its own textSize value, so it will just use the one set on the "parent" stlye ActionBarTitle, which is 18.0dip

<style name="ActionBarTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textSize">18.0dip</item>

I tried to change it to 20.0dip but it turned out that the textSize changed only if the contact name was displayed alone without the phone number (without subtitle), but if the number is shown then the contact name text size was as small as the original.

Doing some more searches in the the styles.xml file I then found the following line that belong the definition of the DefaultTheme style.

<item name="convo_actionbar_customview_title_with_subtitle_textsize">@dimen/convo_actionbar_customview_title_with_subtitle_textsize</item>

That line tells us that the dimension of the phone number is saved in dimens.xml file (already mentioned above) and indeed there we can find this:

<dimen name="convo_actionbar_customview_title_with_subtitle_textsize">16.0dip</dimen>

By replacing the value of 16.0dip with 20.0dip, the contact name will become bigger and easier to read.

:highfive:

I've observed that there's a glitch on how the ellipsis (the shortening of a text with addition of the theree dots) is applied to the contact name... it's sometimes much shorter than the available space.

I found out that the glitch is fixed if the singleLine attribute is enabled.

So let's add the following line to the convo_actionbar_customview_title style.

<item name="android:singleLine">true</item>

As last thing I wanted to remove the call button on the action bar because it has appened more than once that while I had the phone on my pants pocket and the screen was unlocked (forgot to lock) then accidentally the call button was touched and a phone call initiated without me being aware of it.

To find where in the app is defined the visualization of the call button, I started with a search for word "call" inside all the files existing in the chomp SMS decompiled app folder (C:\Decompression.chamber\com.p1.chompsms-1)

I then found that the button icon image is saved as ic_call_icon.png both on xhdpi and and xxxhdpi drawable folders.

Searching for ic_call_icon text inside all the files, I found a layout name ic_call_icon_wrapper.xml that contain a reference to that image.

Searching for ic_call_icon_wrapper, I found a smali file, (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com/p1/chompsms/activities/Conversation.smali that contain a reference to ic_call_icon_wrapper layout.

At line 8510 of Conversation.smali, inside .method public onCreateOptionsMenu(Landroid/view/Menu we can find

sget v2, Lcom/p1/chompsms/s$f;->ic_call_icon_wrapper:I

by analyzing the code a little above and below that row it's possible to spot the "section" that actually initialize the button and attach to it an "intent" the "action" to initiate a call.

To avoid the button to be displayed we can set a jump in the code that will make the execution to bypass that section.

So here it is how to add the jump:

After

.line 822
invoke-static {}, Lcom/p1/chompsms/util/Util;->g()Z
move-result v0
if-eqz v0, :cond_2

add

.line 9998500
goto :goto_9998531

Before

.line 830
const/16 v1, 0xd

add

:goto_9998531

And now... as usual... the final result! :D

.

Before... after

That's more than enough for what concern the Conversation view... mission accomplished! ;)

7) Let's "fix" the "Conversation list", the "main" view, layout

Let's have again a look at the chomp SMS conversations and compare it to the SGY Messaging app.

.

First of all I don't understand why the date should be on the same line of the contact name thus shorting it, instead of being on the same line of the message preview as it is in the old SGY Messaging app.

Secondly... I don't like that date format! :silly:

So... let's fix it.

As usual the first thing to do is to find the layout file, or smali file that control the appearance of the conversation list view.

The first guess is the layout file main.xml in res\layout folder.

It indeed contains some references to a few parts of the view, but not in detail the parts that we are looking to modify, which are eventually described on another layout file.

Scrolling the files in layout folder another one seems very promising by its name: conversation_row.xml

Found! bingo! :D

in conversation_row.xml there' are clear references to the contact name, message row, and date

Here is the related lines

For contact name and date

<com.p1.chompsms.activities.search.SearchResultTextView a:id="@id/person_label" ...
<com.p1.chompsms.views.TextViewWithEllipsesFix a:id="@id/date_label"...

For message text

<com.p1.chompsms.activities.search.SearchResultTextView a:id="@id/subject_label"

The textview id attributes (id/person_label, id/subject_label, id/date_label) makes it very sure that those lines are the one that controls the positions of contact name, message text, and date.

So, in order to change the relative positions we just have to properly move those lines within the layout

Let's cut the date_label TextView line and paste it right below the subject_label TextView line, so that it looks like this

<LinearLayout a:orientation="horizontal" a:layout_width="fill_parent" a:layout_height="wrap_content">
<com.p1.chompsms.activities.search.SearchResultTextView a:id="@id/subject_label"...
<com.p1.chompsms.views.TextViewWithEllipsesFix a:id="@id/date_label" ...
<ImageView a:layout_gravity="bottom" a:id="@id/pinned_marker"...

That's enough to move the date from the above line with the contact name to the below line with the message text.

But we can see that in the same line of the date, now (actually at the right of the date) there's the placeholder for the image that is used to a conversation row as "pinned".

The three objects, message text, date and marker are listed in three rows one below the other, but they will actually be displayed on one horizontal row, one next the other, as the LinearLayout they belong is set as orientation="horizontal".

Is better to move the pinned marker on the same row of the contact name, so... cut and paste right below the person_label TextView line, so that it looks like this

<LinearLayout a:orientation="horizontal" a:layout_marginTop="-3.0dip" ...
<com.p1.chompsms.views.BaseLineImageView a:id="@id/unread_marker"...
<com.p1.chompsms.views.BaseLineImageView a:id="@id/no_notification"...
<com.p1.chompsms.activities.search.SearchResultTextView a:id="@id/person_label"...
<ImageView a:layout_gravity="bottom" a:id="@id/pinned_marker"...

Ok, that's done

Now the "hard" part... the modification of date formatting.

To find where in the 1672 smali files contained in (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com\p1\chompsms is the piece of code that set the date format we can try to trace back the chain starting from the conversation_row.xml layout.

Here we see that the date TextView contents is "controlled" by com.p1.chompsms.views.TextViewWithEllipsesFix that can be found and read as a smali file of name TextViewWithEllipsesFix.smali saved in (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com\p1\chompsms\views

Giving a look at the code of that smali file doesn't show anything related to the date format, so it means that there must be another place, another smali file, that does the date formatting and then pass the result to TextViewWithEllipsesFix; we need to find any smali file that has inside a call to TextViewWithEllipsesFix.

Unfortunately, there's not even one smali file that contains a reference to Lcom/p1/chompsms/views/TextViewWithEllipsesFix in order to pass some data to it or call any of its method.

Eventually the code we are looking for is in (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com\p1\chompsms\views\ConversationRow.smali that is defined in conversation_row.xml layout as the root view, the main container.

By reading the contents of ConversationRow.smali, we can see that at the beginning is defined a variable "p" made to contain a date object

.field private p:Ljava/util/Date;

A few line below, inside the .method public constructor, the "date" , received by as argument p0, is saved in "p".

iput-object v0, p0, Lcom/p1/chompsms/views/ConversationRow;->p:Ljava/util/Date;

Searching for the string "->p:Ljava/util/Date" we can see that "p" is used only in the .method public final b(J)Ljava/util/Date;

The method "b(J)Ljava/util/Date" isn't called anywhere within ConversationRow.smali, so the parameters it receives and the results it returns must be related to some code in some other smali file.

Searching the whole chomp SMS smali folder for files containing the string "b(J)Ljava/util/Date" gave me as result two files:

com/p1/chompsms/activities/conversationlist/ConversationList$a.smali

com/p1/chompsms/activities/search/a.smali

In a.smali, in .method public final bindView, at row 171 there's the call to method "b(J)"

invoke-virtual {v3, v4, v5}, Lcom/p1/chompsms/views/ConversationRow;->b(J)Ljava/util/Date;

The result of the call, supposedly it's a date or time, is then saved to v4, then v5 and v9 are set to numeric value "1", then v0 is set equal to p2 (a parameter received by the bindView method) then v4, v0, v5, v9 are all used to make a call to method a(Ljava/util/Date;Landroid/content/Context;ZZ)Ljava/lang/String defined in com\p1\chompsms\util\cd.smali

invoke-static {v4, v0, v5, v9}, Lcom/p1/chompsms/util/cd;->a(Ljava/util/Date;Landroid/content/Context;ZZ)Ljava/lang/String;

util\cd.smali ? :eek:

But that's the same cd.smali that we had to modify earlier to change the format of time and date in the conversation message timestamp! :D

Let's have a look to method "a(Ljava/util/Date;Landroid/content..." in cd.smali

The method is quite long, but it's clear that is doing some kind of operations on the date that it has received when is been called by a.smali, which has received the date from method "b" in conversation_row.smali.

The "a" method calls the calendar

invoke-virtual {v2, v3}, Ljava/util/Calendar;->get(I)I

in order to know how many days are past from the given date and the present time.

It then choose if in place of a "text" containing a formatted date it has to return a string like "today" or "yesterday"

.line 78
:cond_1
sget v0, Lcom/p1/chompsms/s$l;->today:I

.line 82
sget v0, Lcom/p1/chompsms/s$l;->yesterday:I

But if it's not the case for "today" or "yesterday", but still the given date isn't past than more than three days, than the method code will format the date using the SimpleDateFormat stored in "a" variable!

sget-object v0, Lcom/p1/chompsms/util/cd;->a:Ljava/text/SimpleDateFormat;
invoke-virtual {v0, p0}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
move-result-object v0

If we look at the very beginning of the cd.smali file we can see that the date format stored in "a" is in the form of "EEEE"

const-string v1, "EEEE"
invoke-direct {v0, v1}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V
sput-object v0, Lcom/p1/chompsms/util/cd;->a:Ljava/text/SimpleDateFormat;

"EEEE" is the standard pattern letter that refers to the "day of the week" (for more info read here https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) and as the "E" letters are four then the name will be in full, not abbreviated... like Sunday and Monday, instead of Sun, and Mon.

So if the date that has been received is same as the present date or is one day or two days old the result would be either "today", "yesterday" or the day of the week, but if it's older...

.line 89
:cond_4
invoke-static {p1}, Lcom/p1/chompsms/util/cd;->b(Landroid/content/Context;)Ljava/text/DateFormat;

The DateFormat returned by .method private static declared-synchronized b(Landroid/content/Context; )Ljava/text/DateFormat will be used.

Having a look to the contents of that method we can see that it retrieves the DateFormat by querying the System Settings

const-string v2, "date_format"
invoke-static {v0, v2}, Landroid/provider/Settings$System;->getString(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;

That means that the Date Format will change (synchronized) accordingly with the current System settings.

Well... that's enough! Tiring ah? :silly:

So, we found it! :highfive:

But we still have to fix it... well... that's quite simple once we know where to put our hands ;)

Let's just add a SimpleDateFormat as we already did before for the message TimeStamp and insert the code to force the use of that format instead of the one returned by method "b"

At the beginning of the cd.smali file, # static fields section, add

.field private static final m:Ljava/text/SimpleDateFormat;

At the end of .method static constructor <clinit>()V, below the code added before, add the following

new-instance v0, Ljava/text/SimpleDateFormat;
const-string v1, "d MMM yy"
invoke-direct {v0, v1}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V
sput-object v0, Lcom/p1/chompsms/util/cd;->m:Ljava/text/SimpleDateFormat;

(note that "d MMM yy", is a pattern for a date format like 9 Sep 16)

Then, as last step, replace this

.line 89
:cond_4
invoke-static {p1}, Lcom/p1/chompsms/util/cd;->b(Landroid/content/Context;)Ljava/text/DateFormat;
move-result-object v0
invoke-virtual {v0, p0}, Ljava/text/DateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
move-result-object v0

with this:

.line 89
:cond_4
sget-object v0, Lcom/p1/chompsms/util/cd;->m:Ljava/text/SimpleDateFormat;
invoke-virtual {v0, p0}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
move-result-object v0

Job done! Congratulations! :highfive:

So, let's see how it looks the result of this hard work ;)

.

8) The last touch

If you observe the above pictures you'll find that the Conversation list layout isn't as compact as in SGY Messaging app; moreover the divider line, for some reason, doesn't go all the way from one side to the other of the screen, but has a sort of "margin" distance on its left side.

In order to fine tuning the layout we need to change a few values here and there and add a few too

In values\styles.xml, style "conversationlist_row_content",

change android: paddingLeft value from 8.0 to 0.0

change android: paddingTop value from 10.0 to 7.0

change android: paddingRight value from 16.0 to 6.0

change android: paddingBottom value from 10.0 to 8.0

<style name="conversationlist_row_content">
<item name="android:paddingLeft">0.0dip</item>
<item name="android:paddingTop">7.0dip</item>
<item name="android:paddingRight">6.0dip</item>
<item name="android:paddingBottom">8.0dip</item>

In values\styles.xml, style "conversationlist_row_personlabel",

change android: paddingRight value from 6.0 to 0.0

add android:lineSpacingExtra with value -2.0dip

<style name="conversationlist_row_personlabel">
<item name="android:paddingRight">0.0dip</item>
<item name="android:lineSpacingExtra">-2.0dip</item>

In values\styles.xml, style "conversationlist_row_datelabel",

add android: paddingLeft with value from 6.0

<style name="conversationlist_row_datelabel">
<item name="android:paddingLeft">6.0dip</item>

In values\styles.xml, style "conversationlist_row_subjectlabel",

add android:singleLine with value "true" (to fix the glitch on the ellipsizing)

<style name="conversationlist_row_subjectlabel">
<item name="android:singleLine">true</item>

About the divider...

I hoped I could find any layout file or style attribute somewhere that was related to that left margin that prevents the divider to fill the screen from one side to the other... I couldn't... there's not such thing.

Once again, same as for the case of the message box margin, the divider left margin is "hardcoded".

By searching "divider" within all the smali files existing in (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com\p1\chompsms, there are 27 smali files found but one of them has name ConversationList.smali that seems promising.

The file is located in (C:\Decompression.chamber\com.p1.chompsms-1)\smali\com\p1\chompsms\activities\conversationlist

Indeed... it's the right file! :cool:

It invokes setDivider...

invoke-virtual {v1, v0}, Lcom/p1/chompsms/activities/conversationlist/ConversationListListView;->setDivider(Landroid/graphics/drawable/Drawable;)V

... and setDividerHeight

invoke-virtual {v0, v1}, Lcom/p1/chompsms/activities/conversationlist/ConversationListListView;->setDividerHeight(I)V

Unlike what we found on com/p1/chompsms/views/Message.smali, in ConversationList.smali can't be found any call to setMargins method; there's instead a call to the InsetDrawable class.

invoke-direct/range {v0 .. v5}, Landroid/graphics/drawable/InsetDrawable;-><init>(Landroid/graphics/drawable/Drawable;IIII)V

Changing this

.line 678
:cond_0
const/high16 v1, 0x41800000 # 16.0f

To this

.line 678
:cond_0
const/high16 v1, 0x00000000 # 0.0f

Will get rid of the divider "margin"

Changing this

.line 683
iget-object v0, p0, Lcom/p1/chompsms/activities/conversationlist/ConversationList;->h:Lcom/p1/chompsms/activities/conversationlist/ConversationListListView;
const/high16 v1, 0x3f800000 # 1.0f

To this

.line 683
iget-object v0, p0, Lcom/p1/chompsms/activities/conversationlist/ConversationList;->h:Lcom/p1/chompsms/activities/conversationlist/ConversationListListView;
const/high16 v1, 0x3fc00000 # 1.0f

Will increase the divider thickness from 1.0dip to 1.5dip

So, now... it's showtime! :fingers-crossed:

.

Cherry on the cake ;)

If the phone is connected to the Internet, every three times that the user "enter" one of the SMS conversations, chomp SMS will display an advertisment that will pin on top of the Conversation list... like this

and it will stay there untill the ad gets touched.

The ads are displayed according to their dedicated layouts; there are two different layouts: one generic and one specific for Facebook ads.

The two layouts are defined by two xml files: conversation_list_native_ad_row.xml and conversation_list_native_ad_row_facebook.xml

By adding the attribute a:visibility="gone" to the layouts, the ads won't be visibile anymore (please don't ask "how"... find it out yourself)

:cool:

As cherry on the cake I decided to make a new app icon for the modified chomp SMS app; an icon that is a mix of the SGY Messaging icon and the original chomp SMS one.

+ =

The icon is of hdpi size and it's available for download as attachment to this post.

That's all folks!

If you have enjoyed to follow the tutorial your click on the thanks button here below will be highly appreciated :D

Thanks for reading :)