zxing.net: iOS not recognizing any barcodes - xamarin.forms

I'm using this library for my Xamarin.Forms app: https://github.com/Redth/ZXing.Net.Mobile
Just to start off, it's working perfectly on Android. iOS shows the camera viewfinder, but it doesn't ever recognize any barcodes.
I initialize it in my AppDelegate as required:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
LoadApplication(new App(new iOSInitializer()));
return base.FinishedLaunching(app, options);
}
I also set the permission description in Info.plist:
<key>NSCameraUsageDescription</key>
<string>Please allow access to the camera to scan barcodes</string>
But I guess that's obvious, or else the camera viewfinder wouldn't work either.

I got some issues with Zxing in my app too, but i noticed that some problems are solved with the right version in both Android and IOS, i'm currently using the version 2.3.1 (not 2.4.1) and works perfect, besides, i realized that you should not use your ZxingPage first at the stack, that is why i always put a page before to avoid any crash:
var root = Application.Current.MainPage.Navigation.NavigationStack[0];
Application.Current.MainPage.Navigation.InsertPageBefore(new View(), root);
And then i call the ZxingPage. Hope it helps :)

Related

cefsharp - "Links that open a specific application" seem to be not working

I just begin with Cefsharp on C#.
Everything works fine except Cefsharp can not execute some special links that open/run a specific application on the computer.
The link still works on other Chromium official browsers (Google Chrome), I clicked the link and it launches the application. Cefshap is not, it does nothing when I clicked the link.
The link looks something like this: "runapp://api.abcxyz/..."
How can I make it work on Cefsharp?
image show that the link works on other chromium browsers
Firstly for security reasons loading of external protocols is disabled by default. Historically you would have implemented OnProtocolExecution.
There is currently an upstream bug in OnProtocolExecution see https://bitbucket.org/chromiumembedded/cef/issues/2715/onprotocolexecution-page-goes-blank-after
You can implement a workaround using RequestHandler.OnBeforeBrowser and calling Process.Start
It would look roughly something like the following (Written in Notepad++ very quickly, there maybe minor mistakes that you'd have to correct).
public class ExampleRequestHandler : RequestHandler
{
protected override bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
{
if(request.Url.StartsWith("mailto:"))
{
System.Diagnostics.Process.Start(request.Url);
//Cancel navigation
return true;
}
return false;
}
}
browser.RequestHandler = new ExampleRequestHandler();

Selecting multiple images using xam.plugin.media

I'm using xam.plugin.media to get the file path of the image selected. Working with a single image is fine, but I'm having trouble selecting multiple images.
This is my code:
List<MediaFile> mediaFile;
...
private async void AddAttachments(object sender, EventArgs e) {
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsPickPhotoSupported) {
await DisplayAlert("Error", "Your phone does not support photo uploads. Please proceed without attachments.", "Okay");
return;
}
mediaFile = await CrossMedia.Current.PickPhotosAsync();
if (mediaFile == null) {
return;
}
}
Despite using PickPhotosAsync(), it still selects a single photo. I was expecting something where I can check images I want to upload like other mobile applications.
Unfortunately, you can't (kind of). It is supposed to be working, but there was an issue about this back in 2018-2019, which got marked as solved, even though the user kept complaining about it not working reliably/always.
Link to the feature request/issue here.
There is a new issue, that got registered recently (April 2020) here.
My advice is to subscribe to it and comment, so that the developer will know that you are experiencing some issues with this functionality also. If you can, you can also create a sample project and upload it, so that they can quickly fix it.
However, in my experience, this package hasn't been frequently updated, so you might have to wait a bit.

Unable to override OnApplyTemplate

I'm trying to override the NavigationView behavior:
public partial class CustomizableNavigationView : NavigationView
{
public CustomizableNavigationView()
{
// This gets called
}
protected override void OnApplyTemplate()
{
// This doesn't
}
}
It works on UWP, but not on Android. On Android, it doesn't call OnApplyTemplate and the screen remains blank, there's not content. Questions:
Why doesn't OnApplyTemplate get called on Android? I see that here: https://platform.uno/docs/articles/implemented/windows-ui-xaml-frameworkelement.html it says OnApplyTemplate() is on all platforms
There's no error or anything displayed in the Output panne in VS while running with debugger. Should there be any in this case? Do I need to enable something to log errors?
I noticed that if I don't use partial it gaves me error saying partial is required. This is required only on Android, why is that? A more in-depth explanation would help a lot to understand how things work.
Once I figure out why OnApplyTemplate is not called, I want to do this:
base.OnApplyTemplate();
var settingsItem = (NavigationViewItem)GetTemplateChild("SettingsNavPaneItem");
settingsItem.Content = "Custom text";
My hunch is this won't work on Android. Am I correct? :)
Jerome's answer explains why OnApplyTemplate() was not getting called, to address your other questions:
You can configure logging filters for Uno, this is normally defined in App.xaml.cs. Warnings should be logged by default.
The partial is required because Uno does some code-gen behind the scenes to create plumbing methods used by the Xamarin runtime. Specifically because the control is ultimately inheriting from ViewGroup on Android, it's a native object, and requires special constructors that are used only by Xamarin's interop layer. There's some documentation in progress on this.
Try it and see. :) GetTemplateChild() is supported, and setting ContentControl.Content in this way is supported, so I would expect it to work.
At current version (1.45 and below), the application of styles is behaving differently from UWP. We're keeping track of this in this issue.
The gist of the issue is that Uno resolves the style using the current type and not DefaultStyleKey, and cannot find an implicit style for CustomizableNavigationView.
A workaround for this is to either create a named style from the default NavigationView style, or create an implicit style that uses CustomizableNavigationView as the TargetType instead of NavigationView.

