Create a Notification window in Adobe AIR Application - actionscript-3

I want to create an AIR application in which i need to show the notification that when AIR application is minimize then at some interval of time message shows from the system tray similar like giving information.
I have visited this LINK, its a nice component but tutorial is not that much good as component. I need to create a component like that or source is available from this site so modification in this component will also be acceptable. so please help me.
EG: When you minimize the Yahoo Messenger and some one is sign-out or sign-in then it gives notification i want component similar like that...
Thanks in Advance

First Step, We have created a Custom Popup control for Notifications display.
In the second step, we have controlled the display of that popup using the following code
if(!this.stage.nativeWindow.visible || this.stage.nativeWindow.displayState == NativeWindowDisplayState.MINIMIZED)
{
stage.nativeWindow.alwaysInFront = true;
fadeTimer = new Timer(5000,1);
fadeTimer.start();
fadeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, fadePopUp);
popUpWindow = new PopUpWindow();
popUpWindow.isAlerts = true;
popUpWindow.Message = "<b>You have "+event.numNewMessages+" new notification messages<b>";
popUpWindow.type = NativeWindowType.LIGHTWEIGHT;
popUpWindow.open(true);
popUpWindow.fadeInEffect.play();
popUpWindow.nativeWindow.x = Capabilities.screenResolutionX - popUpWindow.width - 10;
popUpWindow.nativeWindow.y = Capabilities.screenResolutionY - popUpWindow.height - 35;
}
The condition used above is what we have used to find out, whether our application window is minimized to System Tray or not. Even though it is not a perfect fix, It didn't fail me yet. It's quiet stable for my app.

Related

Windows Phone 8 Live tiles Text & image update

