Javascript coder wanted for help in the kitchen... - Windows Mobile Software Development

I (or rather, all of us...) need some code, and I've never really done any Javascript.
Could someone please code:
- Enable all controls on form 0 of a document.
- Walk through all the controls in order. For each control:
- Make a temporary string that holds the name of the control
- add a slash and the value of the control if it is a checkbox
- Walk through all the controls again
- Disable any controls:
- whose name is longer, but starts with the temp string above
- which are radiobuttons whose name is the temp-string
- done
This would disable any controls that do not apply when the user deselects a higher-level checkbox or radio-button, which would look much cleaner and cooler. I would have to spend most of today on this learning enough Javascript and fixing stupid beginner-bugs, and I would be disapointed if we don't have at least a few people here who can code this in 10 minutes.
Code can be tested by copying the form from the kitchen locally and creating a function to replace the submit placed at every checkbox or radiobutton control.

ok, consider this a beta
i did not follow your design in whole
but still i hope the functionality is the same
email me to [email protected] for any needed changes
my local time is 2:31 after midnight
uh uaah, good night
Code:
<html>
<head>
<script>
function setupDisable() {
var myForm = document.getElementById('myForm');
// enable all of them
for(var i=0; i<myForm.elements.length; i++) {
myForm.elements[i].disabled = false;
}
// foreach assign a tmpName
for(var i=0; i<myForm.elements.length; i++) {
var tmpName = myForm.elements[i].name;
if (myForm.elements[i].type == 'checkbox') {
// IMHO this is not needed and will break the functionality
// and this fact renders this whole cycle useless :)
// you can just use the name
// property in fuiction doDisable...
//tmpName += '/' + myForm.elements[i].value;
}
myForm.elements[i].tmpName = tmpName;
}
}
function doDisable(root) {
// disable all children
var myName = root.tmpName;
var myForm = document.getElementById('myForm');
if (!root.checked) {
alert('went off');
for(var i=0; i<myForm.elements.length; i++) {
var actName = myForm.elements[i].name;
if (actName.indexOf(myName) == 0 && actName != myName) {
myForm.elements[i].disabled = true;
}
}
} else {
alert('went on');
for(var i=0; i<myForm.elements.length; i++) {
var actName = myForm.elements[i].name;
if (actName.indexOf(myName) == 0 && actName != myName) {
myForm.elements[i].disabled = false;
}
}
}
}
</script>
</head>
<body onload="setupDisable()">
<form id="myForm">
<INPUT TYPE="checkbox" name="in1" onclick="doDisable(this)">in1
<INPUT TYPE="checkbox" name="in2" onclick="doDisable(this)">in2
<INPUT TYPE="radio" name="in2/1" value="1" onclick="doDisable(this)">in2/1
<INPUT TYPE="radio" name="in2/1" value="2" onclick="doDisable(this)">in2/1
<INPUT TYPE="radio" name="in2/1" value="3" onclick="doDisable(this)">in2/1
</form>
</body>
</html>

Related

DirectShow: Video-Preview and taking photo (with working code)

