[Verizon Samsung Galaxy S III] Didact74:
[MOD] [Guide] Time and AM/PM Toggle

Time and AM/PM Toggle​

ORIGINALTHREAD​

Here is a time and am/pm toggle.

As always feel free to use these MODs with your ROM but since it took a few days to get this coded correctly just give me some thanks and some credit in your thread please.

[Q] What does this MOD do?

[A] It allows you to toggle off the TIME, the AM/PM, or both with toggles located in settings/date/time options

Here are the goodies.....

We will be working with two files.

-SecSettings

-SystemUI.apk

As always, I will assume you know how to compile/decompile so I will not be providing information how to do that.

Lets begin with SystemUI

Navigate to smali/com/android/systemui/statusbar/policy/clock.smali

This part is optional. This will make your AM/PM small or lowercase.

Find the following code

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
.locals 3
.parameter "context"
.parameter "attrs"
.parameter "defStyle"

.prologue
const/4 v2, [B]0x1 = small am/pm
0x0 = regular size am/pm[/B]

Find the following code

.method private final getSmallTime()Ljava/lang/CharSequence;

Replace the entire method with the following code

.method private final getSmallTime()Ljava/lang/CharSequence;
.locals 22

.prologue
.line 227
invoke-virtual/range {p0 .. p0}, Lcom/android/systemui/statusbar/policy/Clock;->getContext()Landroid/content/Context;

move-result-object v8

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

move-result-object v2

const-string v7, "hide_time"

const/4 v0, 0x0

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

move-result v7

const/4 v0, 0x0

if-eqz v7, :cond_0

const/16 v0, 0x8

:cond_0
const v1,[B][COLOR="red"] 0x7f0d003d
[/COLOR][/B]
move-object/from16 v2, p0

