[One (M8) Themes and Apps] fisha21:
What are the Sense 6 themes?​

This is the easy bit! If you open Settings/Personalise/Theme, you'll be presented with the four built-in themes:

Where are the Sense 6 themes?​

This is where things get complicated.

There are four themes, each of which is split into five categories. The themes are called:

The system wide theme is controlled by hex colour codes located in colors.xml and styles.xml of com.htc.resources. This controls the majority of system apps.

If you look at com.htc.resources.apk/styles.xml line 2047 for example, you'll see that there are entries called:

etc, starting from line 2047

Categories 1-4 are represented by the four boxes along the top of the theme preview. The fifth category is defined by HTC within apks as Category 0, and this is the default category. It is used when the code within the apk doesn't specify which category to use (more on this later). With the default theme, you'll probably have noticed that various HTC apps have different coloured header bars, which correspond to the four boxes on the preview image:

So if you wanted to change the colour of the dialer, you'd edit the colour codes for HtcDeviceDefault.CategoryOne. If you were using the second theme, the orange one, you'd edit ThemeOne.CategoryOne to change dialer header, and so on...

I've managed to track down which category each HTC app uses, but if there are any I'm missing, please let me know

Category 0

HTC Backup

Internet

Settings

Setup

Tips & Help

Scribble

All apps launched while in Car mode

Category 1

Calendar

Contacts

Mail

Message

Tasks

Phone

Category 2

Calculator

Clock

Stocks

Voice recorder

Weather

Category 3

Camera

FM radio

Music

Category 4

Didn't actually find any apps that seemed to use this category

All of these apps use the specified category from com.htc.resources, so that's where you should edit it. There are some HTC apps that have seem to have their own internal themes:

Prism.apk

HMS_Gallery.apk

HTC-IME.apk

Video_Center.apk

HtcExtremePowerSaverLauncher.apk

EasyAccessService.apk

so they have their own specified themes and categories within the colors and styles.xml of their own apk. There may be other apks as well, I just haven't spotted them yet. They read the system flag to determine which Theme to use, but then use their own categories for various elements within the app.

So Prism for example will set the overall Theme according to what's been set in the Theme picker but then will use its own internal categories. From my testing so far, all aspects of Prism (app drawer header, Blinkfeed, app drawer icon overlay) seem to use Category 4 colours from within Prism.apk. Haven't looked into any of the other apps listed above!
​

How are the Sense 6 themes used?​

So, which theme the system is using is determined by you, via the Theme Picker. As for which category an app uses, that is determined within the java code - thanks to [MENTION=5386198]Mikanoshi[/MENTION] for some more detailed info

Still not sure where the current theme flag is set, so that the other themed apps (Gallery, Prism etc) know which theme to use. I'm guessing framework2.jar or framework3.jar, though I guess it doesn't really matter!

As for the preview images, these are generated the first time the theme picker is opened, and then cached in /data/data/com.htc.home.personalize/files/themePreview/ - again, thanks to [MENTION=5386198]Mikanoshi[/MENTION] for more detailed info. The colour bar across the top of the previw image is the multiply_color from categories 1-4 of that theme.

If you want the Theme picker screen to show your edited themes, rather than the default ones, you'll need to delete these cached images. This can be done by full wiping, but obviously not so convenient. The other option is to add the following line

delete_recursive("/data/data/com.htc.home.personalize/files/themePreview");

somewhere in the updater-script of your rom/theme zip.​

How to add a new theme​

The four built in themes offer a great way to offer multiple variations of your theme. But what if 4 options aren't enough? Why not add a 5th?

To add your own theme, it's probably easiest to start with com.htc.resources as this requires the most edits. The two folders you'll need to focus on are drawable and values.

In values/styles.xml, the easiest thing to do will be to duplicate the whole block of Theme.Three entries, rename them all to Theme.Four and change the colours as you want them. You'll also need to duplicate all the htcprogress_themethree_*.xmls in the drawable folder, rename them to themefour and edit the colours,

The last step is to edit values/arrays.xmls. This will register your new theme as a usable resource. You need to

add your new theme to the multipleColorThemes array - this tells the system that ThemeFour now exists

add a new ThemeFourarray, which lists the 5 categories -

add a 5th entry to the wallpapersand wallpaper_themesarrays - this will set the default wallpaper for your theme (you can also edit this array if you want our default wallpapers to have a different filename or file type)

create new progressBarArrayarrays for ThemeFour and the four categories

If in doubt, just look for all the ThemeThree stuff, duplicate it and rename to ThemeFour. That's com.htc.resources done. Now you just need to add the ThemeFour stuff to the other 6 apps that use the theme system (see previous list). In each apk, you need to edit arrays.xml, add all the new htcprogress_themefour_*.xmls to the drawable folder, and the new ThemeFour stuff to styles.xml. If you don't add ThemeFour to an app, if you've applied your theme centrally and then open that app, the app will default to the stock green theme.

And that's it! Wipe the theme preview cache as previously mentioned, and your theme will show up nicely. Not sure if there is a limit to the number of new themes that can be added...maybe it just depends on how bored you get :D

There is one small issue that remains. As previously mentioned, the colour bar across the top of the preview is generated by the multiply_color entries of categories 1-4. However, for your new theme, you'll note that the colour bar remains green. Since the themes always revert to the green one when there is missing info relating to the new theme, I suspect there must be a smali array somewhere where the themes are also registered. Since the new theme is not declared there, the preview generator doesn't know to look for ThemeFour.

It is the only remaining bug, but it does annoy me! So if anyone finds where in smali these preview colours are generated, please do let me know!!​

Well, that's all for now. Apologies for the slightly wordy post, a consequence of me thinking out loud. I will say one more thing though. When Sense 6 first landed, I was not a fan of these new themes at all. But having spent time exploring and getting to know how they work, I actually really like them now. Overall, theming Sense 6 requires less smali edits than Sense 5/5.5 did, and the theme picker aspect is actually quite powerful....how else could you offer 4 variants of a theme so easily. I suspect that it's better for themers like myself, who theme specific roms, than it is for standalone themers.

Happy theming!!​

Article originally posted here

How to stop the 4x1 weather clock changing colour according to time of day

In Sense 6 the 4x1 weather clock widget has a white background for daytime clocks, and dark for night clocks. Pretty neat feature, but maybe it doesn't fit with a theme you're making?

If you open

HtcWeatherClockWidget.apk/smali/com/htc/widget/weatherclock/view/WeatherClock4x1View.smali

and search for

.method protected getControls

Scroll down and you'll see

const-string v2, "background_day"

const v3, 0x7f02004d

The 0x7f02004d is the public id for common_panel_light.9.png in the drawable-xxhdpi folder. Scroll a bit further down and you'll see

const-string v2, "background_night"

const v3, 0x2080100

The 0x2080100 is the public id for common_panel.9.png in com.htc.resources. If you want to use the same image for both day and night clocks, just replace 0x2080100 with 0x7f02004d, and the clock will use the common_panel_light.9.png image for both day and night clocks. Just theme that image how you want it to look, recompile and you're done :)