TouchID: What's the difference between fallback (enter password) and cancel? - ios8

I'm integrating TouchID into my app, but I don't get the difference between the two buttons enter password and cancel. They result in an error of LAErrorUserCancel or LAErrorUserFallback, but I can't handle them differently, so I'd like to avoid one of the two buttons. Is there a way to do this? Or what's the best practice here?
1Password is an example here; both buttons the user gets presented are leading to the same action - that you have to enter the password into the app manually. In my opinion it would make sense to have only one button here.

It is super easy to remove the "Enter Password" button if you don't need it for your application. Just set the localizedFallbackTitle property to an empty string, not nil, and the button will not be display.
LAContext *context = [[LAContext alloc] init];
context.localizedFallbackTitle = #"";
(You can't also set it to something more appropriate for your application if you need to, just put the string in there.)
Note: to actually answer the question as posted, not to answer the comment that that OP left on the other answer... the fallback case is useful when the user has decided to not use TouchID but would rather enter a password to gain access to your locked service. You would test for this in the evaluatePolicy message.

If the touchID alert view is displayed from the same VC that contains the password field, both options would accomplish the same. But think in cases where you have workflow where you can cancel the full authentication operation (LAErrorUserCancel) or display a login view controller(LAErrorUserFallback).

Related

How to specify a particular order of buttons in a JavaFX 8 Alert

I need to ask the user to confirm doing an action. The set of buttons of the confirmation dialog are "Yes", "No" and "Cancel". My code is below:
private ButtonType askYesNoCancel(String question) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setContentText(question);
alert.getButtonTypes().setAll(ButtonType.YES,
ButtonType.NO,
ButtonType.CANCEL);
return alert.showAndWait().get();
}
which gives me
The problem I am facing is that regardless in what order I specify the ButtonTypes for an Alert, I get the same button order (No - Cancel - Yes). I took a look at API documentation for Alert, Button and ButtonType, alas, not to find an answer.
What I try to accomplish, is the button order Yes - No - Cancel. Any advice?
Example if you really need to specify button order...
private static class FixedOrderButtonDialog extends DialogPane {
#Override
protected Node createButtonBar() {
ButtonBar node = (ButtonBar) super.createButtonBar();
node.setButtonOrder(ButtonBar.BUTTON_ORDER_NONE);
return node;
}
}
And then when you create your Alert.
alert.setDialogPane(new FixedOrderButtonDialog());
Check the answer to: Enter Key Event Is Not Working On Dialog In Javafx?, though I guess that answer more appropriately belongs with this question and perhaps doesn't fully explain what is going on. Also read the ButtonBar javadoc.
Basically, the button position is determined by a combination of the ButtonType of each button and the ButtonBar's buttonOrder. By changing either of these things, you will end up with different button layouts.
As I recall, customizing the ButtonBar was kind of tricky. You might need to subclass the alert and override createButtonBar.
What I try to accomplish, is the button order Yes - No - Cancel. Any advice?
My advice is: Don't try to customize the button order, but let the system default order be applied. The button order has already been preconfigured to match the standard button layout for dialogs for various operating systems. Reordering the buttons to deviate from that standard may make your application just slightly more confusing for users (that's a pretty subjective opinion though).
This is a modified version of #Adam solution. Advantage - no need in extra class, no need to remove existing dialog pane with all its content.
ButtonBar buttonBar = (ButtonBar) alert.getDialogPane().lookup(".button-bar");
buttonBar.setButtonOrder(ButtonBar.BUTTON_ORDER_NONE);

Windows Phone 8: How to bind Data?

I have a question about WP8 coding. I have a TextBox for numbers. I want calculate with the number (who has been typed in the box) on another Page. This means, that I don t want to show the number on the next Page, I want to get access to the typed value.
So what is the best way to do this?
Thanks to all answers!
Your question not seemed very clear to me. But if you are asking how to pass data between pages, you can do:
NavigationService.Navigate(new Uri("/destinationPage.xaml?dataName=",value));
In the destination page you can access the data this way:
string targetValue;
If(NavigationContext.QueryString.TryGetValue("dataName", out targetValue))
{
//targetValue will contain value, you can do anything with it
}
DataBinding to controls is different thing:
<TextBox Binding={tBoxValue, Mode = TwoWay} x:name="tbox"/>
Now in code consider presenter is an object, which contains a property tBoxValue:
If you do:
tBox.DataContext = presenter;
You can access the data entered in the TextBox via presenter.tBoxValue;

ReactiveCocoa - observing isFirstResponder property and UITextField with clearsOnBeginEditing set to YES

