[Q] How Can I Make an Object Draggable? - Windows Phone 7 Software Development

Hello everybody,
Can someone explain me how can I make an object (an Image) draggable by the user in a Windows Phone Silverlight application?
I'm stuck because I don't know how to do this, I've assmued that the AllowDrop propery It's what I need...
Can you help me?
Thank you

There are lot of ways to implement... Simpliest (but not an optimal) way is: drop image to main page, attach these handlers to the image and LayoutRoot.
You should understand idea but your implementation may differ (and better)
Code:
private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.image1.RenderTransform = new TranslateTransform();
}
private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
this.image1.RenderTransform = null;
}
private void LayoutRoot_MouseMove(object sender, MouseEventArgs e)
{
TranslateTransform t = this.image1.RenderTransform as TranslateTransform;
if (t != null)
{
Point pt = e.GetPosition(this);
t.X = pt.X - (image1.Width / 2);
t.Y = pt.Y - (image1.Height / 2);
}
}

Thank you for the reply!
The code works, but the image is draggable even if I tap somewhere else, how can I make it draggable by only clicking the image?
Thank you again
EDIT: The TranslateTransform is a specific kind of render transformation. Rather that changing properties of the control (such as the Margin property), it simply affects how the control is displayed on the screen.
I need something that actually changes the image margins...

As for first question: attach MouseLeftButtonDown & MouseLeftButtonUp to image, not to the layout root (grid).
For second one: why do you need to change image margins? What's the reason? What are you trying to do?
P.S. Of course you can change margins instead TranslateTransform but I'm not sure is it GPU powered...

MouseLeftButtonDown & MouseLeftButtonUp are already attached to the image... Did you mean MouseMove? I tried to put all the three events on the image, but It doesn't work, I don't have the drag effect :\
I need this for a simple game
This is what I have to do:
1) A level where I don't need to change margins: You have to touch an image which is behind another one, so you have to drage the first image away to touch the second.
2) A level where I need to change margins: You have to complete a puzzle. You have a puzzle with a missing piece on the left and 4 pieces on the right. You have to take the right missing piece and drag it to the empty place in the puzzle. I wanted to so something like "if the block is in a specific range of margins(because it's too difficult to release the image exactly where It should go), then verify it it's the correct one".

Sorry but seems like you need to study game programming basics first. All tasks you've described are very simple but you need (at least) understand what are you doing...
I gave you an idea how to move image (but there are a lot (not, A LOT) of different ways). So you only need to:
- start "dragging" image by changing TranslateTransform coordinates;
- on each change you should check image bounds (it's e.GetPosition(this).X, e.GetPosition(this).Y, e.GetPosition(this).X + image1.Width, e.GetPosition(this).Y + image1.Height) intersection with your placeholder and "fix" image (just do not process MouseMove) . That's all.
If you still don't get it, try good book first.

Related

Open ZIP file in Silverlight

Hi,
I'm working on my first application for Windows Phone. I got a ZIP file which contains a huge amount of XML files and which has to be
updated through the app. So I declared the 'Build Action' of the file to 'Content'. Now I'm stuck opening the file for reading and extracting
a stream for a specific XML file.
I tried File.OpenRead but Visual Studio Express crashes when trying to debug this.
Do I need to use Application.GetResourceStream? If yes, can someone post a working example with a content ZIP file (not resource).
Can anyone help me?
Thank you,
toolsche
Try http://senssoft.com/ZipTest.zip
I've created that example project for Freda's developer.
Hi,
Unfortunately that doesn't help me.
1) U did set the file as "Resource" => it will not be updateable because it's within the assembly. If I'm wrong, please tell me...
2) U used an external library (SharpZipLib) which I hope it wouldn't be necessary.
1) I've used an embedded file (actually, epub == zip) to simplify the solution. It's just an example. U may copy the resource file to IsolatedStorageFile / download it from web/ whatever you want. I can't teach you how to use Silverlight for WP7 - buy some good book...
2) SharpZipLib IS NECESSARY! Other "zippers" looks like not a 100% compatible with WinZip/linux zippers (see Freda corresponding topic). SharpZipLib did the job very well.
Of course it up to you: what you want to use. But I gave you a 100% working and tested solution.
Hi,
I'm not in doubt that your solution is working and I thank you for your suggestion.
Maybe I'm on the wrong path, but what I think I need is a solution for opening
a zip file that is NOT part of the assembly (which I think it is if you declare it as
embedded resource).
My intention is to load one or more zip files from a server which the application
should be able parse/remove/replace if outdated. I tried to find a solution but had
no luck so far. MSDN has an example but I couldn't get it to work because I don't
know where the zip file should be located:
http://msdn.microsoft.com/en-us/library/cc190632(v=VS.95).aspx
Try to use IsolatedStorageFile and WebClient, something like this:
Code:
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
WebClient downloader = new WebClient();
downloader.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("myfile.zip", FileMode.Create, isf))
{
Byte[] buffer = new Byte[e.Result.Length];
e.Result.Read(buffer, 0, buffer.Length);
stream.Write(buffer, 0, buffer.Length);
}
DoSomethingWithZip("myfile.zip");
}
};
downloader.OpenReadAsync(new Uri("http://mysite.com/archive.zip", null));
Thank you for the quick answer. I will try it as soon as possible and post the results.
EDIT: Thanks, it's working as suggested.

[tutorial] How-To-Make-A-CHT-Widget

