[Sony Cross-Device Development Themes and Apps] Ticklefish:
This thread made the Portal! Woo!

https://www.xda-developers.com/animated-gif-home-button-android/

(Thanks To [MENTION=5346465]Tulsadiver[/MENTION] for the above image)​

Want an animated HOME softkey in your navbar? Of course you do!

This is a relatively simple mod, which should work on any rom and any version of Android. Android P, with its gesture control navbar setup, is a different matter but I'll deal with that another time.

Follow the simple steps below to find out how to do this mod. Any problems, just let me know!

Step 1 - Decompile Your "SystemUI.apk"

The first thing you need to do is, as it says above, is to decompile your deodexed SystemUI.apk. I'm not going to tell you how to do that here, because there are already a lot of tutorials and guides for that on xda. There's also a lot of decompiling tools you can use. I personally recommend using Tickle My Android([url]https://xdaforums.com/showthread.php?t=1633333[/URL]). It's fast, user-friendly, makes flashable ZIP's and rumour has it that the developer is devastatingly handsome..

If your rom isn't deodexed, this rom won't work. You have to deodex it first. By a strange coincidence, Tickle My Android can deodex roms too. What a clever developer they must be! ;)

Once you've done this, move onto Step 2!

Step 2 - Add The Smali Files

Now we need to add the new smali files for this. However these aren't my files, somebody else made them so you'll need to get them from the attachment at the bottom of this post here: [url]https://xdaforums.com/android/software-hacking/dev-custom-views-t3174519[/URL]

This code was written by [MENTION=293887]Morningstar[/MENTION] and I can't take any credit for it. So you'll need to make sure you press the "Thanks" button at the bottom of his post. If you don't. this mod won't work!!

Extract the "SelfAnimatingImageView.smali" file from the ZIP and add it to your decompiled APK at "SystemUI.apk\smali\com\android\morningstar\". You'll need to make those folders if they're not there already.

Step 3 - Add The Image Files

In the second post in this thread, you'll find a few animations that I've put together for you to download. Just download the ZIP and add the PNG image files to the appropriate "drawable-?dpi" folder. Which folder you need to put them into depends on your particular phone.

If you don't like any of the animations on offer, you can make your own. All I've done is use Google Image Search to find some fun GIF's and online tools like EZGIF ([url]https://ezgif.com/split[/URL]) to turn the GIF into a collection of individual images.

Of course, you could always make your own images if you wanted..but I don't have the artistic ability for that!

If you are using your own animation, make sure you add the "transparent.png" file to your "drawable-?dpi" folder anyway. You'll need it in Step 5..

Step 4 - Edit The Drawable XML File

In the previous step, you put a collection of images into your decompiled APK to serve as your animation. Now you need an XML file that tells Android which files to use for your animation, as well as how quickly to cycle through them.

For this, go back to the ZIP you downloaded and copy the "frame_anim.xml" to your "res\drawable" folder. If you're using your own PNG files, you can still use this file or make your own.

The "frame_anim.xml" looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="[url]http://schemas.android.com/apk/res/android">[/url]
<item android:duration="100" android:drawable="@drawable/frame_0" />
<item android:duration="100" android:drawable="@drawable/frame_1" />
<item android:duration="100" android:drawable="@drawable/frame_2" />
<item android:duration="100" android:drawable="@drawable/frame_3" />
</animation-list>

Each "item" line represents a different image. The "android:drawable" bit contains the name of the image being displayed the "android:duration" bit says how many milliseconds it's on display for."

If you're using your own animation, just add/delete/edit these lines as you need.

Don't forget to save when you're done!

Step 5 - Edit The Layout XML

We're nearly there, I promise! Just this one step left to do and we can start recompiling. This is the tricky one though - this is the part where we actually put our animation into the navbar, replacing the image for the HOME softkey.

What makes this extra difficult is that Google keep changing where the code we need to change is. In most roms, you'll find the code that controls the HOME softkey in "layout\navigation_bar.xml". In some modern roms, it might actually be in "layout\home.xml"!

So you'll need to do some detective work. You need to find which layout XML file contains a line that looks like this:

<com.android.systemui.statusbar.policy.KeyButtonView android:layout_gravity="center" android:id="@id/home_button" android:layout_width="0.0dip" android:layout_height="0.0dip" android:scaleType="center" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" />

Let me rearrange that to make it a bit easier to read..

<com.android.systemui.statusbar.policy.KeyButtonView
android:layout_gravity="center"
android:id="@id/home_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:contentDescription="@string/accessibility_home"
systemui:keyCode="3" />

See those references to "home" and that bit about "systemui:keyCode="3""? This is the line of code that displays the HOME softkey. Your code might not look exactly like that but it'll be close.

We can't make this display an animation, Android just isn't set up for it. So what we actually need to do is hide this HOME softkey, put a new one in the same place that's the same size but invisble, then put our animation underneath that. Sounds complicated, but all we need is a FrameLayout..

<FrameLayout android:layout_width="@dimen/navigation_key_width" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.KeyButtonView android:layout_gravity="center" android:layout_width="@dimen/navigation_key_width" android:layout_height="fill_parent" android:src="@drawable/transparent" android:scaleType="center" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" />
<com.android.systemui.statusbar.policy.KeyButtonView android:layout_gravity="center" android:id="@id/home_button" android:layout_width="0.0dip" android:layout_height="0.0dip" android:scaleType="center" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" />
<com.android.morningstar.SelfAnimatingImageView android:layout_gravity="center" android:id="@+id/frame_animation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/frame_anim" />
</FrameLayout>

Take a moment to look at that above code. You can see how three different things are piled on top of each other. When the app is running, you won't see that. All you'll see is your animated image where your HOME softkey is. Neat, no?

(For more about FrameLayouts and other XML tricks, you could do worse than check out my short guide here: [url]https://xdaforums.com/general/xda-university/xml-101-xml-modding-easy-t2929816[/url])

So just replace your HOME softkey line of code with the code above. You may need to make some changes for your particular setup. Every rom is different.

Save and move onto the next step.

Step 6 - Recompile The Modded APK

This is it - the last stage. All you need to do now is recompile your SystemUI.apk file and put it back to your phone.

I recommend doing this in recovery as you'll need to wipe the Dalvik cache, otherwise the new smali won't be active.

I also recommend doing it in recovery because I always recommend DOING A BACKUP FIRST!!

Once you've done the above steps, you should now have an animated HOME softkey in your navbar. But, if you have any problems, just let me know and I'll see what I can do to help.