[Verizon Samsung Galaxy S III] Didact74:
Time and AM/PM Statusbar Clock Mods V2.0​

Original thread here​

I have been working on this MOD for a long time now and can finally say finally I got it working 100%!

What Does this MOD do?

- This is a much improved version of the older time and am/pm mod that allowed you to remove time and/or am/pm from the statusbar. This new version introduces a list preference UI with several new options the older MOD did not have. See attached Pictures.

This new MOD will allow you to

:

[B][COLOR="DarkRed"][CENTER]Remove time
Center the clock in statusbar
move the clock to stock location
remove clock from statusbar
remove am/pm
change am/pm to small size
change am/pm to large size
add abbreviated day of week to status bar small size
add abbreviated day of week to status bar large size
remove abbreviated day of week from the status bar[/CENTER]
[/COLOR][/B]

All these changes will work on the fly with no reboot necessary.

There are a few new smali files that had to be created and exstensive changes to some existing smali files. Due to the large amount of changes needed this guide will only cover the changes that are semi-easy to show/explain. For the new files and the files with large amounts of changes I will be uploading a zip with the entire smali file and notes on where they need to be placed.

I used a lot of examples from the CM team to code this MOD and it would have been very difficult without those examples so big props go to them !!

There is a lot to do here so lets get started....

We will be working with several system files. They include:

SystemUI

SecSettings

framework-res

Lets begin with SecSettings.

Decompile SecSettings and navigate to res/values/arrays

Add the following at the end of the file

<string-array name="clock_ampm_entries">
<item>"Don't show"</item>
<item>Small AM/PM</item>
<item>Regular AM/PM</item>
</string-array>
<string-array name="clock_ampm_values">
<item>2</item>
<item>1</item>
<item>0</item>
</string-array>
<string-array name="clock_weekday_entries">
<item>"Don't show"</item>
<item>Small weekday</item>
<item>Regular weekday</item>
</string-array>
<string-array name="clock_weekday_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>

Navigate to res/values/strings and add the following

<string name="enable_clock_weekday">Day of the week</string>
<string name="enable_clock_weekday_summary">Abbreviated day of the week in statusbar</string>
<string name="clock_cat">Clock options</string>
<string name="clock_title_enable">Clock style</string>
<string name="title_clock_ampm_entries">AM/PM style</string>

Navigate to res/xml/date_time_prefs.xml and replace all code with the following

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/date_and_time"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:title="@string/date_time_auto" android:key="auto_time" android:summaryOn="@string/date_time_auto_summaryOn" android:summaryOff="@string/date_time_auto_summaryOff" />
<Preference android:title="@string/date_time_set_date" android:key="date" android:summary="03/10/2008" android:widgetLayout="@layout/round_more_icon" />
<Preference android:title="@string/date_time_set_time" android:key="time" android:summary="12:00am" android:widgetLayout="@layout/round_more_icon" />
<PreferenceCategory android:title="@string/clock_cat" android:key="clock_category">
<ListPreference android:entries="@array/clock_style_entries" android:title="@string/clock_title_enable" android:key="clock_style" android:entryValues="@array/clock_style_values" />
<ListPreference android:entries="@array/clock_ampm_entries" android:title="@string/title_clock_ampm_entries" android:key="clock_am_pm_style" android:entryValues="@array/clock_ampm_values" />
<ListPreference android:entries="@array/clock_weekday_entries" android:title="@string/enable_clock_weekday" android:key="clock_weekday" android:summary="@string/enable_clock_weekday_summary" android:entryValues="@array/clock_weekday_values" />
</PreferenceCategory>
<CheckBoxPreference android:title="@string/zone_auto" android:key="auto_zone" android:summaryOn="@string/zone_auto_summaryOn" android:summaryOff="@string/zone_auto_summaryOff" />
<PreferenceScreen android:title="@string/date_time_set_timezone" android:key="timezone" android:summary="GMT-8:00" android:fragment="com.android.settings.ZonePicker" />
<CheckBoxPreference android:title="@string/date_time_24hour" android:key="24 hour" android:summaryOn="@string/date_time_24_hour_sample" android:summaryOff="@string/date_time_12_hour_sample" />
<ListPreference android:title="@string/date_time_date_format" android:key="date_format" android:summary="mm/dd/yyyy" android:widgetLayout="@layout/round_more_icon" />
</PreferenceScreen>

Navigate to smali/com/android/settings/DateTimeSettings.smali and find the following method

.method public onCreate(Landroid/os/Bundle;)V

Replace that entire method with the following code