Are you interested in making or editing a CHT widget? To make a widget for Co0kie Home Tab 2.0.0 is not such a difficult job as you may think, I tell you by experience. I have no previous formation in programs or informatic code but i could make a few widgets(*) and I would like to share this experience with you. This is not so altruistic work, I am expecting a huge amount of widgets made by all of you to install and enjoy in my brand-repaired HD2
Co0kie Master has allready published a guide for making a CHT widget (it is into the widgets kitchen); also Genius_Rat_2665 has made a tutorial for making a cht clock widget, so -the third time lucky- lets bring here all that knowledge and try to make a simple widget step-by-step. Also this could be a good place to share and learn each other some code for widgets. Things like how to make an blinking element, how to change number in text, how to read from the registry, etc.
(*) What is for sure is that no one widget I could ever do without the help of others. Lets start quoting the existing Co0kie's guide:
Here is a guide on how to build your own widget for CHT.
I decided to break this up into 3 parts.
The kitchen section is a brief description of the kitchen structure and batch files.
The guide section will tell you how to build your own widget and make a cab to install it.
The "how it works" section will tell you what's going on in the background - why the system is the way it is.
#####################
*** 1) Kitchen ******
#####################
Just a few words about the kitchen folder structure:
- Workspace - here you'll find all the raw files that are being worked on currently
- Tools - all the needed tools
- deploy - just a little temp dir used by the batch scripts to compile and deploy files directly to your device
- cab - the cab file and setup.dll
- cab\_files_final - all the final compiled files that will need to be inside the cab
The batch files:
These files automate the process of editing manila files.
Connect your device to your PC via ActiveSync to be able to run the batches.
z_init.bat - You need to run this one before starting. You just need to run it one time. It will copy restartmanila.exe to you device.
_Deploy_to_device_in_dev_mode.bat - this batch will:
1) compile the lua files from \workspace\_lua and copy them to the deploy folder
2) copy all files from \workspace\mode9 and other \workspace\ subfolders to the deploy folder
3) use rapicopy.exe to copy everything from the deploy folder to \windows on your device (it's set to overwrite exitsting files)
4) restart manila on your device
_Generate_files_for_cab.bat - this will compile and copy the workspace files but it will not deploy them to your device,
instead it will copy them to \cab\_final_files
it will also rename the base mode9 and lua files to CHTmode9 and CHTlua - more on this in the "how it works" section
[[ It also needs to be modified the files _Generate_files_for_cab.bat & _Deploy_to_device_in_dev_mode.bat to addapt them to your own widget. Click with the right button of the mouse over the files and select edit, then change the name of the widget (PoyTEST.lua & PoyTESTtranslation.lua in the attached example) and the corresponding manila files ]]
[[ Tools folder includes m9editor for the edition of mode9 files, notepad2 for the edition of the Lua files, CFC_GUI for the qtc files (graphics), manilaHASH to obtain the right manila names corresponding to .luac files, and some other .exe files used automatically by the kitchen. ]]
################################
*** 2) Making your widget ******
################################
Guide - how to make CHT addon widgets:
First of all, because you will be developing, you need to turn on CHT's dev mode.
Open the reg key HKCU\Software\HTC\Manila\ and create a DWORD value, call it "CHTI.AddonWidgets.DevMode" and set it to 1.
This will allow you to deploy and test your widget directly from the kitchen.
[[ This is very important as you do not need to create and install the cab for test the widget, just using DevMode the widget will go from \workspace\ directly to your device, so you can make changes and see results easily. ]]
Now proceed to build your widget. I suggest you use the analog clock addon as a base. [[ You can use PoyTEST, its much simplier ]]
There are two rules you simply must follow:
1) For every new widget, its CHTWidgetDev.lua file must change the "widgetName" property. It must something unique.
I suggest a naming system of "CreatorName_WidgetName" - that should ensure that the names are unique - there must not any conflict here!
Modify anything else however you'd like. The rest of the fields in that file don't need to be as unique as the "widgetName" property.
2) The 30182CB6_manila mode9 file must follow a special rule: The "Scene" section must not contain any components. See how it looks like in the example addon.
That's how it must look for all new widgets.
[[ Making a widget is like making a puzzle (but much more funny ), you have to put the right pieces in the right places. There is no a fix rule and there is a lot of trial and error. Where to find the right pieces? Co0kie gave us thousand of decompiled lines of Lua code in CHT_Source. Download it from post#6 of CHT 2.0.0 thread. Also look in every published widget's kitchen in CHT thread, Rat_2665, Dunc0001, ZaxXx, Azarbel, Colossus_r, RoryB, MnCessna ... (Sorry I dont remember all right now!) ]]
Once you've done that you can do ahead and run "_Deploy_to_device_in_dev_mode.bat" - that will compile the files, copy them to your device and restart manila.
Then just go to the edit widget menu in CHT - your widget should be at the bottom of the list - add it and test it.
When you have finished making your widget, you can pack it up into a cab file.
To prepare the files for the cab you have to run "_Generate_files_for_cab.bat".
The final files will be in the \cab\_files_final\ folder.
Making the cab file - this is what an addon cab must have:
1) Every last one of those files from \cab\_files_final\ need to be in the cab and they have to be set to be copied to %windows%.
Do NOT set the install dir to %windows%, set the files to be copied to %windows%.
2) The setup.dll that is in the \cab\ folder also needs to be added to the cab.
3) Last, but extremely important, set the install dir to \CHTAddons\^widgetName^ - where ^widgetName^ should be your unique widget name same as in the lua file.
[[ This is really important. If you are not creating a new widget but just editing the mode9 and/or lua files, please do not modify the installation dir in the cab properties, as it is used in the installation process and modification may cause problems in CHT ]]
If you want to test that cab on your device make sure you disable dev mode first ("CHTI.AddonWidgets.DevMode" to 0), so that the dev mode widget you were working on and the newly installed one do not conflict.
A widget must not be installed in both dev mode and as a cab at the same time!
##########################
*** 3) How it works ******
##########################
CHT addons plug into slots that interface with the core layout manager.
There is maximum number of addon slots (that number is 10 for the dev preview beta, but it will be 20 for the final).
Each widget consists of 4 parts:
1) a mode9 file for the CHT widget interface
2) a lua file for the CHT widget interface
3) any number of extra mode9 or lua files
4) xml file with a manila file list for CHTScheduler
Numbers 1-3 there are directly needed for CHT. Number 4 is needed for CHTScheduler (I'll leave the explanation of that for the CHTS thread - it's not need for now if you just want to try to build your own widget).
Numbers 1 and 2 are the most important and they are directly linked to the slots.
Here is how:
The interface mode9 and lua need to have a specific names depending on which slot they go into.
To make this happen those 2 files are dynamically named on install.
While you are developing your widget you are working with the dev widget slot. There is only one of these so it has one pair of mode9/lua names (30182CB6_manila and 7D241726_manila).
But once you make the addon cab the widget can be installed in any slot (first one found to be free). That's why in the release files, there is a CHTmode9_manila and CHTlua_manila.
Those are the same files that you were developing with (30182CB6_manila and 7D241726_manila) - they will be renamed on the fly once installed - this is where the special setup.dll comes in.
The dll will look for the first free addon slot and install the widget there, i.e. it will rename the files so they correspond to the first slot.
The install dir name that you had to specifically enter is used as the widget install ID and will be stored in HKCU\Software\HTC\Manila\ "CHTI.AddonWidgets.SlotX" (this is needed to uninstall the widget correctly).
The files that are being installed should all go to \windows so you set that directly for the files, and that allows the install dir name cab field to be used for this purpose.
Click to expand...
Click to collapse
If you have reached here I recomend you re-read Co0kie's guide, is short but it contains a lot of information, i would say every word is important!
So now the first trial:
1.- Install the kitchen: Every widget has its own kitchen, I have attached a kitchen for a very simple widget. Just download in your PC and copy all the files & folders in a separate folder (\CHTwidgets\PoyTEST\) same as they are inside the .rar
Now connect your PC and your device via USB and sinchronize. Then run the file z_init.bat - You need to run this one before starting. You just need to run it only one time. It will copy restartmanila.exe to you device.
2.- Put your device in DevMode: Go to HKCU\Software\HTC\Manila\CHTI.AddonWidgets.DevMode and change to DWORD =1 (create if does not exit). Now restart Sense.
3.- Run the file _Deploy_to_device_in_dev_mode.bat. Your device will automatically restart Sense. Then go to Edit Mode - Add new element - Select PoyTEST - done. You should see now the simple widget in your device's screen.
It will continue ....
SENSE CRASHED? NO PANIC
It is normal to crash sense when you are doing some experiments, but it normally get solved just deleting files 30182CB6_manila & 7D241726_manila in \windows folder\ and/or dissabling DevMode in registry HKCU\Software\HTC\Manila\CHTI.AddonWidgets.DevMode = 0
rat_2665 said:
It's a tricky thing. Do you use one of Co0kies widgets? For this I "took it over" at first. I didn't change the structure, only made new names in the manila files. You have to check over and over. A blank space in a name in the mode9 file cost me a day. In the next step you can try to change the behaviour.
What you see is the normal screen for an error (i had it often ). Check if all variables in the lua files are also in the mode9 file. Then in the developer mode you can't see errors in the lua scripts (absent end in functions and so on). For this I used sometimes the m9editor, compiled the scripts and looked for errors.
Click to expand...
Click to collapse
Even we can learn from this crashs:
Co0kie Monster said:
Sense nuke and lua "debugging"
The empty screen after adding your widget will happen if there is an error in your widgets lua code. Alternatively it could be a bug in the mode9 file (but those usually cause sense not to start at all), or maybe you left dev mode on and installed your widget via cab - dev mode uses a special widget slot and it will cause a conflict if a widget is installed both via cab and in dev mode at the same time, so remember to turn off dev mode.
But, anyway I'm guessing the problem would usually be in the lua code. In that case you need to debug it. I've uploaded all the needed tools to "Co0kie's Home Tab\_Development\Lua_debugging_tools". (* inlcuded in the widget kitchen)
Because lua is a script It's not really debugging, it's pretty much just a trace log.
Run attach.bat while your device is connected via active sync and that will collect trace information and display any errors along with the file and line where they occurred.
All the info is collected in debug-attached.txt.
Do whatever causes the bug, then run terminate.bat to stop pdebug (that will also restart manila).
Open up the log and look for **Lua Error******.
Other than that you will also see trace() output there.
The other batch (run.bat) is for debugging from startup. You need to turn off manila (WM Settings->Home-> turn off HTC Sense from the list) and then hit run.bat - it will start manila and log at the same time. That's only needed in case of startup errors.
Click to expand...
Click to collapse
HOW TO SOLVE SOME GRAPHICS ISSUES
santod040 about some graphic issues said:
I am not exactly sure yet why the 16 rule only applies to some roms. I think this may actually be the difference between a CFC and non CFC manila.
Though Im digging into this more still.
I also think of this more as one rom listening to the mode9, no matter what the image claims to be or is.
Where the other needs the image to specifically be what it expects, according to the mode9 and lua.
I also think it's more about "4" and "16"
Here's a few key items from Mode9 and a small bit about each.
Though it may be somewhat irrelevant mostly.
String: UTF-16LE encoded strings (represented as UTF-8 in XML and YAML)
Path: UTF-16LE encoded strings (represented as UTF-8 in XML and YAML)
UInt32: 4 byte unsigned integer
Q16: 4 byte Q16.16 fixed point number
Int32: 4 byte signed integer
Boolean: 4 byte, either 1 or 0
Vector3: 3*4 bytes of Q16 numbers (X,Y,Z)
RectQ16: 4*4 bytes Q16 numbers (X,Y,Width,Height)
RectInt: 4*4 bytes of signed integers (X,Y,Width,Height)
Size: 4*2 bytes of Q16 (Width,Height)
Color: 4*1 bytes (R,G,B,A)
Viewport: either a Vector3 or a RectQ16, depends on size
FrameValue: either a Vector3 or a Q16 number, depends on size
BinaryScript: a binary value, encoded as Base64 in the XML or YAML file
The CFC should not be used as a standard.
Heres why:
Non Cfc and Cfc images, will work on a Cfc rom.
Whereas Cfc images will not work right on a non Cfc rom(any stock rom).
So to be universal, non Cfc is the best approach.
Also consider that manila, and your device have to decompress as they use the images.
So, to offer Cfc as an option is nice, but not the universal offering.
Click to expand...
Click to collapse
santod040 said:
Similar issue again.
The qtc needed to be a more accepted dimension by manila.
I still don't have any concrete answers behind it, other then the info I already posted regarding textures and sizes in manila.
So, I adjusted the mode9 and also the qtc to be standard sizes.
I have made a few that worked.
The first was 256x64, but then was hard to move, lol.
So I edited again and made it 512x64 and reposted just now.
It seems to move just fine.
Now only to move the resize button up some and it would be near perfect.
But since it's almost 3am, that will have to wait.
Click to expand...
Click to collapse
santod040 said:
Something else to think about.
As far as the 16 rule.
I also mentioned 4.
So for example,
64 divided by 16 = 4 (good number)
96 divided by 16 = 6 (bad number)
128 divided by 16= 8 (good number)
Click to expand...
Click to collapse
only 10 widget slot problem solution
mike2nl said:
We, the CHT teams, have found a solution for the 10 slots for widget issue.
After we had changed things we are now in state to use 20 widgets(*) at all (0..19).
It is tested on HD2 and TP2 WM phones, and it's running without any issue until now.
The new file was tested by santod040, MichelDiamond, poyensa and me.
My last test was to use 20 widgets on the HD2 about the performance. And yes it does the work .
How to install the fix:
1. unzip the manila file
2. switch off sense
3. copy the 7c60907d_manila file o the \Windows directory
4. restart your phone
5. switch on sense
6. have fun to install more widgets now (max. of 20)
7. follow the install routine from every widget
Click to expand...
Click to collapse
Last but not least, thank you to all involved team members...
Click to expand...
Click to collapse
You can do your own widget just changing PoyTEST - PoyText1 - PoyGraphic1 for your own names
The best way to make a new widget is start from another widget, in this case we can start from PoyTEST, its a simple widget with 2 variables to display in the home screen of our devices: one graphic file as background and one text field. This 2 fields (or variables) will be created by the mode9 file. We have to give unique names for all the variables so the easiest way is just to change PoyTEST - PoyText1 - PoyGraphic1 - for your own names in every line of the files involved. So open file 30182CB6_manila using m9editor and do the changes. (If you are not familiar with m9editro go here)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The mode9 file 30182CB6_manila use to define also the content of the graphic variables (SetTexture) but we will do it later for this example. Other important thing is the order in mode9 stablish the order of the elements shown in ours screen. It means that we will see PoyText1 over PoyGraphic1 as we like.
Now we have to change the file CHTWidgetDev.lua using Notepad2 and change all the PoyTEST - PoyGraphic1 & PoyText1 for the name previously used in the mode9 file. It not dificult just change PoyTEST -nothing else- in every line where it appears, substitute for the name previously used in mode9 file. YES YOU HAVE TO LEAVE THE SMALL w
Some important things:
Be careful with capital and lower letters. For lua languaje 'PoyTEST' is different than 'poyTEST' so only one letter can make the widget not working.
If the line strat with '--' then the line is dissabled, this is usefull for notes & reminders and also to activate and deactivate lines. If you use Notepad2 the deactivated line will be green coloured.
The files 30182CB6_manila (mode9) & CHTWidgetDev.lua always have to be in any CHTwidget, and they must have always the same structure. In mode9 file 30182CB6_manila we do create the variables and in CHTWidgetDev.lua (renamed as CHTlua_manila in the cab) we connect the widget to the rest of Co0kie Home Tab.
Now we do not need to change anything, may be later when we are more familiar with widgets:
* Lines 3-8 is to register the widget in CHT
* Line 8 is connected to line 82-83-84. We define there how many layouts is going to have the widget (black-white-etc). We leave everything as it is now ...
* Lines 10-48 are to control the size of the widget, in the future you can play there a bit specially in line 42 if you wish your widget bigger, but now we leave it as it is.
* Lines 50-62 are very important. We do nothing there -never- just change the names for our's widget name. Specially line 62 we put there the object (clockface, bakcground, etc) that is going to react when we press it with our finger. In our case it will be PoyGraphic1 (change it for the variable name used in mode9 file 30182CB6_manila).
* Line 64 conect to our widget lua file. As you may know the lua file defines the behaviour of the widget. In this lua file we are going to say what our widget is going to do. Is time to open ManilaHash and find the manila name of our widget's lua file. Dont change the path just the final name, you can use any but by convention better use something like CreatorName_WidgetName.lua
* Lines 82-84 is to add more layouts in our widget. You can see some examples in other widgets and also in CHT_Widgets.lua (CHT source), but dont forget to modify line 8 then!
* Lines 88-104 is defined the animation effect how the widget comes to the screen when swipping between levels. I never touch anything there.
* same for lines 106-116. It was there before me and i never modify anything there (just the widget name)
* Now have a look again to every line, check the spelling, capital letters, etc.
Now you are using manilaHash you can also find the name for any other graphic file you are going to use. e. Dont change the path just the final name
Now we can start to modify the file PoyTEST.lua. Using Notepad2 you have to change PoyTEST for your widget name used in the previous lua file and also modify the name of the variables defined in the mode9 file 30182CB6_manila (PoyText1 & PoyGraphic1) in all the lines where those appears.
In this lua file can be added some properties that use to be set in mode9 file (lines 15-25) I do that for one reason: This file does not change the name in the widget installation process, as the other CHT files (CHTmode9_manila & CHTlua_manila) does. This file will be always 41CBC6DC_manila in \windows\ folder so it is easy to substitute later to correct some bugs, etc.
You can get out of the line 29 (just put -- at the begining of the line it will be green cloured) This is a test I am doing for translate widgets regarding this post. If so you have also to activate the line 28 (delete -- then the line will be black colour) and delete file PoyTESTtranslation.lua in \PoyTEST\workspace\_lua
I cannot say much more for this file. Here comes the problems. How to do things? I am not a coder I have only read and read and read a lot of code in other widgets and CHT_Widgets.lua and other files in CHT source, and try and try and try a lot, and finally ask rat_2665
* Line 33 is a way to set texture for graphic fields in lua files instead of mode9 files
* Lines 38-63 is to define what the widget does when pressed
You can do your own widget just changing PoyTEST - PoyText1 - PoyGraphic1 for your own names
Now is time to check the USB conection, device is sinchronized, then click on _Deploy_to_device_in_dev_mode.bat and see your widget working!
[[be sure the .bat file has been edited correctly by adding your widget name, as explained in post#8]]
Sense crashed ... dont worry. Nobody has got it at the first time!
1. Be sure you are in DevMode
2. Check that all the names are correctly written, specially capital letters- lower letters
3. if you got an error in the black screen after run .bat file, read it slowly. It will help
4. Once you make the corrections you can run again .bat, even with sense crashed.
MAKING THE CAB
Co0kie Monster said:
When you have finished making your widget, you can pack it up into a cab file.
To prepare the files for the cab you have to run "_Generate_files_for_cab.bat".
The final files will be in the \cab\_files_final\ folder.
Making the cab file - this is what an addon cab must have:
1) Every last one of those files from \cab\_files_final\ need to be in the cab and they have to be set to be copied to %windows%.
Do NOT set the install dir to %windows%, set the files to be copied to %windows%.
2) The setup.dll that is in the \cab\ folder also needs to be added to the cab.
3) Last, but extremely important, set the install dir to \CHTAddons\^widgetName^ - where ^widgetName^ should be your unique widget name same as in the lua file.
Click to expand...
Click to collapse
Be sure that you have edited the file _Generate_files_for_cab.bat with your own name widget as explained in post#8. By running this file all the lua files will be recompiled automatically and all the files will go from \workspace\ to \cab\_final_files\ If you have a look to the screenshot you will notice that some files names have changed: we will find there CHTlua_manila & CHTmode9_manila. This 2 files will change the name again when the cab be installed in the device, depending the free slot asigned will take the final manila in \windows\ folder in your device. Isn't magic?
Dont forget to add the magic setup.dll. When you add the files into the cab select windows as location. Then in cabinet properties - Installation directory do create a folder in \root\CHTAddons\NameOfTheWidget with the same name as your widget (line 5 of chtwidgetdev.lua) and mark hard-coded-path. Finally save the cab.
CHTScheduler
If we add a xml file named as CHTWidget_NameOfYourWidget.xml (CHTWidget_PoyTEST.xml in this case) directly in \windows\ folder with just a description of the manila files names used in our widget (see some of them as example) this widget will be used by CHTSheduler for diferents profiles, baselines, etc.
It does not seems dificult, isnt it? it simple but if you substitute the qtc file attached 1F88A376_manila, and change the color property for the text in line 17 of PoyTEST.lua to black (0,0,0,255) .... it could be the begining of an usefull widget
1.- Lets do our own CHTwidget
2.- Using JMLMenuSense
3.- Final touches
4.- A Bit of CHTS
Its good to have a look into CHTWidgetDev.lua from Co0kie's Standalone Analog Clock, with extended comments by Co0kie (in green). You have it into the Co0kie's widgets kitchen. We all started here:
-- File name: 7D241726_manila -- \windows\htc\home\scripts\home\chtwidgetdev.luac
-- ##### CHT Wigdet interface file #####
-- this script is an abstraction layer that sits between a widget and the core CHT Layout Manager
-- the template needs to be filled in the correct way, but once it is, the created widget will be plugged into the layout manager
-- and automatically behave like any other CHT widget - be movable, have access to different layout profiles, correct lockscreen behaviour etc.
-- even if I do say so myself, the system is *very* powerful
-- the comments below should provide a good description of the template
-- the primary and most important comments will be marked plainly with --
-- secondary comments will be marked with --// and they will contain some additionl points of interest, but not critical info
-- on your first read through I suggest you stick to just the primary comments
-- lines marked with --%% are commented out code that could be part of a template, but is not needed for this example in particular
-- if you have any other question, hit me in the social group
-- this first line creates a new template file based on 'WidgetTemplate' (defined originally in CHT_core.lua)
--// it's best to make it a local - it can be a global too, but there's really no need since it will not be accessed directly anywhere
--// except in this file - and one less global means less polution in the global namespace which could be very important going forward
local wStandaloneAnalogClock = WidgetTemplate:new()
-- this next step registers the newly created widget with the core CHT Layout Manager
CHTLayoutManager:RegisterWidget(wStandaloneAnalogClock)
-- some basic information needs to be filed in about the widget
-- 'widgetName' field - try to make this name as unique as possible, because it is used to save/load widget registy information
-- the core widgets have plain names (Clock, Appointments, Tasks...), but give your widget unique names to avoid conflicts
-- the simplest unique naming scheme would be to just add your name before the widget name
wStandaloneAnalogClock.widgetName = "Co0kieStandaloneAnalogClock"
-- this defines the text that will appear in the advanced settings/add a widget menu
--// sadly, I could not find a way to make the localization system distributed for every widget so you can't enter localized "IDS_*" strings here
wStandaloneAnalogClock.settingsString = "Standalone analog clock"
-- this defines the category in which the widget will appear in the advanced settings/add a widget menu
wStandaloneAnalogClock.settingsCategory = "Clock"
-- the maximum layout count (the layouts that are cycled by the previous/next button on the popup menu or in the settings menu combo box)
wStandaloneAnalogClock.layoutCount = 1
-- should the widget snap to the center of a page
-- // but "center" isn't really center - it's more like snap to posX == 0, 480, 960..., if that position X is the center of a page depends on how you made your widget
wStandaloneAnalogClock.snapToCenterX = false
-- here you can define default settings for your widget on a "per layout" basis
-- if defaults for a level are not given, it will use {visible = false, layout = 0, posX = 0, posY = 0, scale = 1, pinned = false}
-- the visible, posX and posY fields speak for themselves
-- the layout field is the layout number (can be between 0 and layoutCount-1)
--// scale is used for storing size info for resizable widgets
--// pinned is used for storing the pinned state of pinnable widgets
--%% wStandaloneAnalogClock.defaults["HomeLevel0"] =
wStandaloneAnalogClock.defaults["HomeLevel1"] = {visible = false, layout = 0, posX = 0, posY = 0, scale = 1, pinned = false}
--%% wStandaloneAnalogClock.defaults["HomeLevel2"] =
--%% wStandaloneAnalogClock.defaults["HomeLevel3"] =
--%% wStandaloneAnalogClock.defaults["HomeLandscape"] =
--%% wStandaloneAnalogClock.defaults["CHTLockscreen"] =
-- now come the widget function definitions
-- 'Initialize' - and extremely important function
-- it's called when the widget it loaded for the first time (on startup or when added from the advanced menu)
wStandaloneAnalogClock.Initialize = function(self)
-- these first few lines should be the same for all addon widgets
local newComponent = Component()
WidgetLayer2D:Attach(newComponent) -- you may modify this to be either WidgetLayer2D or WidgetLayer3D -- more info on this later
if not self.addonWidgetID then -- this is very important, every addon widget must have these line - do not modify them
newComponent:SetComponentClipCharacter("CHTWidgetDevSlot")
else
newComponent:SetComponentClipCharacter("CHTWidgetSlot" .. tostring(self.addonWidgetID))
end
self.positionLayer = newComponent
-- these two need to be filled in but they differ depending on how you named your mode9 fields
self.animationLayer = StandaloneAnalogClockAnimationLayer -- the layer that will be animated (fade in/out or any other more interesting effect that you can define - dee below)
self:AddObject(SACFace) -- defines the touch surface that, when touched, will enable the widget to be moved
-- the rest is completely up to you
require("Home\\Scripts\\Home\\Co0kieAnalogClock2") -- the script file that describes the behaviour
-- make sure that all new names that you add are unique so that there are no conflict with built-in widgets or any other addon widgets
-- suggested naming scheme is: yourname_variablename
-- the unique name requirement goes for all objectc in mode9 files, lua global variables and classes
StandaloneAnalogClock = StandaloneAnalogClockClass(StandaloneAnalogClockGroup, SACFace, SACMinuteHand, SACHourHand, SACSecondHand)
end
wStandaloneAnalogClock.GetPosX = function(self)
return self.posX + 128 * (1 - self.scale)
end
wStandaloneAnalogClock.GetPosY = function(self)
return self.posY - 128 * (1 - self.scale)
end
-- GetHeight and GetWidth provide feedback for layout manager so it can know the exact borders of a widget
wStandaloneAnalogClock.GetHeight = function(self)
return 256 * self.scale -- in this the base width of the analog clock is muliplied by the scale
end
wStandaloneAnalogClock.GetWidth = function(self)
return 256 * self.scale
end
-- resizing system definitions - I suggest you skip this part on your first read
wStandaloneAnalogClock.isResizable = true
wStandaloneAnalogClock.rotatingResizeButton = true
wStandaloneAnalogClock.GetResizeRefX = function(self)
return self.posX + 128
end
wStandaloneAnalogClock.GetResizeRefY = function(self)
return self.posY - 128
end
wStandaloneAnalogClock.GetResizeButtonXDelta = function(self)
return 90
end
wStandaloneAnalogClock.GetResizeButtonYDelta = function(self)
return -90
end
wStandaloneAnalogClock.CheckScaleLimit = function(self, scale)
return (scale >= 0.5 and scale <= 1.3), 0.5, 1.3
end
wStandaloneAnalogClock.GetResizeUnit = function(self)
return 128
end
wStandaloneAnalogClock.ApplyScale = function(self, newScale)
self.scale = newScale
local newRadius = self:GetResizeUnit() * newScale
self.animationLayer.Scale = Vector3Property(Vector3(newScale, newScale, newScale))
end
-- these are the layout control functions
-- this example widget has only one layout available, but these function come in very handy for defining multiple layouts
-- this function is run before any of the defined layout functions
-- this should contain something that should be set commonly for any layout
wStandaloneAnalogClock.CommonPreSetLayout = function(self)
StandaloneAnalogClockAnimationLayer.Center.x = SACFace.Size.width / 2
StandaloneAnalogClockAnimationLayer.Center.y = -SACFace.Size.height / 2
if not self:CheckScaleLimit(self.scale) then
self.scale = 1
end
self:ApplyScale(self.scale)
end
-- one of these functions is run depending on the selected layout
-- the string to be shown in the settings menu combo box is also defined here
wStandaloneAnalogClock.layoutName[0] = "[[IDS_NO_ALT_LAYOUTS]]" -- combo box text
wStandaloneAnalogClock.SetLayout[0] = function()
end
-- additional layouts can be defined here
-- the number of functions must match the layoutCount field defined above
--%%wStandaloneAnalogClock.layoutName[1] = "Second layout"
--%%wStandaloneAnalogClock.SetLayout[1] = function()
--%%end
--%%wStandaloneAnalogClock.layoutName[2] = "Third layout"
--%%wStandaloneAnalogClock.SetLayout[2] = function()
--%%end
--%%wStandaloneAnalogClock.layoutName[3] = "Etc"
--%%wStandaloneAnalogClock.SetLayout[3] = function()
--%%end
-- like CommonPreSetLayout this function is run for any of the layouts
-- but it's run after the layout specific function
--%%wStandaloneAnalogClock.CommonPostSetLayout = function(self)
--%%end
-- animation function, they are run when switching between level or adding/removing a widget
-- the basic thing that needs to be done here is make the widget visible or invisible,
-- but you can play around with the animations and put in some eye candy
--// Interopolate can be used with Opacity, Position, Rotation and Scale and some cool effect combinations can be made
--// post in the social group if you need more info
wStandaloneAnalogClock.AnimateIn = function(self, instant, swipeDown)
if instant then
self.animationLayer.Opacity.value = 100
else
self.animationLayer.Opacity:Interpolate(100, 10, 0, Interpolate_Linear)
end
end
wStandaloneAnalogClock.AnimateOut = function(self, instant, swipeDown)
if instant then
self.animationLayer.Opacity.value = 0
else
self.animationLayer.Opacity:Interpolate(0, 5, 0, Interpolate_Linear)
end
end
-- these two functions define what should be run to connect or disconnect widget press actions
-- the functions are called on transition to the lockscreen, edit mode, but also for some smaller details (like when menus are up)
wStandaloneAnalogClock.ConnectPressHandlers = function(self)
StandaloneAnalogClock:ConnectPressHandlers()
end
wStandaloneAnalogClock.DisconnectPressHandlers = function(self)
StandaloneAnalogClockisconnectPressHandlers()
end
-- these two do much the same as the previous functions, but the serve as exceptions for the lockscreen
-- in this case the analog clock should not have any action on the lockscreen
-- but for example, the music player uses these functions to reconnect the play controls on the lockscreen
--%%wStandaloneAnalogClock.ConnectLockscreenHandlers = function(self)
--%%end
--%%wStandaloneAnalogClock.ConnectLockscreenHandlers = function(self)
--%%end
-- this one is used to clear the the widgets selection status
-- in this example when the clock is pressed it sinks in a bit
-- in certain situations, there might be a need to deselect a widget even if it's still under the finger
-- (for example when a side scroll is started)
-- that's when this function is called
wStandaloneAnalogClock.ClearSelection = function(self)
StandaloneAnalogClock:ClearSelection()
end
Click to expand...
Click to collapse
You can try now making your own Clock-CHTWidget, following rat_2665 tutorial:
This is a little guide for clock widgets:
Read at first the widget development guide by Cokie (it's in the below mentioned kitchen) !!!
Step 1 manila hash names
1. Download the kitchen for the analog clock widget by cookie and make a temp folder in there. Copy the files for your analog clock in this folder (best if you have already a working clock for CHT 1.8.5). Save the pictures out of the qtc manila files as png in this folder (this is only useful for oversight). Rename the whole widget with your widget name.
2. Make a list with new names for your text and image objects with manilaHASH.
- the names should be unique. I use my name and a widget number as prefix, f.e. rat_w001_secondHand
- determine the manila hash name. For this use the line
\windows\htc\home\assets\images\Home\VGA\Your_Name.qtc
Save this list. You need it all the time for oversight.
3. Rename your images in the temp directory with the new manila names (this is only useful for oversight); then rename also your manila image files with these names.
4. Delete all files in the workspace\qtc directory and copy your new manila files into this (but not the old 1E1A6CCD_manila and 1EC5924B_manila)
Step 2 mode9 file.
5. Open the mode9 file in the workspace directory. Go in the library to the StandaloneAnalogclockGroup. There are the image and text objects for the clock.
6. If you have more objects in your old 1E1A6CCD_manila file for your analog clock add these objects in the group.
7. Then substitute
- for all objects the Instance value with your new name (f.e. rat_w001_secondHand),
- for the image objects the Texture path with the (here shortend) string that you used for the manila hash name (f.e. .\Assets\Images\Home\VGA\rat_w001_secondHand.qtc)
- for the text objects the String value to the variable used in the lua file (f.e. rat_w001_weekday). If you want to use AMPM like in the normal clock, don't change this value.
8. Change the name of the StandaloneAnalogClockGroup to a unique name (that is used later in the lua files, f.e. rat_w001_ClockGroup)
9. Change the name of the StandaloneAnalogClockAnimationLayer to a unique name (that is used later in the lua files, f.e. rat_w001_ClockAnimationLayer)
10. Save the file.
Now to the lua files.
Step 3 CHTWidgetDev
Substitute all uses of wAnalogClock2 with a unique name (f.e. w_rat_w001_Clock). You can do this in Notepad2 with the Edit/Replace function.
Then substitute in line 69 StandaloneAnalogClockAnimationLayer with the new unique name you used in the mode9 file for the animation layer (f.e. rat_w001_ClockAnimationLayer).
Do the same in line 74, 135, 136, 191, 195 and 212 for all uses of StandaloneAnalogClock (f.e. rat_w001_Clock)
Replace the string in line 28 with the name of your widget (f.e. "rat_w001_clock").
In the next line insert the string that is shown for the widget in the home layout (f.e. "my analog clock").
For an analog clock you don't need to change the next item (""Clock").
In line 70, 135 and 136 is the image object for touching mentioned. You have to substitute "SACFace" with your image object (at best the greatest, f.e. rat_w001_clockface)
The last part is line 73 and 74. In line 73 you have to substitute "Co0kieAnalogClock2" with the name of your special lua script (f.e. rat_w001_clock).
Line 74 is the bridge to your lua script. Here are the arguments of the ClockClass defined that are used in the StandaloneAnalogClockClass.__init function in your special lua file. Of course the name of the function is later also to be changed.
In the example it is:
rat_w001_Clock = rat_w001_ClockClass(rat_w001_ClockGroup, rat_w001_clockface, rat_w001_minuteHand, rat_w001_hourHand, rat_w001_secondHand)
Step 4 special lua file
For naming use the lua script file name you used in the CHTWidgetDev.lua file (rat_w001_clock)
In the first (commentary) line change the location with the new name instead of Co0kieAnalogClock2 and use the manilaHash app with this string:
\windows\htc\home\scripts\home\your_widget_name.luac
Then substitute also the manila name (f.e. -- File name: 1F2E1A7D_manila --\windows\htc\home\scripts\home\rat_w001_Clock.luac )
Substitute all uses of StandaloneAnalogClock with your name (rat_w001_Clock)
Change all uses of SACShowAMPM to your name (rat_w001_ShowAMPM).
That would be all if you only want to make a normal analog clock widget, but if you want to change more you have to go to the central function for the behaviour. For this you have to look in this two functions (these are the old Co0kie names):
StandaloneAnalogClockClass.UpdateTime = function(self)
StandaloneAnalogClockClass.UpdateSecondHand = function(self)
Here the update interval and the rotation of the hands is defined. In Co0kies clock it is pretty simple. If you want to add more functions here is the place. The names of the standard arguments clockGroup, clockFace, minHand, hourHand and secondHand should be unchanged in the whole file. For every other variable and object use your special unique name.
Of course you can add other functions in their own place. You find examples for this in my clock thread.
Now it is testing, testing, testing.
Step 5 bat.files
In the kitchen there are these two files
_Deploy_to_device_in_dev_mode.bat
_Generate_files_for_cab.bat
for handling in the development process.
Here you have to substitute in both files in the second luatool line 35E966AF_manila ..\Workspace\_lua\Co0kieAnalogClock2.lua
with your new widget name and its manila hash name. (in the example: 4C0089BA_manila ..\Workspace\_lua\rat_w001_Clock.lua)
Step 6 CHTS file
Rename the file in the CHTS with your new widget name (f.e. CHTWidget_rat_w001_Clock.xml).
Open the file with the windows editor.
Take your list with the manila hash names and substitute the objects with your new names and the manila names.
For the third line use your widget name and in the fourth line ("description") the string you used in the CHTWidgetDev.lua for the home layout description.
Click to expand...
Click to collapse
This links always useful ...
TUT: Editing manila!
LuaTool 1.2 - Lua Decompiler, Compiler and Compare
TF3D manila mode9 editor
CFC GUI - THE Manila/TF3D Image Editor
Manila file names
Manila CMD Kitchen Environment
Lua 5.1 Reference Manual
Manila Development for Beginners
Example of use of longpress thanks to RoryB
Modifications of the lua script/functions thanks to rat_2665
and reserved5 (i hope is enough )
Great post...I have been wanting to work on my own widget for CHT. Hope this thread will help me jump start...
So here are a few little things I have gathered over the last few months which I have found useful.
The ManilaHash.txt contains two lines of text for you to cut and paste into Manila Hash which you need to generate the correct manila filenames for your widget scripts and qtc image files. Just open Manila Hash, open the txt, copy and paste the relevant line into MH and alter the last bit to your image/script name. Then click Get Manila and you'll have your unique manila filename. Then highlight the hashed name, right click and copy. If it is the name for your widget script you are generating you then need to use this in the two bat files (Deploy to device in dev mode/Generate files for cab) before you run either bat - right click and Edit and you'll see something like this:
Code:
@echo off
pushd tools
luatool /c -o ..\deploy\7D241726_manila ..\Workspace\_lua\chtwidgetdev.lua
luatool /c -o ..\deploy\3DFA729F_manila ..\Workspace\_lua\dunchexclock.lua
copy ..\Workspace\mode9\*.* ..\deploy >nul
copy ..\Workspace\qtc\*.* ..\deploy >nul
copy ..\Workspace\png\*.* ..\deploy >nul
copy ..\Workspace\locales\*.* ..\deploy >nul
copy ..\Workspace\CHTS\*.* ..\deploy >nul
rapicopy -d -e -s ..\deploy \windows
rapistart restartmanila.exe
del /q /s ..\deploy\*.* >nul
pause
NB - The bat files included in the widget kitchen contain notation by co0kie but the code above shows the actual active parts of the bat.
The line you need to change is this one:
Code:
luatool /c -o ..\deploy\3DFA729F_manila ..\Workspace\_lua\dunchexclock.lua
Change the manila name to the one you just generated for the script (highlight/paste from MH) and change the script name to whatever name you are giving your widget script. BTW confusing as it may seem the hashed name is generated using .luac and the bat refers to it as .lua - this is correct!
Also for reference you should also edit the first line in your widget script to show the correct script name and hashed manila filename. Incidentally you'll notice this line in the script has -- at the start. This basically 'disables' the line so it becomes for reference only. This is handy during testing because you can remove elements from use without actually removing the text from the script, so they are easy to add back in later. If you are using Notepad2 which is in the tools folder (and I strongly recommend you do because it is specifically formatted for editing these scripts) you'll see that lines beginning with -- appear in green so you can easily identify inactive lines.
If you have generated a hashed name for a qtc file then simply copy the name, right click on your qtc file and Rename, highlight current filename and paste.
Widget mode9 Filenames.txt contains the hashed filenames for the mode9 files of each widget depending on which widget slot it is installed into. The mode9 and WidgetDev.lua filenames are generated during install depending on the slot number so you will need these if you are going to edit the mode9 after you have actually installed a widget (not relevant if you are still working on it in dev mode). You can also use this list to locate the mode9 file for any widgets you already have installed but which you may want to take a look at for reference or edit.
LUA Ref v5.1.pdf is a really useful quick reference guide for lua syntax, but before you get in a spin trying to get your head around lua for the first time I would strongly recommend reading this BEGINNERS GUIDE. There are many online references including the main LUA Reference Manual (there's a link to it in the site I've just linked to) but this one gives an easy to follow guide to the basics so read it first!
rat_2665's CHTAddon Dev Mode Switch - adds a new toggle switch in the CHT Toggle Switches list. Works like every other toggle to activate/deactivate Dev Mode rather than having to do it manually with a registry editor. Just toggle on/off and soft reset after each change to enter/leave Dev Mode. I'm sure rat won't mind me posting this here - it's all his work so all credit to him for this one - but it really is a timesaver when you are developing!
One final word of advice/experience - when you are first starting out on developing widgets it can be very VERY frustrating, especially if like me you have absolutely no previous experience of coding. However we are all here to help -that's what this community is all about. If you have a problem just ask. And be prepared for many many Sense crashes and resets! But hey, that's what dev mode is there for - another of co0kies little flashes of genius!
Right, that's just to give you all a hand with some basics! We are now open for business - ASK AWAY
Thanks Poy, Rat, Dunc, and all those involved with CHT and CHT widget dev.
This could prove to be very useful for anyone wanting to jump into making their own widgets and for collaborative efforts as well.
I look forward to seeing where this goes from here.
If I decide to add anything to the great info already posted, I will place it here.
Thanks for your efforts to get this going Poyensa.
Excellent thread, hope to try out the tutorial at some point.
At the moment interested in the toggle switches and how to make them, since it's not covered anywhere.
I've opened up rat_2665's toggle switch cab (hopefully that is ok - it is a good example).
The two key files are:
CHT_switch_DevMode.png
CHTlua_manila
The lua code is as follows:
Code:
Co0kieSwitchLink("DevMode Switch", "\\Windows\\CHT_switch_DevMode.png", _application.Store:GetValueChangedEvent(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode"), function(l_1_0)
if _application.Store:GetIntValue(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode") == 0 then
_application.Store:SetIntValue(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode", 1)
else
_application.Store:SetIntValue(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode", 0)
end
end
, function(l_2_0)
if _application.Store:GetIntValue(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode") == 0 then
return false
else
return true
end
end
)
From the above you can identify:
The switch title - "DevMode Switch"
The graphic - "\\Windows\\CHT_switch_DevMode.png"
Trigger - _application.Store:GetValueChangedEvent(Lifetime_Permanent, "CHTI.AddonWidgets.DevMode")
Action - function(l_1_0)
Switch position - function(l_2_0)
The setup.dll in the cab, sorts out the install side (as mentioned in the other posts).
Anyone know what lua file is the wifi switch? Or what regkey it monitors? Thanks.
Sorry if this info is written somewhere else, but I've not been able to find it so far.
meltwater said:
Anyone know what lua file is the wifi switch? Or what regkey it monitors? Thanks.
Sorry if this info is written somewhere else, but I've not been able to find it so far.
Click to expand...
Click to collapse
I would like to know that as well.
ai6908 said:
I would like to know that as well.
Click to expand...
Click to collapse
The wifi switch is in the Co0kieLink.lua file
Code:
Co0kieSwitchLink("[[IDS_WIFI_TOGGLE]]", "\\Windows\\CHT_switch_wifi.png", machineStatus.WifiOn.OnValueChanged
,function()
JMLComm("wifi")
end
,function()
return machineStatus.WifiOn.Value
end)
meltwater said:
Anyone know what lua file is the wifi switch? Or what regkey it monitors? Thanks.
Sorry if this info is written somewhere else, but I've not been able to find it so far.
Click to expand...
Click to collapse
ai6908 said:
I would like to know that as well.
Click to expand...
Click to collapse
Download CHT_AddonLinksKitchen.zip in post#6 of CHT2.0 thread. Inside \workspace\_lua\ you will find decompiled 6ADCC943_manila -- \windows\htc\home\scripts\home\chtlinksdev.luac with comments from co0kie
You beat me to it! BTW, Meltwater in the house - we are honoured
Making new links is actually way easier than making new widgets because there are only very small scripts involved and no mode9. You can either make new links to add in to the existing link sets (Miscellaneous, Toggles, etc) which is really straightforward, or you can create entirely new link sets. I have done both, adding new DatePicker and All People links into the Misc group, and making the new Page Switch Link set. Making a new set is also pretty straightforward although you also have to define the class and function, but most importantly each new set of links must have a unique link ID. This ID needs to be chosen and then notified to the CHT dev group in the Widgets discussion. If you don't have access to it then ask here and we'll provide you with one and feed it back to the dev group.
I can't remember what's in the kitchen Poy just linked to so I have attached my three kitchens below, along with a zip containing the CHT_quicklinks and freelinks luas and one of MichelDiamond's scripts for some of the links he added in for CHTS.
Again, any questions you have keep asking. We're waiting to see what amazing new stuff you come up with...
Dunc001 said:
You beat me to it! BTW, Meltwater in the house - we are honoured
Making new links is actually way easier than making new widgets because there are only very small scripts involved and no mode9.
... ...
Again, any questions you have keep asking. We're waiting to see what amazing new stuff you come up with...
Click to expand...
Click to collapse
Thanks guys. I did look at this when it was released, but found it difficult to get started with it.
That was my theory, make a few switches and get used to the plugins. Thought I could make some custom ones for switching on an in-car mode and various other things (switching into development modes for debugging the tabs would be handy too).
Obviously there is potential for using the stuff I've got for an improved RSSWidget and FbWidget but I'm still working out how to create stuff from scratch (but I am getting there).
Would be interesting to make a widget which displays set text items (perhaps a graphic too) from the registry, with callbacks to an app if pressed. That would be enough for a .net program to tie into, this is the basis of the RSSTab. Such a general widget could be used for a lot of things.
By the way, if you want to use some wiki space, feel free to carve out a chunk!
http://forum.xda-developers.com/wiki/index.php?title=WM6_HTC_Sense_Developer_Wiki
Have you got the CHT RSS widget kitchen? I'll upload it if not. If you could make a widget template for an updated rss widget or Facebook/Twitter widget to look/function in a similar way to the Android sense widgets that would be fantastic. Scrollable, with channel icon/Facebook pic beside each item, and also showing update time. Core CHT tasks and contacts widgets are already scrollable so all the necessary code should be available to copy/adapt. Let us know what you need any help with.
Dunc001 said:
Have you got the CHT RSS widget kitchen? I'll upload it if not. If you could make a widget template for an updated rss widget or Facebook/Twitter widget to look/function in a similar way to the Android sense widgets that would be fantastic. Scrollable, with channel icon/Facebook pic beside each item, and also showing update time. Core CHT tasks and contacts widgets are already scrollable so all the necessary code should be available to copy/adapt. Let us know what you need any help with.
Click to expand...
Click to collapse
I think I'll get my feet wet by doing some toggle switches first.
At the moment don't have the time to do the full widgets yet, got plenty that needs doing on the tab itself, but it would be great to get it all to tie in.
Well, the basics are done. If you miss something let us know. We also will try to bring here some tricks, fixes, mods, etc. And of course the answers for all your questions, excepting the date for next CHT update!
meltwater said:
Would be interesting to make a widget which displays set text items (perhaps a graphic too) from the registry, with callbacks to an app if pressed. That would be enough for a .net program to tie into, this is the basis of the RSSTab. Such a general widget could be used for a lot of things.
Click to expand...
Click to collapse
I totally agree with you.
I am monitoring this thread since its creation and I plan to investigate it when I will have more free time next week.
My goal: modify the RSSWidget to display feed informations from Google Reader (via the "Speeed Reader" application and probably a mortscript to parse the .xml and update registry).
kalhimeo said:
I totally agree with you.
I am monitoring this thread since its creation and I plan to investigate it when I will have more free time next week.
My goal: modify the RSSWidget to display feed informations from Google Reader (via the "Speeed Reader" application and probably a mortscript to parse the .xml and update registry).
Click to expand...
Click to collapse
Well I hope to integrate Google Reader into the RSSTab at some point.

[Q][SOLVED] PhotoChooserTask Mango Exception

A simple photochooser task application throws a Nullrefference exception(Invalid pointer) and pixel height and width is 0 on mango, on nodo it worked alright.
Am I missing a cast? or this is a bug in mango, and will be fixed?
Here's the code:
Code:
private PhotoChooserTask photo;
// Constructor
public MainPage()
{
InitializeComponent();
photo = new PhotoChooserTask();
photo.Completed += new EventHandler<PhotoResult>(photo_Completed);
}
void photo_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
//////////////////////////////////////////////////////////////////////////////////////
var wb = new WriteableBitmap(bi);//Exception here
/////////////////////////////////////////////////////////////////////////////////////
// bi.PixelHeight and bi.PixelWidth == 0;
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
photo.Show();
}
}
Hope someone can help.
Thanks in advance
This is because you need to set the CreateOptions property of the BitmapImage before you use it to construct the WriteableBitmap.
The default 'create' option on WP7 is DelayCreation (it may be BackgroundCreation in some of the 7.1 betas, but the mango RTM I think is DelayCreation) but either way the problem you're having is that your image has not been initialised yet at the point you use it in the WriteableBitmap's constructor (hence the null reference exception).
The options (depending what you set) let images be only initialised when needed, and downloaded on separate threads / asynchronously, which can help performance (or at least stop the phone blocking other things happening whilst images are loaded). Users also have the ability with the photo chooser to pick images from online ablums, so as you can imagine you also have to handle perhaps a second or two waiting for a download to complete, and of course downloads can also fail when connections drop etc. which you can handle too.
So in answer to your question (off the top of my head, not confirmed it with code) set the createoptions to none, and use the Bitmap's ImageOpened event to construct the WritableBitmap (you may also want to handle the Bitmap's ImageFailed event). Make sure you set up the ImageOpened event before you set the source, i.e.
BitmapImage bi = new BitmapImage();
bi.CreateOptions = BitmapCreateOptions.None;
bi.ImageOpened += new (some event name)
bi.ImageFailed += new (some event name)
bi.SetSource(e.ChosenPhoto);
Hope that helps,
Ian
Thank you very much
Problem solved
otherworld said:
This is because you need to set the CreateOptions property of the BitmapImage before you use it to construct the WriteableBitmap.
The default 'create' option on WP7 is DelayCreation (it may be BackgroundCreation in some of the 7.1 betas, but the mango RTM I think is DelayCreation) but either way the problem you're having is that your image has not been initialised yet at the point you use it in the WriteableBitmap's constructor (hence the null reference exception).
The options (depending what you set) let images be only initialised when needed, and downloaded on separate threads / asynchronously, which can help performance (or at least stop the phone blocking other things happening whilst images are loaded). Users also have the ability with the photo chooser to pick images from online ablums, so as you can imagine you also have to handle perhaps a second or two waiting for a download to complete, and of course downloads can also fail when connections drop etc. which you can handle too.
So in answer to your question (off the top of my head, not confirmed it with code) set the createoptions to none, and use the Bitmap's ImageOpened event to construct the WritableBitmap (you may also want to handle the Bitmap's ImageFailed event). Make sure you set up the ImageOpened event before you set the source, i.e.
BitmapImage bi = new BitmapImage();
bi.CreateOptions = BitmapCreateOptions.None;
bi.ImageOpened += new (some event name)
bi.ImageFailed += new (some event name)
bi.SetSource(e.ChosenPhoto);
Hope that helps,
Ian
Click to expand...
Click to collapse
Hello, I have the same problem (NullReferenceException) and have read you response, which from what I see it is the solution, but I have a problem; not where I have to go to do I change them that you propose. I would be so kind of explaining to me that I have to continue steps. It English me is very bad and I am using a translator.
I have HTC Trophy the v.th 7740.16 with chevrom and U2M7740 of Ansar.
Thank you in advance and greetings.
Hi,
If you upload your code / project I will take a look and see where the error is.
Si me muestras su código / proyecto, puedo ver por qué recibiras una excepción NullReference
Ian
otherworld said:
Hi,
If you upload your code / project I will take a look and see where the error is.
Si me muestras su código / proyecto, puedo ver por qué recibiras una excepción NullReference
Ian
Click to expand...
Click to collapse
Hello,
The question is that it is not any project, applications do not develop (although I would like). This type of errorr (nullreferenceexception) happens to me since I updated to Mango, so much in v.7720.68 as in v.7740.16 and happens in apps as Morfo, Fantasy Painter, and at the time of choosing fund in Touchxperience. Not if these apps are not conditioned to Mango or if, perhaps, from the record it might change some type of configuration or entering the Xaml of the app to be able to change some fact, end not...
For the little that, an error of the photochooser seems to be, the question is if it is possible to gain access to him and as doing it.
Anyhow thank you very much and a cordial greeting.
Hi,
If it is not a code issue then I do not know what it could be. Are you using a custom rom?
Good luck with it.
Ian
otherworld said:
Hi,
If it is not a code issue then I do not know what it could be. Are you using a custom rom?
Good luck with it.
Ian
Click to expand...
Click to collapse
Hello. Not, I am with official Mango the v.th 7740.16. I have already restored to factory and it continues the error. I believe that it is a question of the update, it must have a mistake in the pitcher of photos or some error with the librerie, do not know...
Thank you anyhow and greetings.
Hello, otherworld.
I continue with the same problem, 'nullreferenceexception' related with 'chooserphoto' in some application. The curious thing is that someone of them me work correctly, I gain access to me librery and it takes the photos, and in others not, as for example Morfo. I do not know if the problem is in the code source of these applications or phone is in me. Is this the code source of Morfo, is it possible to correct so that this does not happen?
Thank you in advance and greetings.

WP7 Shell, Console, Batch files interpreter

Hi Friends.
Standard Cmd.exe seems not working on WP7 probably by any restrictions, then we need own solution. There is a simple WP7 console (paied!!!), but this is childer game only, not a real working tool (some connection features from it are so usable).
There is one BIG problem on CE based systems - Shell context absention, especially Current Directory concept miss. Rainer Keuchel's CELib and Console solves it by ENVIRONMENT registry key, common for every console instance. Desktop Windows / POSIX systems concept of many unique shell contexts is very hard implementable here.There is not problem to make new context in registry - this can be unique key, contain all included processes IDs, environment structure and especially current directory path. But, somebody must release this context, when all processes finish. It can not be user applications dependent, any kernel "garbage collector" must be implemented for it. And, how to refer context to launched process? What do you mean about it - is better simple one context shell then nothing, or long work on multicontext solution?
Another problem is popen and pipes absention on WP7 system. I finished very simple solution last weak, based on stdout to file redirecting, which Microsoft forgets in WP7 API from WM6 one. Then we can make simply dedicated applications (dir.exe, set.exe, copy.exe, delete.exe etc.) in \Windows directory, callable by standard ShellExecuteEx, enrolling ouptut do stdout by printf etc. But, is it good solution? Have you got anybody real pipes working on WP7?
Working console appplication with bath files interpreter give us big possibilities for on-device attempts and programming, simple installators/deinstallators building, WP7 Perl, HaRET, Linux, WM, WinRT, WP8 wrappers working etc. It is not problem now to runs anything in kernel mode on WP7. Are you somebody able to cooperate include native coding? We can make real operating system from Microsoft fart bag named WP7.
Martin7Pro said:
Hi Friends.
Standard Cmd.exe seems not working on WP7 probably by any restrictions, then we need own solution. There is a simple WP7 console (paied!!!), but this is childer game only, not a real working tool (some connection features from it are so usable).
There is one BIG problem on CE based systems - Shell context absention, especially Current Directory concept miss. Rainer Keuchel's CELib and Console solves it by ENVIRONMENT registry key, common for every console instance. Desktop Windows / POSIX systems concept of many unique shell contexts is very hard implementable here.There is not problem to make new context in registry - this can be unique key, contain all included processes IDs, environment structure and especially current directory path. But, somebody must release this context, when all processes finish. It can not be user applications dependent, any kernel "garbage collector" must be implemented for it. And, how to refer context to launched process? What do you mean about it - is better simple one context shell then nothing, or long work on multicontext solution?
Another problem is popen and pipes absention on WP7 system. I finished very simple solution last weak, based on stdout to file redirecting, which Microsoft forgets in WP7 API from WM6 one. Then we can make simply dedicated applications (dir.exe, set.exe, copy.exe, delete.exe etc.) in \Windows directory, callable by standard ShellExecuteEx, enrolling ouptut do stdout by printf etc. But, is it good solution? Have you got anybody real pipes working on WP7?
Working console appplication with bath files interpreter give us big possibilities for on-device attempts and programming, simple installators/deinstallators building, WP7 Perl, HaRET, Linux, WM, WinRT, WP8 wrappers working etc. It is not problem now to runs anything in kernel mode on WP7. Are you somebody able to cooperate include native coding? We can make real operating system from Microsoft fart bag named WP7.
Click to expand...
Click to collapse
Pocket CMD from CE7 ARMv7 works fine via telnet. Tested on my Samsung Omnia 7 and Jaxbot's Samsung Focus. You can see it in action in this screenshot: http://windowsphonehacker.com/articles/all_in_a_days_work-03-03-13
Do I have to rename the zip tp xap and install normally?
No. If you don't know how to install it you probably don't need it as it creates a huge security risk on your phone.
Hmm... , interesting. The same exe in other configuratin I tested on my phones in the past with result : "Too much console ones work immediatelly, close any and try again".
Do you know (or is possible to code) telnet WP7 client, functioning on the same IP as server? Especially with hardware keyboard support?
Martin7Pro said:
Hmm... , interesting. The same exe in other configuratin I tested on my phones in the past with result : "Too much console ones work immediatelly, close any and try again".
Do you know (or is possible to code) telnet WP7 client, functioning on the same IP as server? Especially with hardware keyboard support?
Click to expand...
Click to collapse
Silverlight apps can not connect to localhost, it has been blocked.
Simple batch line interpreter
I tried cmd.exe batch and arguments calling, but it seems does not working for me. Then I will try own attempt.
Single batch line interpreter (*.bat files interpreting precursor):
SHLine.cpp
PHP:
// SHLine.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include <atlstr.h>
/*CString*/
#ifdef _DEBUG
#pragma comment (lib, "libcmtd.lib")
#else
#pragma comment (lib, "libcmt.lib")
#endif
/*CString*/
#include <list>
using namespace std;
typedef list<CString> StringList;
#define SEE_MASK_NOASYNC (0x00000100)
CString ErrorString(DWORD err)
{
CString Error;
try
{
LPTSTR s;
if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPTSTR)&s, 0, NULL) == 0)
{
Error.AppendFormat(TEXT("Error code : %X"), err);
} /* failed */
else
{ /* success */
LPTSTR p = _tcschr(s, _T('\r'));
if(p != NULL)
{ /* lose CRLF */
*p = _T('\0');
} /* lose CRLF */
Error = s;
::LocalFree(s);
} /* success */
return Error;
}
catch (...)
{
Error.AppendFormat(TEXT("Error code : %X"), err);
return Error;
}
}
HRESULT ShellExecuteWait(const wchar_t * file, const wchar_t * args, long lTimeout)
{
TRACE(L"ShellExecuteWait file=%s, args=%s, long lTimeout=%X\n", file, args, lTimeout);
try
{
SHELLEXECUTEINFO lpExecInfo;
memset(&lpExecInfo, 0, sizeof(SHELLEXECUTEINFO));
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = file;
lpExecInfo.lpParameters = args;
lpExecInfo.lpDirectory = _T("");
lpExecInfo.lpVerb = _T("open");
lpExecInfo.nShow = SW_MINIMIZE;
lpExecInfo.fMask = 0;
lpExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;// | SEE_MASK_FLAG_DDEWAIT;//0; lpExecInfo.hwnd = NULL;
lpExecInfo.hInstApp = NULL;//AfxGetInstanceHandle();
if(!ShellExecuteEx(&lpExecInfo))
{
DWORD err = GetLastError();
TRACE(L"ShellExecuteEx Error %d %s\n", err, ErrorString(err));
/// Sleep(100);
return (HRESULT)err;//ERROR_SUCCESS;
}
if (lpExecInfo.hProcess > 0)
{
TRACE(L"ShellExecuteEx WaitForSingleObject hProcess=%X\n", lpExecInfo.hProcess);
DWORD res = ::WaitForSingleObject(lpExecInfo.hProcess, lTimeout/*INFINITE*/);//5000);
TRACE(L"WaitForSingleObject lTimeout=%X, res=%X\n", lTimeout, res);
/// Sleep(100);
if (lTimeout != INFINITE && res != WAIT_OBJECT_0)
{
TerminateProcess(lpExecInfo.hProcess, 0);
TRACE(L"TerminateProcess;\n");
}
CloseHandle(lpExecInfo.hProcess);
}
TRACE(L"return ERROR_SUCCESS;\n");
return ERROR_SUCCESS;
}
catch (...)
{
DWORD err = 0x80070000 | GetLastError();
MessageBox(NULL, ErrorString(err), _T("ShellExecuteWait Error"), MB_OK);
return ERROR_SUCCESS;//(HRESULT)err;
}
}
StringList GetPathList(StringList & slPathList)
{
slPathList.clear();
slPathList.push_front(L"Program Files"); // Only for testing. HKCU\Environment PATH value will splitted instead;
slPathList.push_front(L"My Documents");
return slPathList;
}
CString GetCurrentDirectory(CString & csCurDir)
{
csCurDir = L"Program Files\\SHLine"; // Only for testing. HKCU\Environment CurrentDirectory value will readed instead;
return csCurDir;
}
bool FileExists(const wchar_t * file)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFile = ::FindFirstFile(file, &FindFileData) ;
bool bFound = (hFile && (hFile != INVALID_HANDLE_VALUE));
if(bFound)
{
::FindClose(hFile);
}
return bFound;
}
int _tmain(int argc, _TCHAR* argv[])
{
TRACE(L"_tmain(int argc=%d);\n", argc);
if (argc > 1 && argv[1])
{
CString csRunPath = argv[1];
CString csRunArgs = L"";
if (argc > 2 && argv[2])
{
csRunArgs = argv[2];
for (int i = 3; i <= argc; i++)
{
if (argv[i])
{
csRunArgs = csRunArgs + L" " + argv[i];
}
}
}
CString csCurDir;
GetCurrentDirectory(csCurDir);
HRESULT hRes = ERROR_FILE_NOT_FOUND;
CString csFN = L"\\"+csCurDir+L"\\"+csRunPath/*.GetString()*/;
if (FileExists(csFN))
{
hRes = ShellExecuteWait(csFN, csRunArgs/*.GetString()*/, 60000);
}
if (hRes == ERROR_FILE_NOT_FOUND)
{
csFN = L"\\"+csRunPath;
CString csWin = L"\\Windows\\"+csRunPath;
if (FileExists(csFN) || FileExists(csWin))
{
hRes = ShellExecuteWait(csFN, csRunArgs, 60000); // Full path specified or file is known for CE Shell (included to \\Windows\ directory)
}
if (hRes == ERROR_FILE_NOT_FOUND)
{
StringList slPathList;
GetPathList(slPathList);
DWORD dwPath = 0;
for (StringList::iterator itPath = slPathList.begin(); itPath != slPathList.end(); ++itPath)
{
csFN = L"\\"+*itPath+L"\\"+csRunPath;
if (FileExists(csFN))
{
hRes = ShellExecuteWait(csFN, csRunArgs, 60000);
}
}
}
}
TRACE(L"_tmain returns 0x%X;\n", hRes);
return hRes;
}
TRACE(L"_tmain returns E_INVALIDARG;\n");
return E_INVALIDARG;
}
This interpret will be uploaded to \Windows directory to be used by any appplication. One can be batch files interpreter (call this shell with all lines as paramters), or do any controlling (lines can contain controlling directives as cycles etc.). The .bat extension registering is soluted by CE standard way on unlocked phones.
CD.exe, DIR.exe, ..., etc programs will add standard shell functionality. Output (directories listing etc.) will soluted by stdout file forwarding.
In this way one only shell interpreting application (one current directory only) will allowed immeditelly. Better something then nothing.
EDIT:
I have got batch interpreter working. But, very strange behaviour occures:
1. AygShell does not add exe extension automatically. Then I copied "copy.exe" to "\Windows\copy" etc. It works well. But, it does not work for "start" directive! Start is necessary for Iexplore and other "uncloseable" applications launching to prevent interpreter hanging up. It is interesting too "start.exe" (or "start") everytime renames automatically to "Start" with upcased first letter. Probably "\Windows\Start.html" causes this system behaviour.
2. std::list iterating for multi batch lines interpreting crashes everytime, when lauchched application contains any messagebox. Iterating replacing by numerous cyclus soles it. Unbelievable...
I will publish XAP as soon as. Any filemanager can be used for batch lauching after instllation. I recommend Phone Commander, which is able not only launch, but also edit *.bat files.
Non XAP preliminary beta for testers
1. Copy included files to \Windows directory.
2. Apply registry changes by Batch.reg (can be did automatically from Phone Commander etc.).
3. Try tap to Example.bat from any filemanager (Phone Commander, WP7 Root Tools, wPhoExplorer etc.).
4. Make your own scripts (you can use also automatical shell creating function from Phone Commander menu, rename *.sh file to *.bat and edit it's content by Phone Commander "View" edit function by pencil icon).
"start" and "copy" directives only are implemented still. "copy" is implemented with source and destionation parameters only (copies everytime), switches will added in future versions.
start "filename" [params] = nonblocking shell starting
"filename" [params] (without "start") = blocking shell starting, it waits to application closing (danger for iexplore and any other "uncloseable" applications, use "start" instead). It blocks NonDDE shell directives, DDE (pword.exe, other Office applications, etc.) are nonblocking everytime by principle.
"copy" directive + *.reg files interpreter can be used for simple installator creating for your native applications.
The same principle will used for universal scheduler (for example "switch on wifi every monday morning, switch off ringing and wifi tethering every friday evening" etc.).
"SHLine" part is offered for all console application creators (it interprets one batch line). Use stdout file redirect and ShellExecuteEx(...,L"SHLine.exe",User console input line,...);
jessenic said:
Pocket CMD from CE7 ARMv7 works fine via telnet. Tested on my Samsung Omnia 7 and Jaxbot's Samsung Focus. You can see it in action in this screenshot: http://windowsphonehacker.com/articles/all_in_a_days_work-03-03-13
Click to expand...
Click to collapse
Thanks for a tip. There is working on device Telnet xap screenshot:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Xap release will published, when I solute HaRET and Pocket CMD listing switch.
XAP is released.
Download from HaRET WP7 thread.
Console Big Update - try Ping, IPConfig, NetStat, WLanUtils etc.
New Console7 version can offer to you many usable utilities, as cgacutil, etcha, ipconfig, ipconfig6, ipv6, kbdtest, msmqadm, ndisconfig, net, netlogctl, netstat, ping, rnaapp, route, services, shell, tracert, upnpreg and wlantool. With simply user interface you can write commands (or batch or Mort scripts) with big possibilities as on desktop Windows.
Console7 is not so dangerous as HaRET, but you still keep in mind that it can also destroy your operating system and possibly device ...
1. Install XAP.
2. Enable it by Root Manager.
3. Tap to Upeer screen part, tap to Menu button, slide menu left and select "Install pocketcmd shell etc."
4. Wait to reboot.
5. Wait to automatical Console7 start.
6. Type commands in bottom textbox and send it by Enter key. HELP command is available.
7. Try standard commands. Use help , help cmd commands to see full list.
8. Try additional features. Use help, for example:
ipconfig /?
Also copy, delete, etcha. ipconfig, ipconfig6, ipv6, kbdtest, launchuri, md, messagebox, msmqadm, ndisconfig, net, netlogctl, netstat, ping, reboot, regimport, rnaapp, route, services, shell, start, startback, tracert, upnpreg, wlantool directives are offered, some with help by /?.
9. Try Batch and Mort script making by PhoneCommander editor. Batch files (*.bat) are registered authomatically by Console7 installing. MortScripts installator will available as soon as.
10. When you want to risc device Hard Reset, try also "install haret and kernel driver".
11. Try HaRET/Shell switching by yellow buttons.
Remember: PocketCMD using is relatively safe (when you will not delete any system files or directories), but HaRET may be very danger still! Use both on your own risc.

[APP][DEV][09/04/13][4.0+]BuildBox Beta [0.9.5]

BuildBox Beta by MS Team HD Member Tectas
The main intend of this application is to provide an easy to use, but powerful way to serve updates and addons for developers to their users, but it doesn't stop there, it also can be used by the user itself as batch flashing tool for files on the internal or external sd (openrecoveryscript supporting recovery and root are prerequisite).
But please keep in mind, this is still beta stage, so far all is stable, but the code itself needs refactoring still and some additional features i want to add are still missing, also the included images are far from being great.
Why i built this?
The current alternatives public available seemed outdated and not as powerful as they could be, because of the fact that they are closed source i started to build something similar myself from scratch.
What does it serve?
Tabbed UI
Nested lists within the tabs (in theory infinite levels of nesting [but for usability i wouldn't recommend more than 5 steps])
Detail views with many optional fields, like description, changelog, developers, images,...
Completely remotly configured content using json
Optional Md5 verfification
Download queue
Sorting of download queue by drag & drop
Concurrent downloads to achieve full use of bandwidth (configurable amount)
Backup and restore of download queues
Support of every host with direct link capabilities
Support of hosts with up to 5 redirects (note: still direct link redirects, download webpages don't get handled)
Internal retry or resume (if supported by the server) functionality to avoid broken downloads because of unstable connections (up to 5 retries)
Direct install of apks
"External" link handling
Direct flash capabilities (if an openrecoveryscript supporting recovery is installed)
Adding of zips from storage to the queue
Backup/wipe options before flashing
Queue filter to only flash Successful/Done (Successful=downloaded+md5sum correct, Done=donwloaded+no md5sum provided) downloads (md5mismatches can optional be taken in as well)
Update notifications
Configurable interval for update check
Update version filter to avoid multiple notifications per version
New version check on startup
Image recycling and scaling (if an image is used more than once [identified by it's url], it will be downloaded only once and simply reused, also it will be scaled to the fitting size of the view to take as less bandwidth and ram as possible)
more to come...
Why json and not xml?
Xml is pretty good for local configuration, but json is the way to go when it comes to remote content.
It is highly mutable, lightweight and easy to use. Also the possibility for typos and errors is much less than with xml, because simple brackets and key value pairs are used instead of tags.
Last but not least, json files are about half of the sice of xml files if the same content is provided and the possible use of a webservice to provide it is pretty simple.
How to use as rom developer?
The application uses build.prop properties to configure rom update url, content url, rom version and default download directoy.
For update and content url there are also string resources present (to be able to publish the app to the play store to provide the rom itself with it e.g.).
All of this properties are optional (if they are not provided default values are taken).
Within a build.prop it would look like this:
Code:
buildbox.downloaddir=/storage/sdcard0/TestRom
buildbox.version=1.0.3c1
buildbox.updateurl=http://www.test.com/Rom.json
buildbox.contenturl=http://www.test.com/Content.json
The given serverside json files would look like this:
Content.json:
Code:
[{
"title":"Apps",
"device":"GT-I9300", [B]//optional, compared with the ro.product.model build.prop property, to shows items for specific devices only (can be put at every level inside the nesting of an item, except inside a detail item)[/B]
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Apps.png",
"children": [
{"title":"4.2 Camera/Gallery",
"detail":
{"description":"Aosp Camera from android 4.2 with sphere photo feature",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2Camera_App.zip",
"md5":"10cfc3983156d42a9dbafe7bc8265257"
}
},
{"title":"4.2 Clock",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2-Clock_App.zip",
"md5":"8334f1ed2ec79efbe4199a86fda7ee58"
}
},
{"title":"4.2 Keyboard",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2Keyboard_App.zip",
"md5":"de0d134795217b21ccbeb0f1b7dd3cdd"
}
}
]
},{
"title":"Bloat",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Bloat.png",
"children": [
{"title":"Calculator",
"detail":
{"webpages": [
"http://ms-team-hd.tectas.eu/download.php?file=Addons/Bloat/Calculator_App.zip"
],
"md5":"6adbc0077f7aac1f25ed584cff5c4d0e"
}
},
{"title":"SPlanner",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Bloat/SPlanner_App.zip",
"md5":"2949654d704a59cdbd17b7227b825d37"
}
}
]
},{
"title":"Themes",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Themes.png",
"children": [{
"title":"Battery Mods",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Battery.png",
"children": [
{"title":"Blue Battery",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueBattery.png",
"detail":
{"description":"Stock battery icon in blue made by raubkatze",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueBattery_Mod.zip",
"md5":"f1bc5f90dc284df34fb0c8d2d9044330"
}
},
{"title":"Blue Battery Percentage",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueBatteryPercentage.png",
"detail": {
"description":"Stock battery icon in blue with percentage made by thisiskindacrap",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueBatteryPercentage_Mod.zip"
}
},
{"title":"Blue Battery Circle",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueCircle.png",
"detail": {
"description":"Blue circle battericon with percentage in the center made by raubkatze",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueCircle_Mod.apk", //apk extension will be read and the install dialog will pop up
"md5":"c43c2734846ced3db5ed5987d5647bae"
}
}
]
},{
"title":"Framework Themes",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Apps.png",
"children": [{
"title":"Elegant Theme",
"detail": {
"describtion":"Eye-Candy Theme by ThilinaC",
"url":"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=0B8AYcerB14i3YVBmTEM4b0tzOVU",
"md5":"5e0d5a4578f01cfa8b357e79193f070b"
}
},{
"title":"MS Team Blackbean Theme",
"detail": {
"description":"Black and white theme made by alvin551",
"url":"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=0B8AYcerB14i3VmUwWTVKdWZ6UWM",
"md5":"93442e1fb4197e554ebdb1c8ff9c52a1"
}
},{
"title":"MS Team HD Theme",
"detail": {
"description":"Holo style theme. The theme is not originally created by MS Team HD, it uses parts of many other themes. All credits to the creators of the themes this is based on.",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/MS-Team-HD_Theme.zip",
"md5":"15eec7c80db7acbaccd939f827d806e9"
}
}
]
},{
"title":"Multiwondow Themes",
"children": [{
"title":"Multiwindow Blackbean",
"detail": {
"description":"Multiwindow theme made by alvin551",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-BlackBean_Mod.zip",
"md5":"4be1c0da1d77121de9627dd2570fee00"
}
},{
"title":"Multiwindow Black Glass",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-Glass-Black_Mod.zip",
"md5":"b8befba0558fdd954c8c73563761565c"
}
},{
"title":"Multiwindow Blue Glass",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-Glass-Blue_Mod.zip",
"md5":"d98c0cd04fc3240b372a78911a09c865"
}
}
]
}
]
}
]
Rom.json (which contains basically nothing less than a detailitem, means all optional properties used here can also be used at detail items within the Content.json):
Code:
{
"title": "MS Team HD", [B]//optional if parent item is present[/B]
"version": "9.0.1", [B]//optional[/B]
"description": "test", [B]//optional[/B]
"type": "zip", [B]//optional[/B]
"md5": "75a3a73d3ac941cc83f90dd80d000477", [B]//optional[/B]
"url": "http://ms-team-hd.tectas.eu/download.php?file=Rom/MS-Team-HD_9.0.1_XXEMA2.7z", [B]//optional[/B]
"webpages" : [
"http://forum.xda-developers.com/showthread.php?t=1886332",
"http://ms-team-hd.tectas.eu"
], [B]//optional[/B]
"images": [
"http://ms-team-hd.tectas.eu/Winscp-Screenshot.png"
], [B] //optional[/B]
"changelog": [
"change1",
"change2"
], [B]//optional[/B]
"developers": [
{ "tester": "" },
{ "tester2": "http://test" }
] [B]//optional[/B]
}
NOTE: if you simply want to take and alter this examples, remove the comments (everthing starting with //) they are not supported within json.
Common description:
At the content json all root items will be shown as tabs, everything inside them are listitems.
Every item containing another list of items must contain the "children" property.
Every item containing a detail item must contain the "detail" property instead.
Key Value pair description:
Common properties:
"title": "some value" -> this is the title of the chapter/listitem/detailitem (depends on the item type) (if the detailview doesn't contain a title property it will be taken from it's parent)
"thumbnailurl": "some url" -> this is the thumbnail shown at a listitem, it will be loaded asynchronous
"children": [ { some child items } ] -> this property is used to identify that this item contains another list
"detail" : { some detail properties } -> this property is used to identify this item as last item before a detail view is shown
Additional detail properties:
"version": "some version" -> sets the version (must not be inside the detail item, can also be inside his parent)
"description": "some text" -> sets the description (basic html notation can be used for formating)
"type": "zip" -> possible values are zip, apk, web, other, this will override the basic behaviour of parsing the mime type and will directly threaten it as the provided type [if external is used and the url property is given the url property will be taken for opening instead of the first webpages link])
"md5": "a md5sum" -> sets the md5sum of the package (only used for download verification if provided)
"url": "some url" -> the url where the item can be downloaded from
"webpages": [ "some url",
"some other url",
....
] -> if no url provided the first item of this array will be taken as external link, but in common provided as hyperlinks on the detail view to support pages
"images": [ "some url",
"some other url",
....
] -> used to show screenshots,... within the detail view (also loaded asynchronous)
"changelog": [ "a change",
"another change",
......
] -> to show a changelog, also supports html notation
"developers": [ { "some developer name": "" },
{ "another developer name": "some donation or profile page" },
......
] -> used to show the realted developers, if a donation or profile url is given the name will be shown as hyperlink, if it's empty as plain text​
Is it open source?
Yes, the java packges are licensed under lgpl, which means they can be integrated within every other application without publishing the source, only if the code inside the packages themself is altered the code has to be published. I have chosen this approach in the open sense of android, everyone is allowed to fork/clone my github repository and do whatever he likes with the code, i just want possible fixes or enhancements to be public available for everyone (also fell free to send me pull requests if you like), that's at least my view of what open source means, all should work together to make the best out of something, if they like to, otherwise, take what is already served or find someone able to do the needed changes.
Wait, two repositories? Why the hell...
Well, it's pretty simple, the library part already includes everything which is needed to get the work done, except of one thing, the main activity. It "only" includes an generic abstract activity which serves the fitting implementations to get it's job done without taking into account how the main activity is build up (be it tabed, with lists or whatever). To make your own UI set up on this activity it serves abstract methods you have to implement to handle e.g. viewing the download queue, updating it while downloading,...
But that's as well only a nice to have and should give you more possibilities if you want to use them, if your fine with the tabed UI I built, simply take the application repository, override the resources you like (if you want to) and your already done. I also splitted it up for easier maintenance, the library part is generic and if something needs to be done another way you're able to by simply deriving from the given interfaces or classes itself within your application, the application itself is always specific (even when the differences can be close to none), so i would have to integrate the changes of the library part allover again to the different branches, if it would be included in one single repository, that way all is detached and much easier to maintain.
Additional Information:
The source itself can be found here (Application) and here (library)
The generic apk (and screenshots) is also available at the play store (if you face any issues, pls don't leave bad reviews, just post it here or send me a pm/mail).
Changelog
The full list of commits can be viewed here (application) and here (library)
0.9.5:
Completely revised the structure of buildbox (is now splitted into 2 repositories, one for the library [includes the whole logic, main views,...] and one for the implementation of the main activity and for resource overriding [MainActivity, TabAdapter, ...)
Added device filter property (can be applied at every level except at the detail items) (uses the ro.product.model build.prop property for comparsion)
Many fixes and enhancements
0.9.3:
Fixed adding files from storage
Fixed crash at startup without internet connection available
0.9.2:
Apk handling fix
Recovery script fix
0.9.1:
Revised Install procedure for apks (thx to lowveld for the hint)
Fixed root shell command execution (sry)
small additional changes
one more just for fun
Just reading through the description is enough to see the level of thought that went into this. Well done mate!
I'll give this a shot later. I'm currently "on vacation" from rom development, but I can see this also as a optional plugin server for "normal" apps! I haven't gone through your github, but replacing the flashing hooks by package manager install procedures should be simple enough!
Cheers
lowveld said:
Just reading through the description is enough to see the level of thought that went into this. Well done mate!
I'll give this a shot later. I'm currently "on vacation" from rom development, but I can see this also as a optional plugin server for "normal" apps! I haven't gone through your github, but replacing the flashing hooks by package manager install procedures should be simple enough!
Cheers
Click to expand...
Click to collapse
Thx for the feedback and nice to see you here
Well, it is already possible to provide simple apk files and open the packagemanager after download to install them in two possible ways, assure that the mime of the file is apk and it will be threatened that way or simply pass at the detail view configuration "apk" as type and it will be also threatened like one.
But still a good idea to do the install at this point (currently the package manager is triggered when the download of the given apk is finished), the only problem is that all apk installs would be triggered at once (or one by one when the previous install finishes) , with the current behaviour there is at least a little delay and I would have to add a listener for the results of the install activities to be able to trigger the flash process when all apks are installed (or cancelled) and not like it is now, when the recovery script is written, all of this aren't groundbreaking things to implement.
I will keep this in the back of my head, but focus for now to get it out of beta
Edit: well, after thinking about it a bit more in detail, I decided to start to revise it the way you suggested, today evening, thx for the hint, that way it's more solid (and also a better user experience) and by making usage of interfaces also more variable for later additions
AW: [APP][DEV][28/03/13][4.0+]BuildBox Beta [0.9.1]
Update committed, play store update should be available in some hours (the attached one is already updated). Changelog at the second post and at github.
@the one who wrote the review, thx for it, I indeed kept updateme and some other similar apps and what they serve in mind while building this and simply added stuff I missed at those and tried to enhanced them where I thought stuff could be done better.
Edit: damn, sry, don't take the last version yet, I missed to uncomment a line (reboot to recovery isn't preformed when flashing files [can still be done manually though]) and misplaced a return instead of an continue (only affects you if you're testing own configurations with apks), will update it tomorrow morning.
Gesendet von meinem GT-I9300 mit Tapatalk 2
Fix update commited and attached binary also updated, play store update will be available in some hours.
AW: [APP][DEV][28/03/13][4.0+]BuildBox Beta [0.9.2]
Another fix.
Gesendet von meinem GT-I9300 mit Tapatalk 2
New update with loads of changes, the biggest are:
complete revision of the folder and repository structure
addition of a device property which can be applied to every item except detail items to show items/chapters for specific devices only, more info at the changelog and description
I'm still not where it would like to be with this, but anyway i opened a thread at the common android development section already. I will request this thread to be closed. Any further updates,... you wil find here.
Per OP request....This Thread is Closed.
You can find further progress in the new thread in the Android Software Development section:
[APP][DEV][09/04/13][4.0+]BuildBox Beta [ROM Developers][0.9.5]

Categories

Resources