Programatically update today screen image - Windows Mobile Software Development

Hi all,
First a little background into what I'm attempting...
On my PC, I have a self created program which swaps the desktop image to one selected at random from a predetermined directory. There's lots of nifty features, such as image resizing to fit desktop, support for different images on different monitors in a multi monitor setup. etc.
But enough about that, as it's not really windows mobile related. What is related is the fact i'm trying to implement something similar on my Xperia X1.
Obviously I want it so I can have different images for the today screen when it's in landscape and portrait mode - like the built in themes do. I have to admit i'm fairly miffed that this feature isn't supported nativly in a nice easy non-theme related way. it's nigh-on impossible to find an image that looks good in both aspects.
Anyway, I did have something working. A small program which creates a stwater_480_800.bmp and stwater_800_480.bmp by selecting a random image from one of two predetermined directories, and then plonking said images in the windows directory. (Replacing the two bmp images put there by the theme i was using) No resizing of images or anything fancy, just a straight file copy.
This line of code:
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 242, 0)
forces the today screen to update to the lovely new images after the files have been replaced.
All was well until I installed gtrab's excellent pure windows mobile 6.5 update (http://forum.xda-developers.com/showthread.php?t=588882). And although the app still works for the main part, i.e. it picks an image, and changes the background for the today screen, i have encountered a bug.
The image behind the updated start menu doesn't get refreshed - it stays as whatever the image was when the phone was last reset (Think it's specifically a hard reset? i.e. holding power button down the rebooting with sony ericsson logo etc).
Here's the code i'm currently using (Apologies for lack of comments, despite being employed as a vb.net programmer, i'm self taught and not commenting is a bad habit i've never gotten out of.)
Code:
Public Shared Sub SwitchBG()
Randomize()
Dim curdir As New IO.DirectoryInfo(SharedVars.LandscapeDir)
Dim imagefiles As IO.FileInfo() = curdir.GetFiles("*.bmp")
If imagefiles.Length > 0 Then
IO.File.Delete("Windows\stwater_800_480.bmp")
IO.File.Copy(imagefiles(Math.Floor(Rnd() * imagefiles.Length)).FullName, "Windows\stwater_800_480.bmp")
Else
MessageBox.Show("No Landscape Images!", "BGSwitcherPPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
curdir = New IO.DirectoryInfo(SharedVars.PortraitDir)
imagefiles = curdir.GetFiles("*.bmp")
If imagefiles.Length > 0 Then
IO.File.Delete("Windows\stwater_480_800.bmp")
IO.File.Copy(imagefiles(Math.Floor(Rnd() * imagefiles.Length)).FullName, "Windows\stwater_480_800.bmp")
Else
MessageBox.Show("No Portrait Images!", "BGSwitcherPPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 242, 0)
End Sub
I'd love to know what I have to do to force the start menu image to refresh. I've googled for a while with no joys.
Incidentally, I did discover that i can use .jpgs for the background (makes sense really). Not sure if that will have any bearing, but i'll be changing the code to accept both bmp, jpgs, and probably gifs. Can't see that it will affect my specific problem, but thought it would be worth mentioning.
Once i've got this sorted, i'll be ready to tackle the next stage, which is implementing some form of schedule so i can wake up to a new today screen image every day.
Thanks in advance to anyone with any pointers.
Matt.

Sorry, just realised I should have posted this in the windows specific forum.
Still, any help much appreciated!

Okay, I've managed to do this. Via a hacky work-around.
Basically, I realised after a bit of playing, that if you set a "normal" wallpaper, all it does is create a registry key. But, rather handily, the start menu and lock screens (lock was also affected by this bug) would see this change, and update their pic.
Also, rather handily, if you set the registry to an image that doesn't exist, the image then defaults back to the appropriate stwater
so the workaround is as follows...
Every time i run the switch code, I write an incrementing value to the HKCU\software\windows\today\wall registy value. This can be anything, providing it's not a "real image"
when you next open the start menu, it looks for this "new" image, can't find it, so loads the appropriate stwater image.
I'm gona stick the program in an Xperia forum for some feedback/suggestions.
edit: link to app: http://forum.xda-developers.com/showthread.php?t=594763

Related

Developing against HTC libs

I'm trying to figure out how to write an app that uses HTC API's. Specifically I want my app to switch scenes but I can't figure out how to call in to their libraries.
I unzipped Rosie.apk and it is only resources, no java.
it's the classes.dex
Right but how do I import something from a dex in eclipse and build it?
manicmethod said:
Right but how do I import something from a dex in eclipse and build it?
Click to expand...
Click to collapse
no way.
.dex is compiled, not source.
does java have a way to forward-declare classes so I can tell java they'll be there when it tries to run?
I haven't done much (read: any) actual development on Android yet, as I just got my Hero recently (developing solely on an emulator? ewww), but isn't the typical way of interacting with other applications on Android through Intents and Actions?
Browsing through the AndroidManifest.xml file in Rosie.apk, there seems to be a reference to com.htc.launcher.ThemeChooser.action.theme_change - Maybe this would be a place to start?
Ah yes, I'm still in the mindset of calling other peoples interfaces to do things. Thanks for the tip.
trying to figure out what to do with it will be fun, I'm sure
So com.htc.launcher.ThemeChooser.action.theme_change launches the chooser. I need to be able to change the scene under the covers by telling it what theme to switch to, any one have any ideas?
Glad to see that you made a little bit of progress I did some more searching, but this time in Rosie.odex. I found an ACTION_THEME_CHANGE string. Perhaps it could be something like this:
Component Name: com.htc.launcher.ThemeChooser.action.theme_change
Action: ACTION_THEME_CHANGE
Data: ?
Like I mentioned, I'm new to this stuff I'm not sure if there is a way to log or monitor intents (that would sure make this easy, wouldn't it?).
After looking at this more I think I need to hook into the htc settings content provider and see if I can change the settings like that. I found this in the manifest.xml:
E: provider (line=191)
A: android:name(0x01010003)="LauncherProvider" (Raw: "LauncherProvider")
A: android:readPermission(0x01010007)="com.htc.launcher.permission.READ_SETTINGS" (Raw: "com.htc.launcher.permission.READ_SETTINGS")
A: android:writePermission(0x01010008)="com.htc.launcher.permission.WRITE_SETTINGS" (Raw: "com.htc.launcher.permission.WRITE_SETTINGS")
A: android:authorities(0x01010018)="com.htc.launcher.settings" (Raw: "com.htc.launcher.settings")
so according to http://developer.android.com/guide/topics/providers/content-providers.html it looks like the Uri should be:
Uri u = Uri.parse("content://com.htc.launcher.settings");
except when I try that I get an exception saying that is an invalid URI :\
I'm not sure that it would be a setting. I mean, I'm sure you could find an attribute to set, but I don't think the switch would be instantaneous (likely requiring a reboot to show), unless there is something listening for changes to the settings. I could be wrong, of course.
Figured it out:
final Uri u = Uri.parse("content://com.htc.launcher.settings/widget_workspaces");
And the resulting table has
_id, display_name, created, status, and ancestor_id
So I think I can change status and then figure out how to throw a notify
I guess you were right, it looks like the widget_workspaces table has all the scenes available but the status field doesn't do what I assumed it would, rather it looks like it indicates whether a scene was shipped by HTC, is your saved scene or is unsaved.
I was really hoping this would do it because I don't know where to look now.
Well, looking at the ddms, it seems like I am wrong. It looks like ThemeChooser activity will do the swapping itself after you have selected a different scene. So it doesn't look like you will be able to make use of HTC's packages to do the swapping for you. Unfortunately, the only thing I can think that you could do next, is figure out how it is storing the scenes and load it and call all of the loading functions yourself...
Well, I have no way of calling their loading functions so I guess I'm out of luck :X
Check out smali and baksmali to snoop around in the classes.dex.
P
I used ddx1.7 to snoop in the dex files and found the tables and everything they were storing settings in. Unfortunately it looks like they neither store the current active scene in the table nor have an intent to call that will switch it without popping up the dialog.
It looks like what I want to do isn't possible.

[UTIL] BGSwitchPPC

Hi All,
This is my first ever smartphone app, but it's based on a full-fledged windows app of mine that I've been using for a few years now.
Basically, I like to change my desktop background alot, each time I log on in fact. So i wanted something similar for my phone. Also, I wanted a way of having an appropriately dimensioned image for when the keypad was open/closed.
So I've created this little app for my X1.
What it does is choose a random image from a preset directory (different directory for portrait/landscape images - to allow for correct dimensions - can be the same dir if you're not fussed) and sticks it in as your background image.
Current Features
Random Background Selection
Supports any resolution device
Different Image For Portrait/Landscape mode
Supports Different Directories To Select Portrait/Landscape Iamge From
Preview Backgrounds In The Config Util
Scheduling Support
New Background After Hard Reset Option
Current wishlist
Automatic image resizing/scaling etc
New Background After Suspend
current known bugs
Sometimes unable to delete original theme images - so this still needs to be done manually after each theme change (remove any stwater* files from Windows directory) Might have fixed this. Not sure, couldn't replicate the problem a second time, but there have been appropriate code changes.
In theory if you left the app open for long enough on the appropriate messagebox just before you exit, you could miss your Switch schedule and have to reset it. Highly unlikely anyone will come across this one though!
Hard Reset upodate seems buggy - but could just be my phone taking a while to load up!
Occasionally goes completely wrong on hard reset.
View attachment BGSwitchPPC.zip V0.4
Installation notes:
Copy it somewhere, anywhere, on your Xperia X1 (or other WinMo device)
Run the exe
Please download it and have a play. Any/All feedbacks, criticism and requests more than welcome.
hey graymi really like this app, works exactly how u said it would no problems here, cant wait for you to add scheduling and now i dont always have to switch themes
Sounds good, does it change the wall paper for all tabs?
it changes the phone wallpaper, i dont think it will change the manila wallpapers but i dont have a manila rom to test it on
illmurs said:
Sounds good, does it change the wall paper for all tabs?
Click to expand...
Click to collapse
tabs? Like the xperia button thing I never use? Thought you couldn't change the BG on most of those?
afaik, becuase of the way it works, it'll only change the wallpaper for the today screen. but it'll do it for both screen orientations. (Different if wanted)
good to see some people getting use of this though! Gives me drive to actually put the scheduling in!
pablo34 said:
cant wait for you to add scheduling
Click to expand...
Click to collapse
Scheduling has been added
I've edited top post with new version.
Thanks for the appreciation
scheduling works perfectly thanx for the great app
Glad you like it
hopefully i'll have a chance to work on some more features soon.
i have an idea, made you can find a way to create a way to have it switch wallpapers everytime the phone boots, thats would be a great feature
Consider it done
- Updated version available
that was fast, it works perfectly thank you once again
nothing like a bit of 2am VB hacking
I keep getting "An unexpected error has occurred in BGSwitchPPC.exe" error message.
Details:
Code:
BGSwitchPPC.exe
IndexOutOfRangeException
at BGSwitchPPC.frmMain.LoadImages()
at BGSwitchPPC.frmMain.frmMain_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Form.ShowDialog()
at BGSwitchPPC.SharedSubs.main
interesting...
I think it's because you don't have any stwater images in your windows directory, maybe.
don't have the source code to hand right now, but I'll try and sort it out tomorrow if I get a chance.
This will be sorted!
Is it work on manila ? TF3d ?
woh, exactly what I was looking for :O thanks man, good work. Windows 7 wiie
xicloe said:
Is it work on manila ? TF3d ?
Click to expand...
Click to collapse
honestly, I don't know.
It works by changing the image files used by the today screen, so unless these apps pick up and use the today screen bg, I'd doubt it.
It might be in future I modify the app to do this, but as I use neither program, especially since the win 6.5 today screen, it won't be for a while.
-didn't get a chance to fix above error yesterday. Well, I did have a chance, but I also had the chance to finish Tales of Monkey Island...
Graymi said:
honestly, I don't know.
It works by changing the image files used by the today screen, so unless these apps pick up and use the today screen bg, I'd doubt it.
It might be in future I modify the app to do this, but as I use neither program, especially since the win 6.5 today screen, it won't be for a while.
-didn't get a chance to fix above error yesterday. Well, I did have a chance, but I also had the chance to finish Tales of Monkey Island...
Click to expand...
Click to collapse
heyhey! apparently, i have developed some kind of mod for tf3d to change wallpapers automatically or via touch!
feel free to take a look at it!
http://forum.xda-developers.com/showthread.php?t=541462
not working for me
when I run exe and press "Select Dir..." independent whether I choose Portrait or Landscape an exception is thrown:
unexpected error...
Details: ...DirectoryNotFoundException at ...InternalGetFileDirectoryNames/GetDirectories/RecurseNodes/frmDirPicker_Load/... and a few others
same when I "Pick" one (Portrait or Landscape) or try to "Switch", after "Switch" I even had to soft reset as every attempt to start the app immediately resulted in an error
could that be manila related? I'm on 2.5.19222911.0
Wow, that's quite an error!
I'll code in a catch to stop that happening, plus fix the other error above

Transparent/Translucent Forms & Controls

So I have been searching these forums a bit each day for the past week, and I have yet to see a working solution for SmartPhones AND PPC's alike. I have tried P/Invoking AlphaBlend, SetBkMode, etc. but to no avail. I am not a great coder, so I may be using them wrong.
If anyone knows how to get this to work on SmartPhone's and PPC's, could they please share their knowledge
Thank you!
Cyclonezephyrxz7 said:
So I have been searching these forums a bit each day for the past week, and I have yet to see a working solution for SmartPhones AND PPC's alike. I have tried P/Invoking AlphaBlend, SetBkMode, etc. but to no avail. I am not a great coder, so I may be using them wrong.
If anyone knows how to get this to work on SmartPhone's and PPC's, could they please share their knowledge
Thank you!
Click to expand...
Click to collapse
What exactly do you want to do?
I want to be able to make forms / controls that have Opacity less than 255 ... (I want to do this in C#) ... take, for instance, SMSBubbles, it displays a small bubble at the bottom of the screen about a new text message...how would i be able to achieve that and still maintain the background to be transparent. Also look at SmartToolKit, when you pop open the Start Menu, the back (what is not covered by the menu) remains updating (etc.) but you still get the menu..
I want to do something along those lines...
any help is greatly appreciated
Have you checked out this blog entry?
blogs.commentor.dk/post/Transparent-Controls-in-NETCF.aspx
Or a library: http://beemobile4.net/?sitecateg=products&productID=5
Thanks for the replies, the first I tried implementing, but it didn't work as I would have hoped (The second, well I don't want to pay 45+$ for it...heh)
So I re-tried P/Invoking SetBkMode in the onPaintBackground method:
Code:
protected override void onPaintBackground(PaintEventArgs e)
{
setBkModeCE(e.Graphics.getHDC(), BkMode.TRANSPARENT);
}
I also made sure to P/Invoke
Code:
SetCursor(IntPtr cursor)
...main loop starts here...
SetCursor(IntPtr.Zero)
to get rid of the wait cursor.
While this works perfectly in terms of eliminating the background, it doesn't actually make it transparent. What it does, i can do by taking a screenshot and applying it as the bg (It doesn't update). I suppose I can use a timer and have it update the background on Events of all sorts, on user-activity, and every minute, but that seems like it is a hassle.
That may be the only way to actually do it, I don't know, but it just seems that there is a better way to do it (and be able to conserve RAM).
I used this library in one of my apps: http://code.msdn.microsoft.com/uiframework
Sourcecode is available, written in C# so its easily adaptable to your needs too.

Flash + VB.NET : embedded Flash way to big

Hi there,
i have just recently upgraded to an HTC HD2 phone from an age-old-phone.
Now i wanted to create my own application but i found it very hard to step into mobile-development. After downloading a bazillion tools and trying to do stuff with flash and VB.NET it took me two days to even get the simplest of app to be working. I still find it weird that there is no real solution to simply create an app that looks nice and still works out of the box. VB.NET does not support transparencies unless you write own controls for it (which i am not experienced enough). Flash can not really create an app that runs in itself (or can it - there was this beta-thingy that git cancelled?)
Anyway, what i have settled for now is a VB-APP that does some of the work i want to achieve and embeds a WebBrowser-Control that launches Flash for the main UI. I even got it to work, but, for whatever reason i can not get my flash-swf to fill the webbrowser-control. Setting the flash movie to 100% lets me only see roughly 25% of the upper left corner of my app. The same happens when setting straight pixel values. The closest i get to Full-Screen is with a width-setting of 28% and a height of 50%, which i am certain will not even look half decent on an other phone.
Does anoyone have a solution for this? Maybe it is real simple but i can't see it.
Thanks in advance.

[CODE] Blockclock - Free Code Giveaway - A Metro Style Alarm Clock for WM6+

A lot of people I spoke to whilst leaning programming didn't want to help with the Visual Basic side of things and started moaning about me not using C# - but that was my choice to make. So I make this post with similar minded people in mind - maybe there is someone else out there that doesn't want to learn C# to code apps?!?
A while back I started learning about Windows Mobile development but I left it a bit late in the OS's lifecycle and sadly lost my motivation for producing apps for it.
Now that I have left my Windows Mobile development behind I am willing to contribute my, slightly messy but, working code to anyone that might find a use for it.
I am willing to donate my code to the community in the hope someone will finish it off - if they can decypher my workings - or make use of it in their own projects.
It's an Alarm Clock in the Metro UI style (see attached screenshots) which wakes the device at the set time and sounds an alarm and is written in VB and is for Windows Mobile 6 and above. Most of the functionality is already in place.
It requires the Smart Device Framework libraries to be installed on the PC used to code it.
Working Features:
One working alarm which wakes the device when required
Snooze function
Customisable colours - working selector screen with 46 colours to choose (you can even use a custom hex colour if the XML settings file is manually edited)
Selection of different date formats
Rotation support for WVGA devices works...sort of but could probably be tweaked.
Things left to finish:
Add additional alarm(s)
Allow naming of alarms
Put dialogue in place to select a sound for the alarm(s)
Put an 'if -> then' statement in place in the alarm sounding procedure to vibrate the device if vibration is enabled
Graphics are minimal to reduce on memory usage but I think it looks quite good...even if I do say so myself (Please see the screenshots attached)
The program was never finished due to changing my main OS on my phone from Windows Mobile to WP7 and Android and I don't think I'll be returning to Windows Mobile 6.5 development.
The following imports are required:
Imports System.IO
Imports System.Threading
Imports System.Media
Imports OpenNETCF
Imports OpenNETCF.WindowsCE
Imports OpenNETCF.AppSettings
...and the following references in the project references:
OpenNETCF.AppSettings
OptnNETCF.WindowsCE
The app creates an XML file for the settings which is stored in the program folder and in its current state it works for 1 alarm with one alarm tone ('alarm.wav' in the resources folder).
Any questions...feel free to ask. There is one menu template which is configured in various procs to create the menus for alarms and preferences so it can look more complicated than it actually is in the code.
Glad to see some people may have found this useful! Keep me updated with any developments, it'd be interesting to see if this goes anywhere....I ask for no credit.
Hi thank you for the source code. I prefer C# syntax wise but they share the same runtime environment and get compiled into the same MSIL language so in theory they are the same. Just some things are done differently. Cheers again.
sb.oddworld said:
Hi thank you for the source code. I prefer C# syntax wise but they share the same runtime environment and get compiled into the same MSIL language so in theory they are the same. Just some things are done differently. Cheers again.
Click to expand...
Click to collapse
No problem at all. Some of the form layouts can be a little confusing so if you need a hand just yell. Glad that it might be of use to someone.
Thanks welki1979 being a non C programmer I fully appreciate how hard it is to find suitable code to get examples from. Even if it turns out to be totally useless it is still a very nice gesture.
Ok got it up and running (didn't need the Smart Device Framework listed above as I already had Microsoft .NET Compact Frameworkwork 3.5 installed).
First impressions... It's really cool (especially the random item close), haven't had much chance to go through the code yet as it threw up an exception when I first ran it that needed to be sorted out first.
What I was hoping to see was the application being triggered from one of the menus items but instead it just fires up on load.
I was hoping to learn how to code it so it could be fired off the start menu icons, but I can't seem to work out how those applications are triggered.
Not sure what value I can add to the program, but given enough time to learn a bit more about mobile coding I might be able to add something.

Categories

Resources