[MOD][GUIDE] 4.2 LockScreen Clock for 4.0+

Search This thread

akash akya

Senior Member
May 14, 2012
734
1,307
Bangalore
trickytipss.blogspot.in
after reading many ICS+ users requests, they want 4.2 lock screen clock.. here it is :eek:

Screenshot_2013-07-31-21-23-02.png


Things Needed:
* smali & baksmali
* Text Editor
* Your device framework.jar

Step 1 : in lockscreen digital clock, there are actually 2 clock views overlapping one another...
java source :
Code:
CharSequence newTime = DateFormat.format(mFormat, mCalendar);
        mTimeDisplayBackground.setText(newTime);
        mTimeDisplayForeground.setText(newTime);
        mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
and
Code:
 private static final String SYSTEM_FONT_TIME_BACKGROUND = SYSTEM + "AndroidClock.ttf";
    private static final String SYSTEM_FONT_TIME_FOREGROUND = SYSTEM + "AndroidClock_Highlight.ttf";

so we just have to use both views to get what we wanted, to do so follow steps,
decompile framework.jar goto : com\android\internal\widget\ , open DigitalClock.smali with a text editor..
search for :
Code:
Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

you will see these lines :
Code:
iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayBackground:Landroid/widget/TextView;

    invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayForeground:Landroid/widget/TextView;

    invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

Step 2: below this,
Code:
iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayBackground:Landroid/widget/TextView;

    invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
add these lines :
Code:
new-instance v2, Ljava/text/SimpleDateFormat;

    const-string v3, "h"

    sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;

    invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V

    iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;

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

    move-result-object v3

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

    move-result-object v1

so now we just used second clock view which is add to android at API level 11 (Honeycomb).. but not used after ICS... :p

Step 3 : last step, by default as i said second clock view visibility is turned off
java source :
Code:
         mTimeDisplayBackground = (TextView) findViewById(R.id.timeDisplayBackground);
        mTimeDisplayBackground.setTypeface(sBackgroundFont);
        mTimeDisplayBackground.setVisibility(View.[COLOR="Red"]INVISIBLE[/COLOR]);

to do so delete this line :
Code:
    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setVisibility(I)V

Step 4 : download font in attachments push them to system\fonts\

Step 5 : Save all changes and compile flash/push/do whateva :p


for those who want to know what is happening study modified AOSP DigitalClock source in attachment (unmodified),
 

Attachments

  • fonts.rar
    4.6 KB · Views: 416
  • DigitalClock.txt
    8.1 KB · Views: 397
Last edited:

Cute Idiot

Member
Jul 19, 2012
31
15
after this mod the lockscreen handle goes below its original position
is there any way to get it back to its original position???:confused:
Help would be appreciated ;)
 

akash akya

Senior Member
May 14, 2012
734
1,307
Bangalore
trickytipss.blogspot.in
Here's mine. Seems like the 2 fonts overlapped with each other.

bro you surly missed here :
Code:
new-instance v2, Ljava/text/SimpleDateFormat;

    const-string v3, [COLOR="Red"]"h"[/COLOR]

    sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;

    invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V

    iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;

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

also give me your keygaurd_unlock_xxx.xml.. just a little correction is there...
 
  • Like
Reactions: joeyhuab

joeyhuab

Recognized Developer
bro you surly missed here :
Code:
new-instance v2, Ljava/text/SimpleDateFormat;

    const-string v3, [COLOR="Red"]"h"[/COLOR]

    sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;

    invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V

    iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;

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

also give me your keygaurd_unlock_xxx.xml.. just a little correction is there...

Nah, I'm sure I copied everything. Here's my files, kindly check them out, thanks!
 

Attachments

  • keyguard_screen_xxx.rar
    12 KB · Views: 60
Last edited:

joeyhuab

Recognized Developer
bro you surly missed here :
Code:
new-instance v2, Ljava/text/SimpleDateFormat;

    const-string v3, [COLOR="Red"]"h"[/COLOR]

    sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;

    invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V

    iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;

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

also give me your keygaurd_unlock_xxx.xml.. just a little correction is there...