invoke-virtual {v2, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v1

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

invoke-static {v8}, Landroid/text/format/DateFormat;->is24HourFormat(Landroid/content/Context;)Z

move-result v6

.line 234
.local v6, b24:Z
if-eqz v6, :cond_5

.line 235
const v16, 0x10400a3

.line 249
.local v16, res:I
:goto_0
const v2, 0xef00

.line 250
.local v2, MAGIC1:C
const v3, 0xef01

.line 253
.local v3, MAGIC2:C
move/from16 v0, v16

invoke-virtual {v8, v0}, Landroid/content/Context;->getString(I)Ljava/lang/String;

move-result-object v9

if-nez v6, :cond_1

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

move-result-object v2

const-string v3, "hide_ampm"

const/4 v0, 0x0

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

move-result v7

const-string v0, "ampm"

new-instance v1, Ljava/lang/StringBuilder;

invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

const-string v2, "getint returned="

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v1

invoke-virtual {v1, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

move-result-object v1

invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v1

invoke-static {v0, v1}, Landroid/util/Slog;->i(Ljava/lang/String;Ljava/lang/String;)I

move v2, v7

if-eqz v2, :cond_1

const-string v9, "h:mm"

:cond_1

move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->mClockFormatString:Ljava/lang/String;

move-object/from16 v20, v0

move-object/from16 v0, v20

invoke-virtual {v9, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v20

if-eqz v20, :cond_2

if-nez v6, :cond_a

move-object/from16 v0, p0

iget-boolean v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->mLocaleChanged:Z

move/from16 v20, v0

if-eqz v20, :cond_a

.line 257
:cond_2

const/16 v20, 0x0

move/from16 v0, v20

move-object/from16 v1, p0

iput-boolean v0, v1, Lcom/android/systemui/statusbar/policy/Clock;->mLocaleChanged:Z

.line 264
move-object/from16 v0, p0

iget v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->AM_PM_STYLE:I

move/from16 v20, v0

if-eqz v20, :cond_9

.line 265
const/4 v4, -0x1

.line 266
.local v4, a:I
const/4 v15, 0x0

.line 267
.local v15, quoted:Z
const/4 v11, 0x0

.local v11, i:I
:goto_1
invoke-virtual {v9}, Ljava/lang/String;->length()I

move-result v20

move/from16 v0, v20

if-ge v11, v0, :cond_4

.line 268
invoke-virtual {v9, v11}, Ljava/lang/String;->charAt(I)C

move-result v7

.line 270
.local v7, c:C
const/16 v20, 0x27

move/from16 v0, v20

if-ne v7, v0, :cond_3

.line 271
if-nez v15, :cond_6

const/4 v15, 0x1

.line 273
:cond_3

:goto_2
if-nez v15, :cond_7

const/16 v20, 0x61

move/from16 v0, v20

if-ne v7, v0, :cond_7

.line 274
move v4, v11

.line 279
.end local v7 #c:C
:cond_4

if-ltz v4, :cond_9

.line 281
move v5, v4

.line 282
.local v5, b:I
:goto_3
if-lez v4, :cond_8

add-int/lit8 v20, v4, -0x1

move/from16 v0, v20

invoke-virtual {v9, v0}, Ljava/lang/String;->charAt(I)C

move-result v20

invoke-static/range {v20 .. v20}, Ljava/lang/Character;->isWhitespace(C)Z

move-result v20

if-eqz v20, :cond_8

.line 283
add-int/lit8 v4, v4, -0x1

goto :goto_3

.line 237
.end local v2 #MAGIC1:C
.end local v3 #MAGIC2:C
.end local v4 #a:I
.end local v5 #b:I
.end local v9
.end local v11 #i:I
.end local v15 #quoted:Z
.end local v16 #res:I
:cond_5

const v16, 0x10400a2

.restart local v16 #res:I
goto/16 :goto_0

.line 271
.restart local v2 #MAGIC1:C
.restart local v3 #MAGIC2:C
.restart local v4 #a:I
.restart local v7 #c:C
.restart local v9
.restart local v11 #i:I
.restart local v15 #quoted:Z
:cond_6

const/4 v15, 0x0

goto :goto_2

.line 267
:cond_7

add-int/lit8 v11, v11, 0x1

goto :goto_1

.line 285
.end local v7 #c:C
.restart local v5 #b:I
:cond_8

new-instance v20, Ljava/lang/StringBuilder;

invoke-direct/range {v20 .. v20}, Ljava/lang/StringBuilder;-><init>()V

const/16 v21, 0x0

move/from16 v0, v21

invoke-virtual {v9, v0, v4}, Ljava/lang/String;->substring(II)Ljava/lang/String;

move-result-object v21

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v20

const v21, 0xef00

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

move-result-object v20

invoke-virtual {v9, v4, v5}, Ljava/lang/String;->substring(II)Ljava/lang/String;

move-result-object v21

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v20

const-string v21, "a"

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v20

const v21, 0xef01

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

move-result-object v20

add-int/lit8 v21, v5, 0x1

move/from16 v0, v21

invoke-virtual {v9, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

move-result-object v21

invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v20

invoke-virtual/range {v20 .. v20}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v9

.line 290
.end local v4 #a:I
.end local v5 #b:I
.end local v11 #i:I
.end local v15 #quoted:Z
:cond_9

new-instance v18, Ljava/text/SimpleDateFormat;

move-object/from16 v0, v18

invoke-direct {v0, v9}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

.local v18, sdf:Ljava/text/SimpleDateFormat;
move-object/from16 v0, v18

move-object/from16 v1, p0

iput-object v0, v1, Lcom/android/systemui/statusbar/policy/Clock;->mClockFormat:Ljava/text/SimpleDateFormat;

.line 291
move-object/from16 v0, p0

iput-object v9, v0, Lcom/android/systemui/statusbar/policy/Clock;->mClockFormatString:Ljava/lang/String;

.line 295
:goto_4
move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->mCalendar:Ljava/util/Calendar;

move-object/from16 v20, v0

invoke-virtual/range {v20 .. v20}, Ljava/util/Calendar;->getTime()Ljava/util/Date;

move-result-object v20

move-object/from16 v0, v18

move-object/from16 v1, v20

invoke-virtual {v0, v1}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;

move-result-object v17

.line 297
.local v17, result:Ljava/lang/String;
move-object/from16 v0, p0

iget v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->AM_PM_STYLE:I

move/from16 v20, v0

if-eqz v20, :cond_f

.line 298
const v20, 0xef00

move-object/from16 v0, v17

move/from16 v1, v20

invoke-virtual {v0, v1}, Ljava/lang/String;->indexOf(I)I

move-result v12

.line 299
.local v12, magic1:I
const v20, 0xef01

move-object/from16 v0, v17

move/from16 v1, v20

invoke-virtual {v0, v1}, Ljava/lang/String;->indexOf(I)I

move-result v13

.line 300
.local v13, magic2:I
if-ltz v12, :cond_f

if-le v13, v12, :cond_f

.line 301
new-instance v10, Landroid/text/SpannableStringBuilder;

move-object/from16 v0, v17

invoke-direct {v10, v0}, Landroid/text/SpannableStringBuilder;-><init>(Ljava/lang/CharSequence;)V

.line 302
.local v10, formatted:Landroid/text/SpannableStringBuilder;
move-object/from16 v0, p0

iget v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->AM_PM_STYLE:I

move/from16 v20, v0

const/16 v21, 0x2

move/from16 v0, v20

move/from16 v1, v21

if-ne v0, v1, :cond_b

.line 303
add-int/lit8 v20, v13, 0x1

move/from16 v0, v20

invoke-virtual {v10, v12, v0}, Landroid/text/SpannableStringBuilder;->delete(II)Landroid/text/SpannableStringBuilder;

.line 324
.end local v10 #formatted:Landroid/text/SpannableStringBuilder;
.end local v12 #magic1:I
.end local v13 #magic2:I
:goto_5
return-object v10

.line 293
.end local v17 #result:Ljava/lang/String;
.end local v18 #sdf:Ljava/text/SimpleDateFormat;
:cond_a

move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->mClockFormat:Ljava/text/SimpleDateFormat;

move-object/from16 v18, v0

goto :goto_4

:cond_b

move-object/from16 v0, p0

iget v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->AM_PM_STYLE:I

move/from16 v20, v0

const/16 v21, 0x1

move/from16 v0, v20

move/from16 v1, v21

if-ne v0, v1, :cond_e

.line 307
const v14, 0x3f333333

sget-boolean v20, Lcom/android/systemui/statusbar/BaseStatusBar;->useTouchWizGUI:Z

if-eqz v20, :cond_d

sget-boolean v20, Lcom/android/systemui/statusbar/BaseStatusBar;->canStatusBarHide:Z

if-eqz v20, :cond_c

move-object/from16 v0, p0

iget-boolean v0, v0, Lcom/android/systemui/statusbar/policy/Clock;->mExpandedHeader:Z

move/from16 v20, v0

if-eqz v20, :cond_d

.line 309
:cond_c

const/high16 v14, 0x3f00

.line 312
:cond_d

new-instance v19, Landroid/text/style/RelativeSizeSpan;

move-object/from16 v0, v19

invoke-direct {v0, v14}, Landroid/text/style/RelativeSizeSpan;-><init>(F)V

.line 314
.local v19, style:Landroid/text/style/CharacterStyle;
const/16 v20, 0x22

move-object/from16 v0, v19

move/from16 v1, v20

invoke-virtual {v10, v0, v12, v13, v1}, Landroid/text/SpannableStringBuilder;->setSpan(Ljava/lang/Object;III)V

.line 317
.end local v14
.end local v19 #style:Landroid/text/style/CharacterStyle;
:cond_e

add-int/lit8 v20, v13, 0x1

move/from16 v0, v20

invoke-virtual {v10, v13, v0}, Landroid/text/SpannableStringBuilder;->delete(II)Landroid/text/SpannableStringBuilder;

.line 318
add-int/lit8 v20, v12, 0x1

move/from16 v0, v20

invoke-virtual {v10, v12, v0}, Landroid/text/SpannableStringBuilder;->delete(II)Landroid/text/SpannableStringBuilder;

goto :goto_5

.end local v10 #formatted:Landroid/text/SpannableStringBuilder;
.end local v12 #magic1:I
.end local v13 #magic2:I
:cond_f

move-object/from16 v10, v17

.line 324
goto :goto_5
.end method

In the first section of code you will see an ID highlighted in RED. This is the CLOCK ID. Make sure this ID matches your CLOCK ID located in res/values/public of SystemUI

I know its a lot of code but to single out each change would take too long. Feel free to Diff out the individual changes if you want.

Navigate to smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali

Find the method "Method Public ShowClock"

Replace the entiremethod withthe following code

.method public showClock(Z)V
.locals 3
.parameter "show"

.prologue
.line 1606
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

if-nez v1, :cond_1

.line 1616
:cond_0
:goto_0
return-void

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

const v2, 0x7f0d003d

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

move-result-object v0

.line 1608
.local v0, clock:Landroid/view/View;
if-eqz v0, :cond_0

.line 1609
if-eqz p1, :cond_2

const/4 v1, 0x0

iget-object v2, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

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

move-result-object v2

const-string v3, "hide_time"

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

move-result v2

if-eqz v2, :goto_0

const/16 v1, 0x8

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

.line 1612
sget-boolean v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->useTouchWizGUI:Z

if-eqz v1, :cond_0

sget-boolean v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->alwaysShowMenuKey:Z

if-eqz v1, :cond_0

.line 1613
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mNavigationBarView:Lcom/android/systemui/statusbar/phone/NavigationBarView;

invoke-virtual {v1, p1}, Lcom/android/systemui/statusbar/phone/NavigationBarView;->setMenuButtonVisibilityForLockscreen(Z)V

goto :goto_0

.line 1609
:cond_2
const/16 v1, 0x8

goto :goto_1
.end method

Thats it for SystemUI. Compile and push to /system/app

See Post #2 for the rest of the tutorial.