Is it possible to set a subject to the mail app in Windows 8 metro application, if I am using share contract and sharing files? - email

First of all, I am sharing the content from my windows 8 metro application to another app (for example Mailto app) so:
Now I am sharing files to mailto app using share contract and sharing files from my application,
I wanted to know if: -
Can I set the subject to the mailto app to which I am sharing files as an attachement to that mailto app, if so please let me know how can I do this?
If not, please let me know what is the work around?

As of now, it's not possible.
Windows 8 recently introduced a new API called protocol activation. With Protocol activation, you can launch other windows 8 apps from your application and pass in data. Microsoft worked on Maps app and you can now pass information to the Map app as shown here (URI Scheme for maps application) http://msdn.microsoft.com/en-us/library/windows/apps/jj635237.aspx
See a code walkthrough at http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html
Now, i am sure very soon, you will see some custom parameters for Mail app that you can pass from your app using protocol activation.
Just my 2 cents

No, it isn't possible to do this at the moment.

I may not be understanding the question correctly but if all you want to do is have the ability to click the "Share" button on the Charms Bar, then select the "Mail" app and have the ability to populate the subject line shown when the "Mail" app's share fly-out is displayed then you can follow this approach:
private DataTransferManager dataTransferManager; //class member
// put the following code block wherever you need it:
// Register as a share source
if (this.dataTransferManager == null)
{
this.dataTransferManager = DataTransferManager.GetForCurrentView();
this.dataTransferManager.DataRequested -= this.OnDataRequested;
try
{
this.dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.OnDataRequested);
}
catch
{
};
}
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
DataRequestDeferral deferal = request.GetDeferral();
try
{
// this property will set your subject line
// it will also be shown on the Share fly-out (right below the main
// heading that says 'Share'
request.Data.Properties.Title = GetCustomMailSubjectLine();
if (string.IsNullOrEmpty(request.Data.Properties.Title))
{
request.FailWithDisplayText("An operation failed. Please try again.");
}
else
{
// this will also be shown on the Share fly-out, right below the 'Title'
// property set above
request.Data.Properties.Description = GetMyAppsSharingDesciption();
// use request.Data.SetDataProvider() if your data needs to be asynchronously retrieved
// otherwise directly use request.Data.SetData() (or one of the other
//methods depending on what you need)
request.Data.SetDataProvider(StandardDataFormats.Html, RetrieveSharedData);
}
}
finally
{
deferal.Complete();
}
}
private async void RetrieveSharedData(DataProviderRequest request)
{
DataProviderDeferral deferal = request.GetDeferral();
try
{
// this will set your email's body
request.SetData(await GetCustomMailBodyAsync());
}
finally
{
deferal.Complete();
}
}

Related

Why does the YouTube IFrame API for iOS devices send messages with a youtubeplayer:// protocol?

I am trying to use pieces of the YouTubePlayerKit for a project I am working on. It looks like the library does the following:
Creates a player instance from a videoId
Creates a webview to load the video in
Evaluates some JS to get the video loaded
Re: the 3rd step, I was browsing the source code and i saw this function:
// Send YouTubePlayer Event with optional data
function sendYouTubePlayerEvent(event, data) {
var locationHref = 'youtubeplayer://' + event;
if (data) {
locationHref = locationHref + '?data=' + data;
}
window.location.href = locationHref
}
What I can't understand is, why are they using a youtubeplayer:// protocol? Is it inferring where to send events based on the name of the player class? Just for reference, I was looking at this library as well, and they use the protocol ytplayer://. What's going on here?
ytplayer:// is the start of a URL
https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app
https://developer.apple.com/ios/universal-links/
From the looks of your code it would ultimately look like
youtubeplayer://play?data=fghdfgjhdfgjdfgj
With fghdfgjhdfgjdfgj being some data object.
window.location would take that URL and do something with it like set the location of the current view or direct the webview to that website.
If you look at the code for the "Widget Code Along" You will find a good example for this setup, they only glance over it in the video but a
Link in a Widget uses a URL to open the detail view of a character.
https://developer.apple.com/news/?id=yv6so7ie

Using uni_links when the app is in the background

My application has the following structure:
- InheritedWidget for dependencies
--> Splash Screen Page
--> Login Pages
--> Main Pages
When the app runs for the first time, I can use var link = await getInitialLink(); to get the value for the link that opened the app.
However, I cannot get the same result if I open the app on the background.
I tried to use
getLinksStream().listen((link) => (link) {
try {
var _latestUri;
if (link != null) _latestUri = Uri.parse(link);
print("=== Formated successfully a link!");
} on FormatException {
print("--- A link got here but was invalid");
}
});
For getting the link in the Splash Screen, but if the app is already open in the Login or Main pages, it won't go through the Splash Screen again.
Then, I tried to put it in the InheritedWidget, but alas, didn't get any result whatsoever.
So my question is: Where and how should I set up uni_links so that I can catch all incoming links even if the app is open?
Or better, is there an alternative for App Links/Universal Links that I can use?
Though it's not the best and most elegant way, I got around this.
First, I was not using getLinksStream correctly
Instead of
(link) => (link) {...}
It's
(link) {...}
Then, I need to put this subscription in my Splash Screen and do not dispose of it, so that it can listen to new events.
If anybody has a better solution, please free to add it
For this situation, you need to use both of getInitialUri() and getUriLinksStream(),
If app launchs directly u will get uri from getInitialUri, if app already running on background u will get uri from getUriLinksStream.

