How do I add my privacy policy link to the Windows Settings charm with Unity? - windows-8

Windows Store rule 4.1.1 mandate that:
You must provide access to your privacy policy in the Description page
of your app, as well as in the app’s settings as displayed in the
Windows Settings charm.
The Description page is easy, since when you setup your app in the store there's a field where you can enter the URL.
However I'm a bit clueless about how to add this entry in the Windows Setting charm in a Unity project. I've found this answer but that assumes you are in full control and knowledge of your Windows Store app, while I'm just exporting from Unity, so I've no clue on where I would put that code.
So, how do I do that?

Unity is exporting the game as JS or C#.
So have a look to these samples http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples. In these samples, there are a few Setting Charm screnios that you can use in your application.
But remember that, you should add setting charm after export the game.

The plugin prime31/MetroEssentials has the function registerSettingsCommand, which allows you to do just that.
// Registers a settings item with an associated message that will be displaed in a popup when clicked
public static void registerSettingsCommand( string title, string message )
// Registers a settings item with an action. When the settings item is clicked the action will be called.
public static void registerSettingsCommand( string title, Action onActivated )

Related

Changing language in UWP doesn't change system features language - only on app restart

I have a UWP application.
And i have a need to change locale on the fly, so i have this for language changing:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = language.FourDigitCode;
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();
But there is a problem that system features language doesn't switch ( only after application relaunch ) how can i fix it?
Here is an example:
Now i run this code:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "lv-LV";
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();
The UI gets localized, but system features still remain unlocalized:
But when i restart the app, all is OK:
Any ideas how can i fix it?
I'm afraid there is no fix for this and what you've seen is by design. Ref Remarks of PrimaryLanguageOverride property:
When you set the PrimaryLanguageOverride, this is immediately reflected in the Languages property. However, this change may not take effect immediately on resources loaded in the app UI. To make sure the app responds to such changes, you can listen to the QualifierValues property on a default resource context and take whatever actions may be needed to reload resources. Those requirements may vary depending on the UI framework used by the app, and it may be necessary to restart the app.
For your scenario, a restart is needed. I'd suggest that you can add a tip to tell users to restart the app and also a button to close the app like what used in News App.
And to close the app, we can call Application.Exit method like the following.
Application.Current.Exit();
Maybe page reloading can fix it? Try to re-navigate to the same page.
Found the example below here.
//like this
private bool Reload(object param = null)
{
var type = Frame.CurrentSourcePageType;
Frame.Navigate(type, param);
Frame.BackStack.Remove(Frame.BackStack.Last());
}
// or like this
private bool Reload(object param = null)
{
var frame = Window.Current.Content as Frame;
frame.Navigate(frame.CurrentSourcePageType, param);
frame.BackStack.Remove(frame .BackStack.Last());
}

Windows Phone ThemeManager

