[Miscellaneous Android Development] Mohitash:
***Here is a guide for Adding Hide time and am/pm toggle in Samsung ICS Devices***

This guide is specially for GT-S7562. But should work for other Samsung ICS devices also. Values may differ.​

Here, we will edit two files:

SecSettings.apk

SystemUI.apk

Here we start-

Decompile SecSettings.apk

Open smali/com/android/settings/DateTimeSettings.smali

Add blue one

# instance fields
.field private mAutoTimePref:Landroid/preference/CheckBoxPreference;

.field private mAutoTimeZonePref:Landroid/preference/CheckBoxPreference;

.field private mDateFormat:Landroid/preference/ListPreference;

.field private mDatePref:Landroid/preference/Preference;

.field private mDummyDate:Ljava/util/Calendar;

[COLOR="Blue"].field private mHideAmPm:Landroid/preference/Preference;[/COLOR]

[COLOR="blue"].field private mHideTime:Landroid/preference/Preference;[/COLOR]

.field private mIntentReceiver:Landroid/content/BroadcastReceiver;

.field private mSettingsObserver:Lcom/android/settings/DateTimeSettings$SettingsObserver;

.field private mTime24Pref:Landroid/preference/Preference;

.field private mTimePref:Landroid/preference/Preference;

.field private mTimeZone:Landroid/preference/Preference;

Search

Replace the whole method with this

.method private initUI()V
.locals 8

.prologue
const/4 v5, 0x1

const/4 v6, 0x0

.line 152
const-string v4, "auto_time"

invoke-direct {p0, v4}, Lcom/android/settings/DateTimeSettings;->getAutoState(Ljava/lang/String;)Z

move-result v0

.line 153
.local v0, autoTimeEnabled:Z
const-string v4, "auto_time_zone"

invoke-direct {p0, v4}, Lcom/android/settings/DateTimeSettings;->getAutoState(Ljava/lang/String;)Z

move-result v1

.line 155
.local v1, autoTimeZoneEnabled:Z
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getActivity()Landroid/app/Activity;

move-result-object v4

invoke-virtual {v4}, Landroid/app/Activity;->getIntent()Landroid/content/Intent;

move-result-object v2

.line 156
.local v2, intent:Landroid/content/Intent;
const-string v4, "firstRun"

invoke-virtual {v2, v4, v6}, Landroid/content/Intent;->getBooleanExtra(Ljava/lang/String;Z)Z

move-result v3

.line 158
.local v3, isFirstRun:Z
invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;

move-result-object v4

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mDummyDate:Ljava/util/Calendar;

.line 160
const-string v4, "auto_time"

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

move-result-object v4

check-cast v4, Landroid/preference/CheckBoxPreference;

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mAutoTimePref:Landroid/preference/CheckBoxPreference;

.line 161
iget-object v4, p0, Lcom/android/settings/DateTimeSettings;->mAutoTimePref:Landroid/preference/CheckBoxPreference;

invoke-virtual {v4, v0}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

.line 162
const-string v4, "auto_zone"

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

move-result-object v4

check-cast v4, Landroid/preference/CheckBoxPreference;

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mAutoTimeZonePref:Landroid/preference/CheckBoxPreference;

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

move-result-object v4

invoke-static {v4}, Lcom/android/settings/Utils;->isWifiOnly(Landroid/content/Context;)Z

move-result v4

if-nez v4, :cond_0

if-eqz v3, :cond_2

.line 166
.line 167
:cond_0
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getActivity()Landroid/app/Activity;

move-result-object v4

invoke-static {v4}, Lcom/android/settings/Utils;->isWifiOnly(Landroid/content/Context;)Z

move-result v4

if-eqz v4, :cond_1

.line 168
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

move-result-object v4

iget-object v7, p0, Lcom/android/settings/DateTimeSettings;->mAutoTimePref:Landroid/preference/CheckBoxPreference;