Programmatically minimize all windows or besides my Cocoa application?

I haven't been able to find anything about this in Swift. Is there a way to programmatically make my application minimize all other windows open in the background, or even just minimize Safari? I basically want my application to run against the desktop, without any clutter in the background. Is there a way to programmatically do this for a Cocoa app? I'm pretty new to swift, so any help would be appreciated.
You can use api on NSWorkspace which allows you to hide all visible app in the background.
You can find more about NSWorkspace here: link
Hides all applications other than the sender. This method must be called from your app’s main thread.
NSWorkspace.shared().hideOtherApplications()
If you only want to hide Safari,
let appPath = NSWorkspace.shared().fullPath(forApplication: "Safari")
let identifier = Bundle.init(path: appPath!)?.bundleIdentifier
if let bundleID = identifier {
let runningApps = NSRunningApplication.runningApplications(withBundleIdentifier:bundleID )
if !runningApps.isEmpty {
runningApps.first?.hide()
}
}

google chrome app script ask to save as userAppPanel

I encounter a problem using UIApplication in google app script, but only on Chrome 18.0.1025.142 m, my application works fine on Firefox 3.6, and also on chrome 16.x.x.
I updated my chrome version to 19.0.1084.56 m. And the problem still occurs.
On Chrome 18.0.1025.142 m and 19.0.1084.56 m, I have the following behaviour:
A blank frame is displayed over my spreadsheet when I try to display the UI Application and I'm asked to perform a "Save As" operation for an object userAppPanel.
On Chrome 16.x.x or Firefox 3.6, I have a UI application with a panel, a textbox and a button.
Here is my application creation code:
// Create my application
var mydoc = SpreadsheetApp.getActiveSpreadsheet();
var myapp = UiApp.createApplication();
myapp.setTitle("Translation selector");
// create panels, text boxes and widgets
var mypanel = myapp.createVerticalPanel();
// Create input boxes and button
var textBoxA = myapp.createTextBox();
textBoxA.setName('Input search filter here').setId('SearchText');
var MyButton = myapp.createButton("Fill the tables");
mypanel.add(textBoxA);
mypanel.add(MyButton);
// create handler to respond to events
var clickHandler = myapp.createServerClickHandler("respondToSubmit");
MyButton.addClickHandler(clickHandler);
clickHandler.addCallbackElement(mypanel);
// assemble everything in app
myapp.add(mypanel);
//mydoc.show(myapp);
//return myapp;
var doc = SpreadsheetApp.getActive();
// show the app
doc.show(myapp);
}
I've a similar issue on Chrome 21.0.1180.89 for OSX. Working with a mail merge script which worked perfectly on a, similar up-to-date, chrome on Win8 just a few hours ago.
I'm pretty sure it's a security issue.
De-authorising the app (under account->security) and then reloading the script and re-authorising it helps. Not sure if it's on a per-browser level or something else..
Kindly Add this Code,
As per your question, It works on chrome.
function saveTextAsFile()
{
var textToWrite = document.getElementById('area').value;
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = "ecc.plist"/*Your file name*/;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href =
window.webkitURL.createObjectURL(textFileAsBlob);
}
else
{
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
I have some users of a script I've developed, FormEmailer (available in the Script Gallery) that are also having this problem. But we were not able to nail the situation that generates this yet.
Is the spreadsheet you're testing yours? Or is it shared and you're not the owner? Do you have other scripts projects on this same spreadsheet? Are you the owner of all scripts?
(I think it's better if you change you edit your question and I my answer, instead of talking in the "limited" comments).
I have the same problem :
More details about this after a few tests. It seems it is due both to user triggering the script to execute, as well as characteristics of the trigger :
- if the function is called from a custom menu in a spreadsheet, everything works fine for everyone
- if function is called onOpen(), everything works fine for everyone
- if an installable onEdit or onOpen trigger has been set on the function, then everything works fine for the person who set it, and bad for others.
The last behavior is observed whether that person is owner or not.
Basically it seems the only times when it doesn't work well is when someone opens or edits a spreadsheet and the function is triggered by an installable trigger installed by somebody else.
This is a pain.

GWT - Fullscreen

Is there a way to start a gwt-app in fullscreen mode (without toolbar, navigation)?
I found only a hint to open a new window:
Window.open("SOMEURL","SOMETITLE",
"fullscreen=yes,hotkeys=no,scrollbars=no,location=no,menubar=no,status=no,
toolbar=no,resizable=no");
Is this the only way?
If yes, what's the best way to use the "Window.open" (Example)?
This works for me:
private native void requestFullscreen() /*-{
var element = $doc.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}-*/;
This isn't really a GWT question - this is a browser-provided API that GWT happens to wrap for you.
It's worth noting that modern browsers have a tendency to ignore some or all of these flags. For example, good luck getting Chrome to hide its address bar. The reason for this is that if they honoured all of the flags, you could write a web app which looked exactly like a desktop app and the user wouldn't know it - which is exactly what you sound like you're trying to do!
or use https://github.com/wokier/gwt-fullscreen
Caffeinate response has been used as a basis. I also added an event to be notified of fullscreen state change.