Is it possible to use a xamarin form in place of a winform on a local display? - xamarin.forms

I have a number of console application that use winforms to gather simple input from the user (Do this and click "OK", Did this happen click "Yes" or "No" That kind of thing) There is a new requirement that we provide the option to gather the simple input from the user on a handheld device that runs Android.
I had hoped to convert our winforms to Xamarin forms that could be used either locally or be sent to the handheld device. This is not my area, really, so it may be that I am not looking at the problem in the right way.
The system running the console application is usually a laptop or maybe a desktop.
Does anyone have any advice?

You can use App Center Analytics Events Metrics to track user event.
Here is the document for Xamarin:
You can track your own custom events with up to twenty properties to
understand the interaction between your users and the app.
Analytics.TrackEvent("Video clicked", new Dictionary<string, string> {
{ "Category", "Music" },
{ "FileName", "favorite.avi"}
});

Related

Telegram Web Apps method Expand isn't working

I found that the method Expand of window.Telegram.WebApp object isn't working in the Telegram client for Windows and IOS on computers and tablets.
How to increase the size of Web Apps frame for those devices?
function buttonOn(){
// do something on btn click
}
let main_page = document.querySelector('#main_page');
if (main_page){
window.Telegram.WebApp.expand() //expand window after page loading
window.Telegram.WebApp.MainButton.onClick(buttonOn) //set func on main button click
window.Telegram.WebApp.MainButton.setParams({'text': 'Корзина'}) // set byn params
window.Telegram.WebApp.MainButton.show() //show telegram btn
}
Other button events
Remove the line from the function:
window.Telegram.WebApp.expand() //expand window after page loading
And call it in the beginning/at the top of your main javascript code. (The code that will start running once the user has clicked on the button)
Also, you can make your code a lot shorter by putting window.Telegram.WebApp in a variable like:
const tele = window.Telegram.WebApp; //Initializes the TELEGRAM BOT and
//Gets the user's Telegram ID from the Telegram API
tele.expand(); //Expands the app on the users' phone to 100% height
The reason is, probably, you are a bit incorrect in understanding what "expansion" is. This term could only be applied to mobile devices with OS such as Android or iOS. Web App is displayed there in such native component as BottomSheet with inserted WebView containing your web application. Initially, in mobile devices, application is being opened minimized (not expanded). To make it use maximum allowed height of screen, you could call expand() method. It must work through window.Telegram.WebApp.expand().
In desktop or web versions of Telegram, Web App is displayed in separate component which is not allowed to change its size.
You could probably find more useful information about viewport and expansion here, or use alternative libraries, such as twa-bridge or twa-sdk

How to distribute apps when SELECT button does nothing - Android Management API