invoke-virtual {v4, v7}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

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

move-result-object v4

const-string v7, "auto_time_zone"

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

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

move-result-object v4

const-string v7, "auto_time"

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

.line 173
const/4 v0, 0x0

.line 175
:cond_1
const/4 v1, 0x0

.line 177
:cond_2
iget-object v4, p0, Lcom/android/settings/DateTimeSettings;->mAutoTimeZonePref:Landroid/preference/CheckBoxPreference;

invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

.line 179
const-string v4, "time"

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

move-result-object v4

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mTimePref:Landroid/preference/Preference;

.line 180
const-string v4, "24 hour"

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

move-result-object v4

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

.line 181
const-string v4, "timezone"

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

move-result-object v4

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mTimeZone:Landroid/preference/Preference;

.line 182
const-string v4, "date"

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

move-result-object v4

iput-object v4, p0, Lcom/android/settings/DateTimeSettings;->mDatePref:Landroid/preference/Preference;

.line 183
const-string v4, "date_format"

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

move-result-object v4

check-cast v4, Landroid/preference/ListPreference;

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

.line 184
if-eqz v3, :cond_3

.line 185
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

move-result-object v4

iget-object v7, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

invoke-virtual {v4, v7}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

.line 186
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

move-result-object v4

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

invoke-virtual {v4, v7}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

.line 189
:cond_3
invoke-virtual {p0}, Lcom/android/settings/DateTimeSettings;->updateDateFormatEntries()V

.line 192
iget-object v7, p0, Lcom/android/settings/DateTimeSettings;->mTimePref:Landroid/preference/Preference;

if-nez v0, :cond_6

move v4, v5

:goto_0
invoke-virtual {v7, v4}, Landroid/preference/Preference;->setEnabled(Z)V

.line 193
iget-object v7, p0, Lcom/android/settings/DateTimeSettings;->mDatePref:Landroid/preference/Preference;

if-nez v0, :cond_7

move v4, v5

:goto_1
invoke-virtual {v7, v4}, Landroid/preference/Preference;->setEnabled(Z)V

.line 194
iget-object v4, p0, Lcom/android/settings/DateTimeSettings;->mTimeZone:Landroid/preference/Preference;

if-nez v1, :cond_8

:goto_2
invoke-virtual {v4, v5}, Landroid/preference/Preference;->setEnabled(Z)V

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

.line 199
const-string v6, "hide_time"

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

move-result-object v6

check-cast v6, Landroid/preference/Preference;

iput-object v6, p0, Lcom/android/settings/DateTimeSettings;->mHideTime:Landroid/preference/Preference;

const-string v6, "hide_ampm"

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

move-result-object v6

check-cast v6, Landroid/preference/Preference;

iput-object v6, p0, Lcom/android/settings/DateTimeSettings;->mHideAmPm:Landroid/preference/Preference;

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

check-cast v0, Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

if-eqz v0, :cond_4

const/4 v0, 0x0

iget-object v6, p0, Lcom/android/settings/DateTimeSettings;->mHideAmPm:Landroid/preference/Preference;

invoke-virtual {v6, v0}, Landroid/preference/Preference;->setEnabled(Z)V

iget-object v6, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

invoke-virtual {v6, v0}, Landroid/preference/Preference;->setEnabled(Z)V

:cond_4
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

check-cast v0, Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

if-eqz v0, :cond_5

const/4 v0, 0x0

iget-object v6, p0, Lcom/android/settings/DateTimeSettings;->mHideAmPm:Landroid/preference/Preference;

invoke-virtual {v6, v0}, Landroid/preference/Preference;->setEnabled(Z)V

:cond_5
return-void

:cond_6
move v4, v6

.line 192
goto :goto_0

:cond_7
move v4, v6

.line 193
goto :goto_1

:cond_8
move v5, v6

.line 194
goto :goto_2
.end method

Search this method

.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z

Replace full method with this