Questions
As mentioned in the text below the TakePicture() method is not working properly on the HTC HD 2 device. It would be nice if someone could look at the code below and tell me if it is right or wrong what I'm doing.
Introduction
I recently asked a question on another forum about displaying a video preview and taking camera image with DirectShow. The tricky thing about the topic is, that it's very hard to find good examples and the documentation and the framework itself is very hard to understand for someone who is new to windows programming and C++ in general.
Nevertheless I managed to create a class that implements most of this features and probably works with most mobile devices. Probably because as far as I know the DirectShow implementation depends a lot on the device itself. I could only test it with the HTC HD and HTC HD2, which are known as quite incompatible.
HTC HD
- Working: Video preview, writing photo to file
- Not working: Set video resolution (CRASH), set photo resolution (LOW quality)
HTC HD 2
- Working: Set video resolution, set photo resolution
- Problematic: Video Preview rotated
- Not working: Writing photo to file
To make it easier for others by providing a working example, I decided to share everything I have got so far below. I removed all of the error handling for the sake of simplicity. As far as documentation goes, I can recommend you to read the MSDN documentation about the topic. After that the code below is pretty straight forward.
Code:
void Camera::Init()
{
CreateComObjects();
_captureGraphBuilder->SetFiltergraph(_filterGraph);
InitializeVideoFilter();
InitializeStillImageFilter();
}
Dipslay a video preview (working with any tested handheld):
Code:
void Camera::DisplayVideoPreview(HWND windowHandle)
{
IVideoWindow *_vidWin;
_filterGraph->QueryInterface(IID_IMediaControl,(void **) &_mediaControl);
_filterGraph->QueryInterface(IID_IVideoWindow, (void **) &_vidWin);
_videoCaptureFilter->QueryInterface(IID_IAMVideoControl,
(void**) &_videoControl);
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, NULL);
CRect rect;
long width, height;
GetClientRect(windowHandle, &rect);
_vidWin->put_Owner((OAHWND)windowHandle);
_vidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
_vidWin->get_Width(&width);
_vidWin->get_Height(&height);
height = rect.Height();
_vidWin->put_Height(height);
_vidWin->put_Width(rect.Width());
_vidWin->SetWindowPosition(0,0, rect.Width(), height);
_mediaControl->Run();
}
HTC HD2: If set SetPhotoResolution() is called FindPin will return E_FAIL. If not, it will create a file full of null bytes. HTC HD: Works
void Camera::TakePicture(WCHAR *fileName)
{
CComPtr<IFileSinkFilter> fileSink;
CComPtr<IPin> stillPin;
CComPtr<IUnknown> unknownCaptureFilter;
CComPtr<IAMVideoControl> videoControl;
_imageSinkFilter.QueryInterface(&fileSink);
fileSink->SetFileName(fileName, NULL);
_videoCaptureFilter.QueryInterface(&unknownCaptureFilter);
_captureGraphBuilder->FindPin(unknownCaptureFilter, PINDIR_OUTPUT,
&PIN_CATEGORY_STILL, &MEDIATYPE_Video, FALSE, 0, &stillPin);
_videoCaptureFilter.QueryInterface(&videoControl);
videoControl->SetMode(stillPin, VideoControlFlag_Trigger);
}
Set resolution: Works great on HTC HD2. HTC HD won't allow SetVideoResolution() and only offers one low resolution photo resolution:
Code:
void Camera::SetVideoResolution(int width, int height)
{
SetResolution(true, width, height);
}
void Camera::SetPhotoResolution(int width, int height)
{
SetResolution(false, width, height);
}
void Camera::SetResolution(bool video, int width, int height)
{
IAMStreamConfig *config;
config = NULL;
if (video)
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
else
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
int resolutions, size;
VIDEO_STREAM_CONFIG_CAPS caps;
config->GetNumberOfCapabilities(&resolutions, &size);
for (int i = 0; i < resolutions; i++)
{
AM_MEDIA_TYPE *mediaType;
if (config->GetStreamCaps(i, &mediaType,
reinterpret_cast<BYTE*>(&caps)) == S_OK )
{
int maxWidth = caps.MaxOutputSize.cx;
int maxHeigth = caps.MaxOutputSize.cy;
if(maxWidth == width && maxHeigth == height)
{
VIDEOINFOHEADER *info =
reinterpret_cast<VIDEOINFOHEADER*>(mediaType->pbFormat);
info->bmiHeader.biWidth = maxWidth;
info->bmiHeader.biHeight = maxHeigth;
info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader);
config->SetFormat(mediaType);
DeleteMediaType(mediaType);
break;
}
DeleteMediaType(mediaType);
}
}
}
Other methods used to build the filter graph and create the COM objects:
v
Code:
oid Camera::CreateComObjects()
{
CoInitialize(NULL);
CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **) &_captureGraphBuilder);
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **) &_filterGraph);
CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_videoCaptureFilter);
CoCreateInstance(CLSID_IMGSinkFilter, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_imageSinkFilter);
}
void Camera::InitializeVideoFilter()
{
_videoCaptureFilter->QueryInterface(&_propertyBag);
wchar_t deviceName[MAX_PATH] = L"\0";
GetDeviceName(deviceName);
CComVariant comName = deviceName;
CPropertyBag propertyBag;
propertyBag.Write(L"VCapName", &comName);
_propertyBag->Load(&propertyBag, NULL);
_filterGraph->AddFilter(_videoCaptureFilter,
L"Video Capture Filter Source");
}
void Camera::InitializeStillImageFilter()
{
_filterGraph->AddFilter(_imageSinkFilter, L"Still image filter");
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, _imageSinkFilter);
}
void Camera::GetDeviceName(WCHAR *deviceName)
{
HRESULT hr = S_OK;
HANDLE handle = NULL;
DEVMGR_DEVICE_INFORMATION di;
GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E,
0x4D, 0x7E, 0x3C, 0x86 };
di.dwSize = sizeof(di);
handle = FindFirstDevice(DeviceSearchByGuid, &guidCamera, &di);
StringCchCopy(deviceName, MAX_PATH, di.szLegacyName);
}
Full header file:
Code:
#ifndef __CAMERA_H__
#define __CAMERA_H__
class Camera
{
public:
void Init();
void DisplayVideoPreview(HWND windowHandle);
void TakePicture(WCHAR *fileName);
void SetVideoResolution(int width, int height);
void SetPhotoResolution(int width, int height);
private:
CComPtr<ICaptureGraphBuilder2> _captureGraphBuilder;
CComPtr<IGraphBuilder> _filterGraph;
CComPtr<IBaseFilter> _videoCaptureFilter;
CComPtr<IPersistPropertyBag> _propertyBag;
CComPtr<IMediaControl> _mediaControl;
CComPtr<IAMVideoControl> _videoControl;
CComPtr<IBaseFilter> _imageSinkFilter;
void GetDeviceName(WCHAR *deviceName);
void InitializeVideoFilter();
void InitializeStillImageFilter();
void CreateComObjects();
void SetResolution(bool video, int width, int height);
};
#endif
Hey, in the FindInterface for the you're not checking the return code, which has to be S_OK; if not, the config is NULL and using config-> will cause your crash. If FindInterface for PIN_CATEGORY_PREVIEW is failing, try FindInterface for PIN_CATEGORY_CAPTURE.