give me DigitalClock.smali also.. i will check once..

Here you go, this is my DigitalClock.smali from my Stock framework.jar
 

Attachments

  • DigitalClock.rar
    2.3 KB · Views: 32

akash akya

Senior Member
May 14, 2012
734
1,307
Bangalore
trickytipss.blogspot.in
Although there's something with the hours that doesn't feel right, this one works like a charm! THANKS A LOT!

change red code in your keygaurd_screen _tab_unlock.xml
Code:
    <com.android.internal.widget.DigitalClock [COLOR="Red"]android:layout_gravity="left"[/COLOR] android:id="@id/time" android:layout_marginTop="@dimen/keyguard_lockscreen_status_line_clockfont_top_margin" [COLOR="Blue"]android:layout_marginRight="@dimen/keyguard_lockscreen_status_line_font_right_margin"[/COLOR] android:layout_marginBottom="12.0dip">
        <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_background" android:ellipsize="none" android:id="@id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" />
        <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_foreground" android:ellipsize="none" android:id="@id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" android:layout_alignLeft="@id/timeDisplayBackground" android:layout_alignTop="@id/timeDisplayBackground" />
        <TextView android:textSize="14.0sp" android:textColor="@color/lockscreen_clock_foreground" android:ellipsize="none" android:id="@id/am_pm" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8.0dip" android:layout_marginTop="18.0dip" android:singleLine="true" android:layout_toRightOf="@id/timeDisplayForeground" android:layout_alignBottom="@id/timeDisplayForeground" />
    </com.android.internal.widget.DigitalClock>

if it looks odd, then tune blue code....
 
  • Like
Reactions: joeyhuab

joeyhuab

Recognized Developer
change red code in your keygaurd_screen _tab_unlock.xml
Code:
    <com.android.internal.widget.DigitalClock [COLOR="Red"]android:layout_gravity="left"[/COLOR] android:id="@id/time" android:layout_marginTop="@dimen/keyguard_lockscreen_status_line_clockfont_top_margin" [COLOR="Blue"]android:layout_marginRight="@dimen/keyguard_lockscreen_status_line_font_right_margin"[/COLOR] android:layout_marginBottom="12.0dip">
        <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_background" android:ellipsize="none" android:id="@id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" />
        <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_foreground" android:ellipsize="none" android:id="@id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" android:layout_alignLeft="@id/timeDisplayBackground" android:layout_alignTop="@id/timeDisplayBackground" />
        <TextView android:textSize="14.0sp" android:textColor="@color/lockscreen_clock_foreground" android:ellipsize="none" android:id="@id/am_pm" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8.0dip" android:layout_marginTop="18.0dip" android:singleLine="true" android:layout_toRightOf="@id/timeDisplayForeground" android:layout_alignBottom="@id/timeDisplayForeground" />
    </com.android.internal.widget.DigitalClock>

if it looks odd, then tune blue code....

LOL THIS happened when I did that. :)) No worries, I'll just put it back to the old format, it looks good anyways! THANKS A LOT! :victory:
 

Attachments

  • Screenshot_2013-08-04-23-52-06.jpg
    Screenshot_2013-08-04-23-52-06.jpg
    19.6 KB · Views: 258
  • Screenshot_2013-08-04-21-36-08.jpg
    Screenshot_2013-08-04-21-36-08.jpg
    20.6 KB · Views: 278

akash akya

Senior Member
May 14, 2012
734
1,307
Bangalore
trickytipss.blogspot.in
LOL THIS happened when I did that. :)) No worries, I'll just put it back to the old format, it looks good anyways! THANKS A LOT! :victory:

oops missed this :silly:
Code:
 <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_background" android:ellipsize="none" [COLOR="Red"]android:layout_gravity="center" [/COLOR]android:id="@id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" />
            <TextView android:textAppearance="?textAppearanceMedium" android:textSize="@dimen/keyguard_lockscreen_clock_font_size" android:textColor="@color/lockscreen_clock_foreground" android:ellipsize="none" [COLOR="red"]android:layout_gravity="center" [/COLOR]android:id="@id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6.0dip" android:singleLine="true" android:layout_alignLeft="@id/timeDisplayBackground" android:layout_alignTop="@id/timeDisplayBackground" />