How to swipe iOS emulator screen

As soon as I upgraded my local version of Appium, all my swipe logic stopped working. I moved to the non deprecated API, and but I'm till not able to observe swipes. I'm pretty sure I'm just not using the coordinate system correctly but I'm not sure how. I want to swipe vertically down the screen of an iOS simulator to refresh a list view.
Any pointers on how to treat properly swipe and why, and what the mechanics of it are?
Here is my code for swiping
PointOption fromPoint = PointOption.point(
topView.getLocation().x,
topView.getLocation().y);
PointOption toPoint = PointOption.point(
bottomView.getLocation().x,
bottomView.getLocation().y);
new TouchAction(user.mDriver)
.press(fromPoint)
.moveTo(toPoint)
.release()
.perform();
I upgraded my version of Appium and my Java client, but those improvements didn't fix the swiping.
Apparently, one must add a wait duration for the swipe to take place.
WaitOptions waitOptions = WaitOptions.waitOptions(Duration.ofMillis(500));
new TouchAction(mUser.mDriver)
.press(fromPoint)
.waitAction(waitOptions)
.moveTo(toPoint)
.release()
.perform();
This is my code it is working fine for IOS simulator swiping .
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "left");
js.executeScript("mobile: swipe", scrollObject);

Vaadin: How to react to a tray notification click?

I'm using Tray Notifications to let the user know about some pending actions. It works fine but would love to be able to click on it and do what I need it to do like showing the correct screen, etc. Sadly I'm unable to find some click listener like other components.
Am I'm missing something?
As far as I know that's not possible with the default notification in either Vaadin 7 or 8.
If you're using Vaadin 7, you can either fake it using a non-modal window (or something similar), or use the fancy-layouts add-on (also compatible with 8) that offers a FancyNotifications component (online demo and source). It's not exactly the same thing but it may provide what you need. Also be careful to select the v7 version and to add the suggested maven repo.
Basic usage:
public class MyUi extends UI {
#Override
protected void init(VaadinRequest request) {
FancyNotifications fancyNotifications = new FancyNotifications();
fancyNotifications.setPosition(FancyNotificationsState.Position.BOTTOM_RIGHT);
Button button = new Button("Show notification", buttonClickEvent -> {
FancyNotification fancyNotification = new FancyNotification(null, "Meh", "Click me to navigate to GITHUB");
fancyNotification.getTitleLabel().setContentMode(ContentMode.HTML);
fancyNotification.getDescriptionLabel().setContentMode(ContentMode.HTML);
fancyNotification.addLayoutClickListener(notificationClickEvent -> Page.getCurrent().setLocation("https://github.com/alump/FancyLayouts"));
fancyNotifications.showNotification(fancyNotification);
});
VerticalLayout content = new VerticalLayout();
content.setSizeFull();
setContent(content);
content.addComponents(button, fancyNotifications);
content.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
}
}
Result:
If you're using 8, there's the notify add-on (online demo and github page) which supports click-listeners. Please be aware that this add-on currently supports Vaadin 8 and works with browsers that support the Notification API:
Development is mainly done on Chrome. Also Firefox is tested and mainly works as planned. Other browsers are still not tested. IE11 and Edge does not support Notification API as far as I know. Anyway add-on can use used only to show notifications on browsers that do support Notification APIs.
From the github demo:
private void showWithClickHandling() {
Notify.show(new NotifyItem()
.setTitle("Notification can be also clicked")
.setBody("Click here to navigate to project's GitHub page")
.setIcon(new ThemeResource("images/github.png"))
.setClickListener(e -> {
Page.getCurrent().setLocation(GITHUB_URL);
}));
}
... which will look like:

Resources