I am new to ReactiveCocoa, but I think it's very nice and outstanding technique for reducing code complexity. I just started experiencing with the framework, and not everything is clear for me at the moment, so excuse me if my problem can be solved in some obvious way.
In my app I have login view controller with simple form contains two text fields (username and password) and a button. I would like the button to be disabled if any of two text fields is empty. So, I wrote this code:
RAC(self.loginButton, enabled) =
[RACSignal combineLatest:#[self.userTextField.rac_textSignal,
self.passwordTextField.rac_textSignal]
reduce:^(NSString *username,
NSString *password) {
BOOL valid = (username.length > 0 && password.length > 0);
return #(valid);
}];
It's very simple and it's working. The problem is that one of my text fields (the password field) has secureTextEntry and clearsOnBeginEditing properties set to YES. I will try to explain unwanted behavior that I am experiencing with this configuration:
Let's assume that both username and password fields are NOT empty. In this case the button is enabled. When user taps on password field, it becomes first responder (keyboard appears and user can enter his password), but because of clearsOnBeginEditing being set to YES for that field, the previously entered password is cleared from the text field. That's way password field is now empty. The problem is that signal is not being sent, so the button remains enabled, despite the password field is empty.
My first idea to solve this issue (well, more like workaround solution) was to observe isFirstResponder property on password field beside observing text changes. That's way the block that checks if button should be enabled would be called when password field becomes first responder. I don't know if this solution works, because I have no idea how to implement it using ReactiveCocoa. I have looking for creating a signal for isFirstResponder property changes, but without a luck. It might be not the best approach in order to solve this issue, but nothing comes to my mind at this point.
Then, the question is: how to observe isFirstResponder property with ReactiveCocoa?
And more general question: how to observe text field's text changes when clearsOnBeginEditing is set to YES?
UPDATE:
I found out that I can create signal for UIControlEventEditingDidBegin event that should give me substitution of observing isFirstResponder property changes:
[self.passwordTextField rac_signalForControlEvents:UIControlEventEditingDidBegin]
Unfortunately this does not solve the issue. Now I understand that field is cleared AFTER it becomes first responder, and clearing field automatically after it becomes first responder does not send signal for text changes. That's way when validation block is executed it still thinks that password field is not empty, and the button remains enabled despite password field was cleared and it's empty.
Unfortunately the -rac_textSignal only listens for UIControlEventEditingChanged. If UIControlEventEditingDidBegin were added, you'd be all set.
I suppose you could patch this into it and submit a pull request?
- (RACSignal *)rac_textSignal {
#weakify(self);
return [[[[[RACSignal
defer:^{
#strongify(self);
return [RACSignal return:self];
}]
concat:[self rac_signalForControlEvents:UIControlEventEditingChanged|UIControlEventEditingDidBegin]]
map:^(UITextField *x) {
return x.text;
}]
takeUntil:self.rac_willDeallocSignal]
setNameWithFormat:#"%# -rac_textSignal", [self rac_description]];
}

Prefill email content with NSButton hyperlink

I was wondering how I could, or if it's even possible to, prefill an email message's content when you click an NSButton, so far I open up the default email client but I want to prefill the body of the email and was wondering how I'd do that. Below is the current code:
-(IBAction)openEmail:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:#"mailto:domain#domain.com"]];
}
The "mailto" URI scheme supports this: http://en.wikipedia.org/wiki/Mailto
Send email
Rather than forcing a user out of your app, why don't you use MFMailComposeViewController to present the standard message composition window?
MFMailComposeViewController conveniently also has methods to set the message body and just about anything else you would like.
UPDATE: Oops, I misread "NSButton" as "UIButton" - what I wrote above only applies to iOS. Using the mailto: additions is the correct approach AFAIK on OS X.

Hot to implement grails server-side-triggered dialog, or how to break out of update region after AJAX call

In grails, I use the mechanism below in order to implement what I'd call a conditional server-side-triggered dialog: When a form is submitted, data must first be processed by a controller. Based on the outcome, there must either be a) a modal Yes/No confirmation in front of the "old" screen or b) a redirect to a new controller/view replacing the "old" screen (no confirmation required).
So here's my current approach:
In the originating view, I have a <g:formRemote name="requestForm" url="[controller:'test', action:'testRequest']", update:"dummyRegion"> and a
<span id="dummyRegion"> which is hidden by CSS
When submitting the form, the test controller checks if a confirmation is necessary and if so, renders a template with a yui-based dialog including Yes No buttons in front of the old screen (which works fine because the dialog "comes from" the dummyRegion, not overwriting the page). When Yes is pressed, the right other controller & action is called and the old screen is replaced, if No is pressed, the dialog is cancelled and the "old" screen is shown again without the dialog. Works well until here.
When submitting the form and test controller sees that NO confirmation is necessary, I would usually directly redirect to the right other controller & action. But the problem is that the corresponding view of that controller does not appear because it is rendered in the invisble dummyRegion as well. So I currently use a GSP template including a javascript redirect which I render instead. However a javascript redirect is often not allowed by the browser and I think it's not a clean solution.
So (finally ;-) my question is: How do I get a controller redirect to cause the corresponding view to "break out" of my AJAX dummyRegion, replacing the whole screen again?
Or: Do you have a better approach for what I have in mind? But please note that I cannot check on the client side whether the confirmation is necessary, there needs to be a server call! Also I'd like to avoid that the whole page has to be refreshed just for the confirmation dialog to pop up (which would also be possible without AJAX).
Thanks for any hints!
I know, it's not an "integrated" solution, but have you considered to do this "manually" with some JS library of your choice (my personal choice would be jQuery, but any other of the established libraries should do the trick)? This way you wouldn't depend on any update "region", but could do whatever you want (such as updating any DOM element) in the response handler of the AJAX request.
Just a thought. My personal experience is that the "built-in" AJAX/JS stuff in Grails often lacks some flexibility and I've always been better off just doing everything in plain jQuery.
This sounds like a good use-case for using web flows. If you want to show Form A, do some kind of check, and then either move onto NextScreen or show a Dialog that later redirects to NextScreen, then you could accomplish this with a flow:
def shoppingCartFlow = {
showFormA {
on("submit") {
if(needToShowDialog())return
}.to "showNextScreen"
on("return").to "showDialog"
}
showDialog {
on("submit").to "showNextScreen"
}
showNextScreen {
redirect(controller:"nextController", action:"nextAction")
}
}
Then you create a showDialog.gsp that pops up the dialog.
--EDIT--
But, you want an Ajax response to the first form submit, which WebFlow does not support. This tutorial, though, will teach you how to Ajaxify your web flow.

Resources