and as i said you have to tune left margin for cleaner look...
 
  • Like
Reactions: joeyhuab

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    after reading many ICS+ users requests, they want 4.2 lock screen clock.. here it is :eek:

    Screenshot_2013-07-31-21-23-02.png


    Things Needed:
    * smali & baksmali
    * Text Editor
    * Your device framework.jar

    Step 1 : in lockscreen digital clock, there are actually 2 clock views overlapping one another...
    java source :
    Code:
    CharSequence newTime = DateFormat.format(mFormat, mCalendar);
            mTimeDisplayBackground.setText(newTime);
            mTimeDisplayForeground.setText(newTime);
            mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
    and
    Code:
     private static final String SYSTEM_FONT_TIME_BACKGROUND = SYSTEM + "AndroidClock.ttf";
        private static final String SYSTEM_FONT_TIME_FOREGROUND = SYSTEM + "AndroidClock_Highlight.ttf";

    so we just have to use both views to get what we wanted, to do so follow steps,
    decompile framework.jar goto : com\android\internal\widget\ , open DigitalClock.smali with a text editor..
    search for :
    Code:
    Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    you will see these lines :
    Code:
    iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayBackground:Landroid/widget/TextView;
    
        invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
    
        iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayForeground:Landroid/widget/TextView;
    
        invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    Step 2: below this,
    Code:
    iget-object v2, p0, Lcom/android/internal/widget/DigitalClock;->mTimeDisplayBackground:Landroid/widget/TextView;
    
        invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
    add these lines :
    Code:
    new-instance v2, Ljava/text/SimpleDateFormat;
    
        const-string v3, "h"
    
        sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;
    
        invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V
    
        iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;
    
        invoke-virtual {v3}, Ljava/util/Calendar;->getTime()Ljava/util/Date;
    
        move-result-object v3
    
        invoke-virtual {v2, v3}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
    
        move-result-object v1

    so now we just used second clock view which is add to android at API level 11 (Honeycomb).. but not used after ICS... :p

    Step 3 : last step, by default as i said second clock view visibility is turned off
    java source :
    Code:
             mTimeDisplayBackground = (TextView) findViewById(R.id.timeDisplayBackground);
            mTimeDisplayBackground.setTypeface(sBackgroundFont);
            mTimeDisplayBackground.setVisibility(View.[COLOR="Red"]INVISIBLE[/COLOR]);

    to do so delete this line :
    Code:
        invoke-virtual {v0, v1}, Landroid/widget/TextView;->setVisibility(I)V

    Step 4 : download font in attachments push them to system\fonts\

    Step 5 : Save all changes and compile flash/push/do whateva :p


    for those who want to know what is happening study modified AOSP DigitalClock source in attachment (unmodified),
    2
    Credits :
    * Android for source
    * jesusfreke for smali & baksmali Tools
    1
    ask any dev in a110 fourms... @BOND1987 @Akhilendra1711 or @khan_frd2002 can do this for you... its easy....
    @akash akya I will do after competing the 4.2 Quick panel
    1
    Here's mine. Seems like the 2 fonts overlapped with each other.

    bro you surly missed here :
    Code:
    new-instance v2, Ljava/text/SimpleDateFormat;
    
        const-string v3, [COLOR="Red"]"h"[/COLOR]
    
        sget-object v4, Ljava/util/Locale;->ENGLISH:Ljava/util/Locale;
    
        invoke-direct {v2, v3, v4}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V
    
        iget-object v3, p0, Lcom/android/internal/widget/DigitalClock;->mCalendar:Ljava/util/Calendar;
    
        invoke-virtual {v3}, Ljava/util/Calendar;->getTime()Ljava/util/Date;

    also give me your keygaurd_unlock_xxx.xml.. just a little correction is there...
    1
    Here you go, this is my DigitalClock.smali from my Stock framework.jar

    try this one...
    http://www.mediafire.com/?cm6dza6nepkbxjt