I created an app for windows Phone 8 and want to implement Live tiles in my app. I don't even know anything about live tiles. I tried many examples from the forums and all.
But all are in the form of buttons(Like Flip, Cycle) If i click Cycle Button it will direct to the start screen to show the Cycle Tile.
But, How could i implement in my app. i want to shows the lives tiles only when user pins into the start screen.
anyone, help me to solve this????
Thanks in Advance.
The first thing you need to know is that LiveTiles on Windows Phone 8 can be implemented only from C#/.NET code, not C++. The native libraries don't have access to LiveTiles, so you need to use the .NET API.
Next... if your app is written in C++ with DirectX, you need to use XAML with Direct3D interop. This means you will have at least 2 VS projects, one using XAML/C#, the other using C++. LiveTiles will be updated through callbacks and delegates, sending events from the C++ component to the C# XAML component.
(If your app is using only C#/.NET, you don;t need any callbacks)
One more thing: the only type of LiveTile which always works on Windows Phone is FlipTile type. If you use iconic tiles, WP8 usually ignores colors, and shows only white&transparency.
Here is a snippet from my C++ component:
std:string dummyStd = "test string to display";
std::wstring dummyWs.assign(dummyStd.begin(), dummyStd.end());
Platform::String^ dummy = ref new Platform::String(separatorWs.c_str());
m_d3DInterop->OnLiveTilesUpdates(dummy);
and a snippet from the C# component:
public void OnLiveTilesUpdates(String s)
{
String szTitle = "title";
String szText = s;
ShellTile oTile = ShellTile.ActiveTiles.First();
{
FlipTileData oFliptile = new FlipTileData();
oFliptile.Title = "";
oFliptile.Count = 0;
oFliptile.BackTitle = szText;
oFliptile.BackContent = szTitle;
oFliptile.WideBackContent = szTitle;
oFliptile.SmallBackgroundImage = new Uri("/Assets/Tiles/FlipTileFrontSmall.png", UriKind.Relative);
oFliptile.BackgroundImage = new Uri("/Assets/Tiles/FlipTileFrontMedium.png", UriKind.Relative);
oFliptile.WideBackgroundImage = new Uri("/Assets/Tiles/FlipTileFrontHigh.png", UriKind.Relative);
oFliptile.BackBackgroundImage = new Uri("/Assets/Tiles/FlipTileFrontMedium.png", UriKind.Relative);
oFliptile.WideBackBackgroundImage = new Uri("/Assets/Tiles/FlipTileFrontHigh.png", UriKind.Relative);
oTile.Update(oFliptile);
}
Remember you need to bind the two snippets of code using events and delegates/callbacks (only if you use XAML with Direct3D interop).
Also, if you arrive here, you should know that the best component to use for rendering is DrawingSurface, because DrawingSurfaceBackgroundGrid has some z-order issues in WP8, and SwapChainBackgroundPanel is not supported in WP8.
PS: you should also do some research regarding secondary tiles.

Google Map V2 GIcon.shadow Image display in local development server but not from test server

I have custom marker icon (gif/png) to display on Google Map V2. I am using GICON and shadow property to set image path. The marker icons are diplaying as expected in development system. But after i deploy the system into server (Windows server 2008 r2, IIS 7.5), the icons are not displaying in some PC (not all). For some users the icons are displaying but for some users it is not displaying. I really appreciate all your help on this regard.
The code used is below :
var cm_baseIcon = new GIcon();
if (Records[i].Act == '1')
cm_baseIcon.shadow = "images/img/Markers/green.gif";
else
cm_baseIcon.shadow = "images/img/Markers/red.gif";
cm_baseIcon.iconSize = new GSize(27, 27);
cm_baseIcon.iconAnchor = new GPoint(9, 34);
cm_baseIcon.infoWindowAnchor = new GPoint(0, 0);
cm_baseIcon.infoShadowAnchor = new GPoint(13, 27);
var markerOpts = {};
var icon = new GIcon(cm_baseIcon);
markerOpts.icon = icon;
When I load your test page, I don't see any markers. Should the page create some markers when first loaded like this, or do I need to interact with the page in some way to get it to display any markers?
I set a breakpoint inside the initialize() function. Your Records variable is an empty array, i.e. []. So the for loop in this function that creates the markers never executes.
Do you know how to use the JavaScript debugger in a browser? It will let you figure out what is going wrong without having to ask anyone. I and other people here are happy to help, of course, but you'll make much faster progress if you can debug this on your own.
I recommend the developer tools in the Chrome browser. Here is a good introduction to the Chrome DevTools. Read through that and try out the JavaScript debugger in particular. You can stop your code and look at variables, change values, single step through the code to see what each line does, etc. This will at least double your productivity in JavaScript, and probably even more than that.

How does one implement pull-to-refresh with a LongListSelector in Windows Phone 8?

I am writing a new WP8 app using the off-the-shelf LongListSelector that is shipped in the Microsoft.Phone.Controls assembly. Can anyone provide a code example that implements pull-to-refresh, originally made popular by Tweetie for iPhone and now common on iOS and Android? The existing examples use non-standard controls and I'd like to maintain my use of LongListSelector in WP8.
EDIT
I have found a good answer on StackOverflow describing the Twitter sample and how to do this in more detail:
Continuous Pagination with LongListSelector
You do not.
Pull-to-refresh is not a standard Windows Phone interaction, and you therefore should not implement it.
No native/first-party Windows Phone application use this functionality, and almost no third-party application does either. There is a reason for that.
To refresh the content of a page (or in your case, a LongListSelector), you should use a refresh ApplicationBacIconButton, just like in the Mail app. That's the standard and preferred way to manage refreshes.
Windows Phone is not Android, nor is it iOS. Keep that in mind when designing an application for it.
It is not a zoo, there are rules.
Actually, I just discovered a project uploaded to the Windows Phone Dev Center on November 30, 2012 that implements "infinite scrolling" using Twitter Search and Windows Phone 8 LongListSelector.
Download this project at: http://code.msdn.microsoft.com/wpapps/TwitterSearch-Windows-b7fc4e5e
If you really must do this (see answer by Miguel Rochefort) then details can be found at http://blogs.msdn.com/b/jasongin/archive/2011/04/13/pull-down-to-refresh-a-wp7-listbox-or-scrollviewer.aspx
Basically, the ScrollViewer has hidden/undocumented states that allow for detecting "compression" at the top or bottom of the list and you can use this to trigger the loading.
This is not completely trivial, but one way of doing it is to use GestureService
this.gestureListener = GestureService.GetGestureListener(containerPage);
this.gestureListener.DragStarted += gestureListener_DragStarted;
this.gestureListener.DragCompleted += gestureListener_DragCompleted;
this.gestureListener.DragDelta += gestureListener_DragDelta;
However, it has some bugs. For example, DragCompleted is not always raised, so you need to double-check for that using ManipulationCompleted event, which seems to be more reliable.
containerPage.ManipulationStarted += delegate { this.manipulationInProgress = true; };
containerPage.ManipulationCompleted += delegate
{
this.manipulationInProgress = false;
PerformDragComplete();
};
Another issue is that DragDelta occasionally reports bad coordinates. So you would need a fix like this:
Point refPosition = e.GetPosition(null);
if (refPosition.X == 0 && refPosition.Y == 0)
{
Tracer.WriteLine("Skipping buggy event");
return;
}
Finally, you can find if list is all the way at the top:
public double VerticalOffset
{
get
{
ViewportControl viewportControl = this.FindChildByName("ViewportControl") as ViewportControl;
if (viewportControl != null)
{
Tracer.WriteLine("ViewPort.Bounds.Top=" + viewportControl.Bounds.Top + " ViewPort.Top=" + viewportControl.Viewport.Top.ToString() + " State=" + this.ManipulationState);
return viewportControl.Bounds.Top - viewportControl.Viewport.Top;
}
return double.NaN;
}
}
You can check out the samples in
https://github.com/Kinnara/WPToolkit
it has an excellent implementation something called a ListView extension of the longllistselector control, that will really help you out.
and remember with longlistselector always try to load 20 items atleast. =)
As the WP8 LLS doesn't use a scrollviewer, I guess you will have to inspect the UI tree to get a hold on the viewport control and see what you can do with ViewportControl.Viewport property ...
Oh ... the twitter application is now using the pull to refresh interaction. I like the UI guidelines of the WP platform but rules, once mastered, are made to be broken ;)
This post here can give you hints on how to get the viewport control and retreive the scrolling offset. this scrolling offset must be of a particular value when the list is bouncing