C# Battery State

Hi Everyone,
I'm making a windows mobile app in C# to help those affected by alzheimers disease and other dimentia related conditions
One function of the app is sending SMS text messages and so I'd really like to include the battery charge percentage in each text, but I can't find how to do so!
How can I put this in my program?
Thanks!
James
Use PowerBatteryStrength of Status.SystemProperty!
I know it's something to do with
Code:
Microsoft.WindowsMobile.Status.SystemState.PowerBatteryStrength.ToString();
but beyond that I'm lost! How do I put it in to my code so that I just get the string "Battery level: 42%" for example?
Signal strenght and battery level example
Hi,
Here is a simple example on how you can use the SystemState and SystemProperties.
Hope this will help you.
Code:
using System;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Status;
namespace SignalAndBatteryLevel
{
public partial class BatteryAndSignalLevel : Form
{
private readonly SystemState _signalStrenght =
new SystemState(SystemProperty.PhoneSignalStrength);
private readonly SystemState _batteryLevel =
new SystemState(SystemProperty.PowerBatteryStrength);
private readonly SystemState _batteryState =
new SystemState(SystemProperty.PowerBatteryState);
public BatteryAndSignalLevel()
{
InitializeComponent();
SetSignalStrenght();
SetBatteryLevel();
_signalStrenght.Changed +=
SignalStrenghtChanged;
_batteryLevel.Changed += BatteryLevelChanged;
_batteryState.Changed += BatteryLevelChanged;
}
private void SignalStrenghtChanged(object sender,
EventArgs e)
{
SetSignalStrenght();
}
public void SetSignalStrenght()
{
_lblSignalStrenght.Text =
SystemState.PhoneSignalStrength.ToString();
}
private void BatteryLevelChanged(object sender,
EventArgs e)
{
SetBatteryLevel();
}
private void SetBatteryLevel()
{
_lblBatteryLevel.Text = GetBatteryLevel();
}
private string GetBatteryLevel()
{
string batteryLevel = "Unknown";
if (SystemState.PowerBatteryState ==
BatteryState.Charging)
{
return "Charging";
}
switch (SystemState.PowerBatteryStrength)
{
case BatteryLevel.VeryLow:
batteryLevel = "Very lowt";
break;
case BatteryLevel.Low:
batteryLevel = "Low";
break;
case BatteryLevel.Medium:
batteryLevel = "Medium";
break;
case BatteryLevel.High:
batteryLevel = "High";
break;
case BatteryLevel.VeryHigh:
batteryLevel = "Very High";
break;
}
return batteryLevel;
}
}
}
Hi PerOla,
This is really a good solution and working fine for me. Its really help me out in one of my project.
Thank you very much....
Vimal Panchal