.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
.locals 6
.parameter "preferenceScreen"
.parameter "preference"

.prologue
const/4 v1, 0x1

.line 490
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mDatePref:Landroid/preference/Preference;

if-ne p2, v0, :cond_1

.line 491
const/4 v0, 0x0

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

.line 501
:cond_0
:goto_0
invoke-super {p0, p1, p2}, Lcom/android/settings/SettingsPreferenceFragment;->onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z

move-result v0

return v0

.line 492
:cond_1
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mTimePref:Landroid/preference/Preference;

if-ne p2, v0, :cond_2

.line 494
invoke-virtual {p0, v1}, Lcom/android/settings/DateTimeSettings;->removeDialog(I)V

.line 495
invoke-virtual {p0, v1}, Lcom/android/settings/DateTimeSettings;->showDialog(I)V

goto :goto_0

.line 496
:cond_2
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

if-ne p2, v0, :cond_4

.line 497
iget-object v0, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

check-cast v0, Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

invoke-direct {p0, v0}, Lcom/android/settings/DateTimeSettings;->set24Hour(Z)V

iget-object v1, p0, Lcom/android/settings/DateTimeSettings;->mHideAmPm:Landroid/preference/Preference;

if-nez v0, :cond_3

const/4 v0, 0x1

goto :goto_1

:cond_3
const/4 v0, 0x0

:goto_1
invoke-virtual {v1, v0}, Landroid/preference/Preference;->setEnabled(Z)V

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

move-result-object v0

invoke-virtual {p0, v0}, Lcom/android/settings/DateTimeSettings;->updateTimeAndDateDisplay(Landroid/content/Context;)V

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

goto :goto_0

:cond_4
const-string v3, "hide_ampm"

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

if-ne p2, v0, :cond_5

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

check-cast v0, Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v2

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

move-result-object v3

const-string v4, "hide_ampm"

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

goto :goto_2

:cond_5
const-string v3, "hide_time"

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

if-ne p2, v0, :cond_0

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

check-cast v0, Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v2

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

move-result-object v3

const-string v4, "hide_time"

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

if-nez v2, :cond_6

const/4 v2, 0x1

goto :goto_3

:cond_6
const/4 v2, 0x0

:goto_3
iget-object v1, p0, Lcom/android/settings/DateTimeSettings;->mHideAmPm:Landroid/preference/Preference;

invoke-virtual {v1, v2}, Landroid/preference/Preference;->setEnabled(Z)V

iget-object v1, p0, Lcom/android/settings/DateTimeSettings;->mTime24Pref:Landroid/preference/Preference;

invoke-virtual {v1, v2}, Landroid/preference/Preference;->setEnabled(Z)V

goto :goto_2
.end method

Save it.

Now open res/xm/Date_Time_Prefs.xml

Add blue lines

<?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" />
<CheckBoxPreference android:title="@string/zone_auto" android:key="auto_zone" android:summaryOn="@string/zone_auto_summaryOn" android:summaryOff="@string/zone_auto_summaryOff" />
[COLOR="blue"]<CheckBoxPreference android:title="@string/disable_time" android:key="hide_time" android:summary="@string/disable_time_text" />
<CheckBoxPreference android:title="@string/disable_ampm" android:key="hide_ampm" android:summary="@string/disable_ampm_text" />[/COLOR]
<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" />
<ListPreference android:title="@string/date_time_date_format" android:key="date_format" android:summary="mm/dd/yyyy" android:widgetLayout="@layout/round_more_icon" />
</PreferenceScreen>

Save it.

Open res/values/strings.xml

Add these lines at the end

<string name="disable_time">Hide time</string>
<string name="disable_time_text">Remove time from status bar</string>
<string name="disable_ampm">Hide AM/PM</string>
<string name="disable_ampm_text">Remove AM/PM from time in status bar</string>

Save it and recompile SecSettings.apk

Conitnue to next Post