AIR > browseForSave strange behaviour

I just noticed something weird in my app.
I have a "save" button that triggers this function:
var saveFile:File = File.desktopDirectory.resolvePath(nameOfProject+".uct");
saveFile.browseForSave("Save as");
saveFile.addEventListener(Event.SELECT, saveFileToSystem);
When clicked, it display the "browse for save" window with a suggested name file.
Now I've noticed that when exporting, installing and running the app, when I click the button for the first time everything it's ok, but when I clicked again the location looks like this:
The "where" field is the same file....? And even if I click save, it doesn't save. The strange stuff is that this is not happening while testing my app in Flash Builder.
Any hint?
I did the workaround above, and it seems to do the trick. Code is something like this:
var saveFile:File = File.documentsDirectory.resolvePath("output.file");
var tempMovedAway:File = File.applicationStorageDirectory.resolvePath("temp.temp");
currentFileRenamedForAirBug = picker.clone();
currentFileRenamedForAirBug.moveTo(tempMovedAway), true);
saveFile.addEventListener(Event.SELECT, function():void {
tempMovedAway.deleteFile();
} );
saveFile.addEventListener(Event.CANCEL, function():void {
tempMovedAway.moveTo(currentFileRenamedForAirBug);
});
saveFile.browseForSave("save file");
// MUST be sure to call saveFile.browseForSave, or you risk losing an existing file.
You can wrap this lot in checks for the Air runtime (NativeApplication.nativeApplication.runtimeVersion) and Mac-only, to avoid doing this any more than necessary.
Also, if your file save code could rely on making changes to an existing file (rather than creating an entirely new one), you'll need to tweak this a bit.

Preload dynamically created views in Actionscript for Flex Mobile App

I've got the following problem, my boss wants me to make our app far more responsive without any waiting time between switching views. It used to a "standard" application based on a ViewNavigator but with just one View that was destroyed and re-created with different content based on the user's selection of tabs he created himself. Views were switched with the default SlideViewTransition. I'm down to half a second now with a slightly more lightweight approach as described below, however that half second is still too much.
The app is a tabbed application where the user can create and edit new views himself, so create/edit/delete tabs and their corresponding tabs.
My current implementation is based on a ButtonBar and a Group that is used to display the "views". The group's content is created based on the selected tab. The content is based on XML data that stores all the required information to build the "view". Naturally, removing and creating the component's takes a little while (the half second I talked about), so I'm after another solution.
What I thought about is using the ViewNavigator and create all stored views upon application start.
Very much like this:
for each (var _view:XML in _allViewsConfig.children()) {
var compView:View = new View();
compView.percentHeight = 100;
compView.percentWidth = 100;
compView.name = _view.label;
for each (var _groupElement:XML in _view.vgroup) {
var group:VGroup = new VGroup;
group.percentWidth = 100;
group.percentHeight = 100;
for each (var _windowElement:XML in _groupElement.window) {
var window:WindowContainer = new WindowContainer;
for each (var _componentElement:XML in _windowElement.component) {
var component:UIComponent = _componentManager.create(_componentElement.#type, _componentElement);
window.addElement(component);
}
group.addElement(window);
}
compView.addElement(group);
}
views.addItem(compView);
}
views is an ArrayList that is used to store the created views.
The only problem I've got right now is that I can't use the Views stored in this ArrayList in the corresponding ViewNavigator.
I tried it the usual way, i.e. navigation.pushView(_viewCreator.views.getItemAt(0) as Class);
This, however doesn't work, no error or anything, the ViewNavigatorjust doesn't do anything, so I guess that a View class can't be created like this.
So how can I make this work?
Also, do you guys think that this is a proper solution to the problem, especially considering the whole dynamic nature of the application (being based on tabs)?
Naturally, slide transitions will be completely disabled as they are quite slow with our complex components.
Any help, comments or thoughts would be greatly appreciated!
EDIT:
On second thought, simply using Groups instead of ViewNavigator and View should make this a little more lightweight and solve the issue of views not being pushed.
In fact ViewNavigator pushView() is a mechanism which create an instance of a given Class (method parameter).
For all navigation history purpose, ViewNavigator uses NavigationStack objects to store relevant values (that you can customize too).
I don't have a straightforward answer for you, but I think you'll have to implement your own custom ViewNavigator mechanism (extending ViewNavigator to leverage existing useful methods and override others).