is it possible to for example - write a background service, which randomly changes the windows phone theme, I mean is it possible to access the windows phone theme under settings via code? and change it?
if so can you please give me an example of the API's I can use or additional libraries I can dl
thank you
Unfortunately you can't. It is not possible to change the Windows Phone theme by code. The only one who can is the user. This is part of the Windows Phone concept.
The only thing you can do is defining themes that are used in your own apps.
Sorry for the bad news...
You are allowed to change the theme for your application. There is a Nuget package available that makes this even easier. You could accomplish changing it in a background task by setting a property that you check when the app opens.
// background agent code
// get random value
IsolatedStorageSettings.ApplicationSettings["Theme"] = randomValue; // this is just a string or something simple
IsolatedStorageSettings.ApplicationSettings.Save();
When your app opens, you would check this value
var theme = "Standard";
if(IsolatedStorageSettings.ApplicationSettings.ContainsValue("Theme"))
{
theme = IsolatedStorageSettings.ApplicationSettings["Theme"];
// Set the theme
}
You can modify the source of the Theme Manager by downloading the source from github. Here is some more info on the Theme Manager. If you would like to change values yourself, you can accomplish this by setting the resource values when the papp starts
((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = myAccentBrush;
((SolidColorBrush)Resources["PhoneBackgroundBrush"]).Color = myBackgroundBrush;
((SolidColorBrush)Resources["PhoneChromeBrush"]).Color = myChromeBrush;
((SolidColorBrush)Resources["PhoneForegroundBrush"]).Color = myForegroundBrush;

Sharing StorageItems from a byte[] array

I want to implement the Share source contract in my WinRT C# Metro app (Windows Release Preview). My app is storing arbitrary files. Not in the filesystem, but instead I get the data over a WCF service as byte[]. Now I want to share such "files" in my app.
The only possibility I've seen with a standard data format is using the SetStorageItems() method on the DataPackage. Thus I'm facing the challenge to convert the data from my byte array to a StorageFile, which can be shared. I found the StorageFile.CreateStreamedFileAsync() method and wanted to use it in this way:
// filename: string
// fileContent: byte[]
// ... setting DataPackage title and description ...
DataRequestDeferral deferral = args.Request.GetDeferral();
var file = await Windows.Storage.StorageFile.CreateStreamedFileAsync(filename,
async stream => await stream.WriteAsync(fileContent.AsBuffer()), null);
args.Request.Data.SetStorageItems(new List<IStorageItem> { file });
deferral.Complete();
It compiles fine, but it doesn't work as expected. I've tried the sharing with the standard Mail app. The Mail share view opens and I can create a new mail. The file is shown without thumbnail (as expected), but the e-mail can't be sent. It's showing the sending progress for several minutes and then an error occurs: "Couldn't share {filename} with Mail.". The share charm shows "Something went wrong" and "[...] Mail can't share right now. Try again later.".
It works perfectly when I load the StorageFile from the file system: the mail opens and is sent within seconds, no problems here. So either I'm using CreateStreamedFileAsync() wrong or there's a bug in this method, what do you think?
In the callback passed into CreateStreamedFileAsync, you need to actually dispose of the object - that signals to the OS that you are done.
Wrote a complete example here
The Mail app is not a target for sharing files. From http://blogs.msdn.com/b/b8/archive/2012/06/14/building-the-mail-app.aspx: "Mail supports sharing text, links, and pictures."
Remember that there are 2 parts of the Share contract: Share sources and Share targets. As you know, there are many different data formats that can be shared between them, like text, pictures, URIs, and files. The full list of the different data formats that are supported is at http://msdn.microsoft.com/en-us/library/windows/apps/hh771179.aspx.
I recommend that you use the Share Target Sample app to test that your file is being shared properly - share to this and it will display everything that is being shared from your app as a source (and it does accept files for sharing). You can download it from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782. You can also use the Share Source Sample app as an example and leverage code from this app; you can download it from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Source-App-d9bffd84.
Hope that helps!
Ok, perhaps the preview version of the Mail app doesn't handle the sharing target contract correctly. Using the SDK sample app "Sharing Content Target App" from http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Target-App-e2689782, sharing a StorageItem created in memory with the StorageFile.CreateStreamedFileAsync() method posted above works fine.
Thus, that's the way you should go when you want to share in-memory byte[] arrays. For testing, make sure that the share target app doesn't run in Visual Studio when you want to share data from another app with it. Then the sharing sidebar mysteriously will disappear automatically...

Add dropdown to settings charm in Windows 8 Metro (C#)

I found how can I add command (looks like link) to settings charm:
SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
var cmd = new SettingsCommand("feedback", "Send feedback", new Windows.UI.Popups.UICommandInvokedHandler(x =>
{
App.ShowSendFeedback();
}));
args.Request.ApplicationCommands.Clear();
args.Request.ApplicationCommands.Add(cmd);
}
Now I need adding dropdown list for language selection to settings charm. How can I achieve it?
See also this blog post, which explains how you can display a custom user control whenever one of your settings are selected.
Basically, he moves an off-screen user control on-screen and then hides it again when user interaction is done. To me this feels kind of hack-ish... But I guess that's where WinRT is right now.
You can't add it directly to the Win8 UI. The idea is to publish 'command' links into the Win8 UI and then, when they are clicked, your app gets notified. At that point, you show your own UI with whatever widgets you want in it. See any of the Settings samples in the SDK for an example.

Calling App Expose In Lion

Is there any way to call App Expose in Lion programmatically, for example on an event tap, etc?
If you don't mind using a TOTALLY UNDOCUMENTED API, which might change at any point without notice:
void CoreDockSendNotification(CFStringRef, void *);
(...)
CoreDockSendNotification(#"com.apple.expose.front.awake", NULL);
Other known arguments are #"com.apple.expose.awake" and #"com.apple.dashboard.awake", which activate Mission Control and Dashboard, respectively. #"com.apple.showdesktop.awake" used to activate Show Desktop, but no longer works on current versions of macOS.
Note that most applications should not use these calls -- these actions are intended to be invoked directly by the user.
Expose does not exist in Lion, it has been merged with Spaces into the Mission Control application.
You can launch Mission Control:
[[NSWorkspace sharedWorkspace] launchApplication:#"Mission Control"];