.method public onCreate(Landroid/os/Bundle;)V
.locals 4
.parameter "savedInstanceState"

.prologue
.line 132
invoke-super {p0, p1}, Lcom/android/settings/SettingsPreferenceFragment;->onCreate(Landroid/os/Bundle;)V

invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getActivity()Landroid/app/Activity;

move-result-object v0

invoke-virtual {v0}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

.line 134
const v0, 0x7f07001c

invoke-virtual {p0, v0}, Lcom/android/settings/DateTimeSettings;->addPreferencesFromResource(I)V

const-string v0, "clock_style"

invoke-virtual {p0, v0}, Lcom/android/settings/DateTimeSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v0

check-cast v0, Landroid/preference/ListPreference;

iput-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockStyle:Landroid/preference/ListPreference;

const-string v0, "clock_style"

const/4 v1, 0x0

invoke-static {v3, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockStyle:Landroid/preference/ListPreference;

invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v1

invoke-virtual {v2, v1}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockStyle:Landroid/preference/ListPreference;

invoke-virtual {v2, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

const-string v0, "clock_am_pm_style"

invoke-virtual {p0, v0}, Lcom/android/settings/DateTimeSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v0

check-cast v0, Landroid/preference/ListPreference;

iput-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockAmPmstyle:Landroid/preference/ListPreference;

const-string v0, "clock_am_pm_style"

const/4 v1, 0x0

invoke-static {v3, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockAmPmstyle:Landroid/preference/ListPreference;

invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v1

invoke-virtual {v2, v1}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockAmPmstyle:Landroid/preference/ListPreference;

invoke-virtual {v2, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

const-string v0, "clock_weekday"

invoke-virtual {p0, v0}, Lcom/android/settings/DateTimeSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v0

check-cast v0, Landroid/preference/ListPreference;

iput-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockWeekday:Landroid/preference/ListPreference;

const-string v0, "clock_weekday"

const/4 v1, 0x0

invoke-static {v3, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockWeekday:Landroid/preference/ListPreference;

invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v1

invoke-virtual {v2, v1}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v2, p0, Lcom/android/settings/DateTimeSettings;->mClockWeekday:Landroid/preference/ListPreference;

invoke-virtual {v2, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

.line 135
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getResources()Landroid/content/res/Resources;

move-result-object v0

sput-object v0, Lcom/android/settings/DateTimeSettings;->resources:Landroid/content/res/Resources;

.line 136
invoke-direct {p0}, Lcom/android/settings/DateTimeSettings;->initUI()V

.line 139
new-instance v0, Lcom/android/settings/DateTimeSettings$SettingsObserver;

new-instance v1, Landroid/os/Handler;

invoke-direct {v1}, Landroid/os/Handler;-><init>()V

invoke-direct {v0, p0, v1}, Lcom/android/settings/DateTimeSettings$SettingsObserver;-><init>(Lcom/android/settings/DateTimeSettings;Landroid/os/Handler;)V

iput-object v0, p0, Lcom/android/settings/DateTimeSettings;->mSettingsObserver:Lcom/android/settings/DateTimeSettings$SettingsObserver;

.line 141
return-void
.end method

You will now

create

the following new method by pasting the following code right after the "oncreate" method you just pasted

.method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z
.locals 3
.parameter "preference"
.parameter "objValue"

iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockStyle:Landroid/preference/ListPreference;

if-ne p1, v0, :cond_0

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v0

invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

move-result v1

invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v2, "clock_style"

invoke-static {v0, v2, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

:cond_0
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockAmPmstyle:Landroid/preference/ListPreference;

if-ne p1, v0, :cond_1

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v0

invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

move-result v1

invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v2, "clock_am_pm_style"

invoke-static {v0, v2, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

:cond_1
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mClockWeekday:Landroid/preference/ListPreference;

if-ne p1, v0, :cond_2

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v0

invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

move-result v1

invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v2, "clock_weekday"

invoke-static {v0, v2, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

:cond_2
const/4 v0, 0x1

return v0
.end method

Thats it for SecSettings, recompile and set it aside.

Decompile SystemUI and navigate to res/values/layout/tw_status_bar.xml

Replace the entire file with the following code

<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/status_bar_background" android:focusable="true" android:fitsSystemWindows="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/center_clock_layout" android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.ClockCenter android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="center" android:id="@id/center_clock" android:paddingLeft="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</LinearLayout>
<ImageView android:id="@id/notification_lights_out" android:paddingLeft="6.0dip" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" />
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="0.0dip" android:paddingRight="2.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:id="@id/left_icons" android:paddingLeft="4.0dip" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<TextView android:textSize="15.0dip" android:gravity="center_vertical" android:id="@id/carrierLabel" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
<ImageView android:id="@id/operatorLogoIcon" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:src="@drawable/tw_stat_notify_operator_logo" />
<ImageView android:id="@id/doNotDisturbIcon" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tw_dnd" android:alpha="0.7" android:scaleX="0.85" android:scaleY="0.85" />
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/right_icons" android:paddingRight="4.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true">
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/tw_signal_cluster_view" />
<TextView android:textSize="12.0dip" android:textColor="#ffa6a6a6" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" />
<ImageView android:gravity="center" android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:textSize="@dimen/status_bar_clock_text_size" android:textColor="#ff959595" android:ellipsize="none" android:gravity="left|center" android:id="@id/clock" android:paddingLeft="3.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:includeFontPadding="false" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:paddingLeft="6.0dip" android:animationCache="false" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginRight="4.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="centerInside" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="centerInside" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:paddingRight="10.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:id="@id/ticker_text_view_old" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:id="@id/ticker_text_view_new" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>

Navigate to res/values/ids

Past the following somewhere in the file

<item type="id" name="center_clock">false</item>
<item type="id" name="center_clock_layout">false</item>

Navigte to smali/com/android/systemui/phone/PhoneStatusBar.smali

Find the following method

.method public showClock(Z)V

Replace the entire method with the following code

.method public showClock(Z)V
.locals 8
.parameter

.prologue
const/16 v3, 0x8

const/4 v2, 0x0

const/4 v1, 0x1

.line 1151
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

if-nez v0, :cond_1

.line 1162
:cond_0
:goto_0
return-void

.line 1152
:cond_1
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

const v4, 0x7f0d003d

invoke-virtual {v0, v4}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

move-result-object v4

.line 1153
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

const v5, 0x7f0d011f

invoke-virtual {v0, v5}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

move-result-object v5

.line 1154
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v6, "clock_style"

invoke-static {v0, v6, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

if-ne v0, v1, :cond_3

move v0, v1

.line 1155
:goto_1
iget-object v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

invoke-virtual {v6}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v6

const-string v7, "clock_style"

invoke-static {v6, v7, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v6

const/4 v7, 0x2

if-ne v6, v7, :cond_4

.line 1156
:goto_2
if-eqz v0, :cond_2

if-eqz v4, :cond_2

.line 1157
if-eqz p1, :cond_5

move v0, v2

:goto_3
invoke-virtual {v4, v0}, Landroid/view/View;->setVisibility(I)V

.line 1159
:cond_2
if-eqz v1, :cond_0

if-eqz v5, :cond_0

.line 1160
if-eqz p1, :cond_6

:goto_4
invoke-virtual {v5, v2}, Landroid/view/View;->setVisibility(I)V

goto :goto_0

:cond_3
move v0, v2

.line 1154
goto :goto_1

:cond_4
move v1, v2

.line 1155
goto :goto_2

:cond_5
move v0, v3

.line 1157
goto :goto_3

:cond_6
move v2, v3

.line 1160
goto :goto_4
.end method

Now comes the part where we have ALOT of changes. I am going to attach a zip file that will contain the following files

-PhoneStatusBar$MyTicker.smali - this file goes in smali/com/android/systemui/phone
-Clock.smali - this file goes in smali/com/android/systemui/policy
-Clock$1.smali - this file goes in smali/com/android/systemui/policy
-Clock$SettingsObserver.smali - this file goes in smali/com/android/systemui/policy
-ClockCenter.smali - this file goes in smali/com/android/systemui/policy
-ClockStock$1.smali - this file goes in smali/com/android/systemui/policy
-ClockStock.smali - this file goes in smali/com/android/systemui/policy

Add and/or replace the existing files with the new ones above

I mentioned we will be working with framework-res and while we are not modifing any files in framework-res you will need to refer to res/values/public if you run into issues with copy and pasting the new code/files. There are quite a few unique ID's that need to match those in the "public" xmlboth in SystemUI and framework-res. If you have issues getting this working, you will need to verify you have the right IDs in the new and revided files. Like I said, its a tough MOD with a lot involved. I will be posting up a flashable zip later tomorrow but it will have other MODs built into it in addition to this time MOD.

Good luck, enjoy and feel free to ask questions if you have them. Thereis an outside chance I forgot something in this guide but I am sure we will figure it out once DEVs get going with it.

DEVs, feel free to use this MOD, just shoot me some credit and hit the thanks button.

See original thread for attachments

Have fun!!