Problem with Dynamic Pivot

Hello everyone,
I have a problem with Dynamic Pivot. I create Dynamic Pivot and binding data to it, but Pivot not display content.I tried using MVVM pattern to create Dynamic Pivot and it work well. But I still not know why is it worked (with MVVM).
But i don't want use MVVM pattern in this case. Please tell me know why it not work and how to fix it.
Please see below or download project demo (file attached) to more know . Thanks
XAML
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<controlsivot x:Name="PivotPlatform" Margin="0,0,8,77" Title="BindingDynamicPivotDemo" ItemsSource="{Binding PivotItems}" >
<controlsivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</controlsivot.HeaderTemplate>
<controlsivot.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding ImagePath}" />
<StackPanel>
<TextBlock Text="{Binding Address}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</controlsivot.ItemTemplate>
</controlsivot>
</Grid>
Code Behind:
public ObservableCollection<Food> PivotItems { get; set; }
public MainPage()
{
InitializeComponent();
// Set the data context of the listbox control to the sample data
//DataContext = App.ViewModel;
PivotItems = new ObservableCollection<Food>();
LoadData();
}
public void LoadData()
{
XDocument loadedData = XDocument.Load("food.xml");
List<Food> data = (from query in loadedData.Descendants("food")
select new Food()
{
Id = (int)query.Element("id"),
Name = (string)query.Element("name"),
Address = (string)query.Element("address"),
ImagePath = (string)query.Element("imagepath"),
Thumbnail = (string)query.Element("thumbnail")
}).ToList();
for (int i = 0; i < data.Count; i++)
{
Food food = (Food)data;
Food header = new Food { Name = food.Name, Address = food.Address, ImagePath = food.ImagePath };
PivotItems.Add(header);
}
}
If you use MVVM the DataContext is set to the MainViewModelSataSource (e.g.).
You have to set the DataContext to your MainPage code.
Code:
<phone:PhoneApplicationPage
[U]x:Name="mainPage"[/U]
x:Class="BindingDynamicPivotDemo.MainPage"
and
Code:
<controls:Pivot x:Name="PivotPlatform" Margin="0,0,8,77" Title="BindingDynamicPivotDemo" ItemsSource="{Binding PivotItems}" [U]DataContext="{Binding ElementName=mainPage}[/U]">
should work
By the way, this probably should go in the Software Development sub-forum. It's dev-related, but doesn't appear to be hacking-related and is more just a general app development question.
Moved to Software Development so you get a few more hits
If you use Caliburn Micro doing this is really simple.
http://caliburnmicro.codeplex.com/S...aliburn.Micro.HelloWP71/PivotPageViewModel.cs

Photochooser task not working after phone was synced with PC?