I am building a console and have successfully rendered my iframe:
gapi.load('gapi.iframes', function() {
var options = {
'url': 'https://play.google.com/work/embedded/search?token=' + data + '&mode=SELECT',
'where': document.getElementById('container'),
'attributes': { style: 'width: 950px; height:500px', scrolling: 'yes'}
}
However, when I select an app using the provided SELECT button, it only returns the expected payload. I assumed that the iframe would do the heavy lifting here but now know that I need to build the logic. Can someone point me in the rightt direction here for approving the app via SELECT button? Is there a set of iframe events that I should be writing this with in mind? I'm completely lost since documentation here https://developers.google.com/android/management/apps#select-button_1
is extremely vague. Has anyone had issues with this before?
Thanks!
The documentation for the select button indicates that “You need to specify the action that takes place when the IT admin clicks this button”. It is up to the EMM to decide what to do next. You could prompt the user to approve the app on play.google.com/work
For example, you need to approve dropbox. You need to login with your enterprise account then go to this link https://play.google.com/work/apps/details?id=com.dropbox.android and then approve the app.
Or you could prompt the user to add the application to a policy, which automatically approves the app for use by the user’s enterprise.
You may refer to this link for more information about handling iframe events.

Azure AD (ADAL) Login Screen Loses Entered User Email on Device Orientation in Android Only-XamarinForms.Android

I have Xamarin.Forms application that authenticates user against Azure AAD using ADAL (Microsoft.IdentityModel.Clients.ActiveDirectory). That all works fine but on Android, device orientation looses user email on the Microsoft authentication screen.
Here I am in Portrait mode and I have entered user email:
Clicking on Next lands on screen asking to enter password. If I now rotate device on Android, it will return me back to blank screen above, user email I entered above is lost:
Device rotation should not return user back and re-prompt for user email again. It should stay on password prompt.
How do I prevent the rotation from re-prompting for user email? I dont want to disable rotation, I just want to prevent it from returning me back to screen that prompts for user email again.
This is Xamarin.Forms application and my MainActivity has already ConfigChages.Orientation attribute like below; however, this is not solving the issue:
[Activity(Name = "my.mainactivity"
, Label = "MyApp"
, Icon = "#drawable/icon"
, ConfigurationChanges = ConfigChanges.ScreenSize
| ConfigChanges.SmallestScreenSize
| ConfigChanges.ScreenLayout
| ConfigChanges.Orientation)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
}
UPDATE
Even if I freeze orientation to Portrait before call to AcquireTokenAsync and unfreeze it after the call receives response, it still behaves same - it will still rotate the Microsoft sign in page even though I freeze its parent (MainActivity) to Portrait (which is the owner passed in PlatformParameters to the call to AcquireTokenAsync. So, my activity stays in portrait but that sign-in page still rotates and looses data. It appears that the WebView Microsoft uses internally in AcquireTokenAsync is not following orientation settings on the activity passed inside PlatformParameters to AcquireTokenAsync.
Confirmed by Microsoft that this is their internal issues. If you are also running into this issue on Android where device rotation returns you back to prompt for user email, you can follow up progress of fixes for both ADAL and MSAL here:
https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1622 https://github.com/xamarin/xamarin-android/issues/3326
I use Entry at my side, adding ConfigurationChanges = ConfigChanges.ScreenSize| ConfigChanges.Orientation, it works fine.
If you still have this issue, I suggest you can follow the next steps:
1.on Forms PCL, you can override OnSizeAllocated to check screen orientation, like this:
How to detect screen orientation of the device in Xamarin.Forms?
2.On Forms PCL and Android, you can use MessageCener to subscribe and send data
3.override method onSaveInstanceState() and onRestoreInstanceState(), like this:
Handle screen rotation without losing data - Android
The issue has been fixed in ADAL Release 5.1.1, and will be included in the next version of MSAL (most likely 4.3.1).
This issue is caused by Microsoft's ADAL component Microsoft.IdentityModel.Clients.ActiveDirectory and it has been fixed in 5.1.0 version released just couple of weeks ago (current version is 5.2.0).
What I had to do in order to fix this issue is:
1. Update ADAL from 3.19.8 to 5.2.0 (everything below 5.1.0 has this problem)
2. Then modified AuthorityURL passed to AuthenticationContext c-tor from something like https://login.microsoftonline.com/my-tenant-id/oauth2/authorize to https://login.microsoftonline.com/my-tenant-id
Number 2 was necessary even though Microsoft claims in most places that the change is non-breaking change (they confirmed this is necessary).
After this, I was able to authenticate just like before but rotation on Android would not loose already provided user id and/or password.

How can I handle modal dialogs with Behat and Goutte?

I'm testing a functionnality on a website that allows the user to fill a form. At a moment, the users needs to click on a button, which triggers an Ajax loaded modal that allows him to upload a file. However, when I trigger the button, Behat doesn't seem to "see" the modal window.
Maybe I should precise I'm in a Drupal 8 environment, but I don't know if this changed anything
Just so we're clear, I'm not talking about an alert, but this kind of modal
So far my tests looks like this:
Scenario: Creates a stage test with two sessions
Given I am on "/user/login"
And I fill in "user#user.com" for "name"
And I fill in "password" for "pass"
And I press "Log in"
Then I should get a "200" HTTP response
And I should see "User Name"
When I go to "/node/add/stage"
Then I should get a "200" HTTP response
And I should see "Add content CISIA Stage"
When I fill in "Test Cisia Stage" for "edit-title-0-value"
And I press "Select files"
Then I should see "Upload files" <-- fails
And I should see "Click or drop files here to upload them" <-- gets ignored but is likely to fail too
I can't find anything modal-related on SO or Google in general, only about small message alerts, and people talk about objects or functions I don't have (such as getWebDriver())
I also tried to find the modal's content by myself by doing so:
public function iShouldSeeAModalWindow() {
$element = $this->getSession()->getPage();
$modal = $element->find('css', sprintf('div:contains("%s")', 'Upload files'));
if($modal) {
exit('Yaaaay!');
}
else {
throw new Exception("No modal found");
}
}
However I got no luck so far.
What should I do?
You have an iframe and you need to switch to it.
Use something like this:
$this->getSession()->getDriver()->switchToIFrame('iframe_name');
I think you should also consider to write your scenario on a high level basis and also use page objects extension to avoid getting long scenarios that are hard to maintain and unreadable and also to reuse as much code as possible.
Follow Behavior Driven Development methodology.

onGoing notification can still be removed by user, manually

i create an application and i want after click on specific button, a "Permanent Nofitication" show on notification bar.
i search for it and use these codes:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_clip_board_service)
.setContentTitle(getResources().getString(R.string.notifTitle))
.setContentText(getResources().getString(R.string.notifText))
.setOngoing(true);
the ongoing method, prevent user to manually clear the notification.in my emulator(genymotion), everything is ok.but in my real Phone(Huawei G8) when i try to remove notificaiton, a pop-up menu appeared and say:
Not Recomended
removing ongoing notification may affect app stability.
the menu has already two buttons:cancel and Remove.and i can remove the notification.:(
i don't want user manually remove notification.
is the problem about my Phone or setOngoing(true) method?
thanks in advance...
Based off what I'm seeing for my app that behaves similarly, it appear Huawei phone's always allow clearing notifications and shutting down the app. My app even runs as a device administrator and it can still be cleared.

Resources