hello guys and girls,
I have a very peculiar problem with my application (two actually, working together to make a bigger problem)
I have a resume tile, which allows the users to resume working on the picture they were working after navigating away from the game.
Now, the users can choose pictures in their media lib to use in the game.
However, after i sync my phone to laptop, unplug it, then try to use the resume tile, it simply brings me to main page and does not continue doing the resume as it should do. This only happens with pictures from photochooser task: the ones integrated in the app work fine.
The photochooser task also refuses to work properly until i start the app "the usual way" and not from the resume tile. It basically goes back to the MainPage no matter what.
So, what's with all this? I think it has something to do with the syncing messing up isolated storage and phone storage.
here's some code:
MainPage:
Basically, I'm using some messages to know from where i navigated to the MainPage. The "resumeTile" message is obviously coming from the resume tile, whereas "FromPlay" means the player just left the play page.
App.IsFirstLoaded is used to known that it loaded already and should ignore the "ResumeTile" message and continue with the resume, but not to repeat the same feat in case the user navigates from any page in the game.
Code:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string msesage = null;
try
{
NavigationContext.QueryString.TryGetValue("message", out msesage);
if (msesage == "resumeTile")
{
App.isFirstLoaded = true;
}
if (msesage == "FromPlay")
{
NavigationService.RemoveBackEntry();
}
if (App.isFirstLoaded == true)
{
resume_SubmitResume();
App.isFirstLoaded = false;
msesage = null;
}
else
{
//NavigationService.RemoveBackEntry();
base.OnNavigatedTo(e);
if (msg == "openPlay")
{
string msggs = msg;
msg = null;
if (portrait)
{
NavigationService.Navigate(new Uri("/PlayPage.xaml?msg=" + msggs, UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msggs, UriKind.Relative));
}
}
}
}
catch (NullReferenceException)
{
}
}
and here is the photochooser task completed event handler
Code:
void photochoser_Completed(object sender, PhotoResult e)
{
string path = "mhgcjtcthgg.jpg";
if (e.TaskResult == TaskResult.OK)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication()))
{
if (e.Error == null)
{
if (App.AutoSave == true)
{
MediaLibrary ml = new MediaLibrary();
ml.SavePicture("CountlessPuzzles" + DateTime.Now.ToShortTimeString(), e.ChosenPhoto);
}
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
WriteableBitmap wb = new WriteableBitmap(bi);
if (wb.PixelHeight <= wb.PixelWidth)
{
Extensions.SaveJpeg(wb, fs, DHeigh, DWidth, 0, 100);
//NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msg, UriKind.Relative));
}
else
{
Extensions.SaveJpeg(wb, fs, DWidth, DHeigh, 0, 100);
//NavigationService.Navigate(new Uri("PlayPage.xaml?msg=" + msg, UriKind.Relative));
portrait = true;
}
}
}
}
msg = "openPlay";
}
else
{
isDataSavedInIsolatedStorage = false;
}
// e.ChosenPhoto.Close();
}
So, any ideas?
mcosmin222 said:
hello guys and girls,
I have a very peculiar problem with my application (two actually, working together to make a bigger problem)
I have a resume tile, which allows the users to resume working on the picture they were working after navigating away from the game.
Now, the users can choose pictures in their media lib to use in the game.
However, after i sync my phone to laptop, unplug it, then try to use the resume tile, it simply brings me to main page and does not continue doing the resume as it should do. This only happens with pictures from photochooser task: the ones integrated in the app work fine.
The photochooser task also refuses to work properly until i start the app "the usual way" and not from the resume tile. It basically goes back to the MainPage no matter what.
So, what's with all this? I think it has something to do with the syncing messing up isolated storage and phone storage.
here's some code:
MainPage:
Basically, I'm using some messages to know from where i navigated to the MainPage. The "resumeTile" message is obviously coming from the resume tile, whereas "FromPlay" means the player just left the play page.
App.IsFirstLoaded is used to known that it loaded already and should ignore the "ResumeTile" message and continue with the resume, but not to repeat the same feat in case the user navigates from any page in the game.
Code:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string msesage = null;
try
{
NavigationContext.QueryString.TryGetValue("message", out msesage);
if (msesage == "resumeTile")
{
App.isFirstLoaded = true;
}
if (msesage == "FromPlay")
{
NavigationService.RemoveBackEntry();
}
if (App.isFirstLoaded == true)
{
resume_SubmitResume();
App.isFirstLoaded = false;
msesage = null;
}
else
{
//NavigationService.RemoveBackEntry();
base.OnNavigatedTo(e);
if (msg == "openPlay")
{
string msggs = msg;
msg = null;
if (portrait)
{
NavigationService.Navigate(new Uri("/PlayPage.xaml?msg=" + msggs, UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msggs, UriKind.Relative));
}
}
}
}
catch (NullReferenceException)
{
}
}
and here is the photochooser task completed event handler
Code:
void photochoser_Completed(object sender, PhotoResult e)
{
string path = "mhgcjtcthgg.jpg";
if (e.TaskResult == TaskResult.OK)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication()))
{
if (e.Error == null)
{
if (App.AutoSave == true)
{
MediaLibrary ml = new MediaLibrary();
ml.SavePicture("CountlessPuzzles" + DateTime.Now.ToShortTimeString(), e.ChosenPhoto);
}
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
WriteableBitmap wb = new WriteableBitmap(bi);
if (wb.PixelHeight <= wb.PixelWidth)
{
Extensions.SaveJpeg(wb, fs, DHeigh, DWidth, 0, 100);
//NavigationService.Navigate(new Uri("/PlayPageLandscape.xaml?msg=" + msg, UriKind.Relative));
}
else
{
Extensions.SaveJpeg(wb, fs, DWidth, DHeigh, 0, 100);
//NavigationService.Navigate(new Uri("PlayPage.xaml?msg=" + msg, UriKind.Relative));
portrait = true;
}
}
}
}
msg = "openPlay";
}
else
{
isDataSavedInIsolatedStorage = false;
}
// e.ChosenPhoto.Close();
}
So, any ideas?
Click to expand...
Click to collapse
Photochooser does not work when the phone is syncing via zune, maybe once the app is running and you try to sync, PhotoChooser crashes or something.
http://www.codeproject.com/Articles/342149/Using-WPConnect-instead-of-Zune-for-Windows-Phone
I figured that when synced, the photochooser instantiated inside the app is turned off or something, and stays so until the constructor is called again, which would happen if the app is re-launched.
Kinda peculiar though...

Hooking a protected List in an Inner Class with an odd set of Parameters

So, I'm getting fairly good at hooking and modifying classes, but this one is so unique, I'm not quite sure how to approach hooking it to do what I want. Code for the method/class I want to attack:
Code:
private class CreateLaunchPointListTask
extends AsyncTask<Void, Void, List<LaunchPoint>>
{
private CreateLaunchPointListTask() {}
protected List<LaunchPoint> doInBackground(Void... paramVarArgs)
{
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
paramVarArgs = new LinkedList();
PackageManager localPackageManager = mContext.getPackageManager();
localObject = localPackageManager.queryIntentActivities((Intent)localObject, 129);
int j = ((List)localObject).size();
int i = 0;
while (i < j)
{
ResolveInfo localResolveInfo = (ResolveInfo)((List)localObject).get(i);
if (activityInfo != null) {
paramVarArgs.add(new LaunchPoint(mContext, localPackageManager, localResolveInfo));
}
i += 1;
}
return paramVarArgs;
}
public void onPostExecute(List<LaunchPoint> arg1)
{
synchronized (mLock)
{
mAllLaunchPoints.clear();
mAllLaunchPoints.addAll(???);
synchronized (mCachedActions)
{
LaunchPointListGenerator.access$502(LaunchPointListGenerator.this, true);
if (!mCachedActions.isEmpty()) {
((LaunchPointListGenerator.CachedAction)mCachedActions.remove()).apply();
}
}
}
LaunchPointListGenerator.access$602(LaunchPointListGenerator.this, true);
Iterator localIterator = mListeners.iterator();
while (localIterator.hasNext()) {
((LaunchPointListGenerator.Listener)localIterator.next()).onLaunchPointListGeneratorReady();
}
}
}
So, while this is a big chunk of code, everything I want to do is really in the first few lines:
Code:
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
So, string 2131558445 is a specific intent. What I would like to do is add *another* category after 2131558445 is added to localObject.
That would be the simplest implementation.
A more advanced implementation would be to actually and return a second LinkedList, paramVarArgs2, that only matches up to the second intent category that we're inserting.
Any help would be greatly appreciated.

Categories

Resources