Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let user know if airplane mode is on #315

Closed
jameljoseph opened this issue Dec 13, 2023 · 15 comments
Closed

let user know if airplane mode is on #315

jameljoseph opened this issue Dec 13, 2023 · 15 comments
Assignees

Comments

@jameljoseph
Copy link
Contributor

So if by chance the user has airplane mode on, we should let them know with a popup box

@jameljoseph jameljoseph self-assigned this Dec 13, 2023
jameljoseph added a commit that referenced this issue Dec 13, 2023
…k it out Gab and se eif it works for you? I checked and I dont think you are capable of turning airplane on or off in the app anymore.
@jameljoseph
Copy link
Contributor Author

I put some code in to check. Seems to work on my end.

@ghuotvez
Copy link
Member

Nice addition, I'll try to test that out.

I did have the same thing implemented in the first version, but then with some windows updates, it started to pop the airplane mode message for no reasons. So I removed it to make things more simple. #167

@ghuotvez ghuotvez added this to the GSC Field App 2.4 milestone Dec 13, 2023
@ghuotvez
Copy link
Member

@jameljoseph so, it does work but only when the app is opened while airplane mode is on. If airplane mode is toggled on while the app is running, we can still take a station or navigate to the map page without much trouble.

Last time it was implemented I did set the warning to pop right in the method that tracks the event regarding the location. Here's where the code used to be: 9022805#diff-f4dbb8457dc93ffa105061b852d7d6513adb0eebc96775af014f533e9592159cR326

So when user tried to get a location and no data was hit, the code assumed it was on airplane mode or something like that. I like the way you'Re getting to it with the connection method instead. It's probably more stable that way. We just need to move your code to the old place I think.

And here is the code to get the pop-up yellow like all the other warning messages in the app. You need to set the style of the dialog before opening it:

public async Task NoLocationRoutine()

@jameljoseph
Copy link
Contributor Author

Yeah it is just meant as a warning when they open the app to let them know.

I will check the style and change it to all the other pop ups.

@ghuotvez
Copy link
Member

Yeah it's just a warning, but shouldn't we have it auto-detect more often then not? We did have a geologist that fat fingered airplane mode while on an outcrop and had to call via satellite to get some help before we found what was the problem.

@jameljoseph
Copy link
Contributor Author

I can set it up so that it detects it every second. I was working with code that would detect it every second but figured it might cause issues because it would be constantly checking and might use up some extra resources

@ghuotvez
Copy link
Member

Yeah, you're right on that, every second is overkill. Just when user takes a station at least, there could be a quick check? That would also take less resource then adding your code to the location event that tracks the GPS changes, that also might too much.

@jameljoseph
Copy link
Contributor Author

Ok so I am looking at MapPageViewModel and see there is a task to validate the geolocation access where there is lots of methods like PoorLocationRoutineTap , NoLocationRoutine..... being called depending on certain criteria like accuracy is poor, location is turned off... Do you want me to just move my code inside the NoLocationRoutine method?

@jameljoseph
Copy link
Contributor Author

I see inside NoLocationRoutine method you have:

public async Task NoLocationRoutine()
{
//// Language localization using Resource.resw
//var local = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

        ContentDialog noLocationDialog = new ContentDialog()
        {
            Title = local.GetString("MapPageDialogLocationTitle"),
            Content = local.GetString("MapPageDialogTextLocationStatus"),
            PrimaryButtonText = local.GetString("MapPageDialogTextYes"),
            SecondaryButtonText = local.GetString("MapPageDialogTextNo"),
        };

        noLocationDialog.Style = (Style)Application.Current.Resources["WarningDialog"];

        try
        {
            ContentDialogResult cdr = await Services.ContentDialogMaker.CreateContentDialogAsync(noLocationDialog, true).Result;

            if (cdr == ContentDialogResult.Primary)
            {
                bool result = await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
            }
        }
        catch (Exception)
        {
            Debug.WriteLine("Warning dialog for location allocation failed.");
        }



    }

@jameljoseph
Copy link
Contributor Author

Oh I just see nolocationflightmode() in the page you sent me

@ghuotvez
Copy link
Member

Yeah that's what I was talking about. We used to pop the warning from this method, but the check wasn't s good as yours so I had to remove it. Either we get your code in the nolocationflightmode or when user takes a station. As long as we don't check it too often or only once.

@jameljoseph
Copy link
Contributor Author

jameljoseph commented Dec 13, 2023

I see you commented out a call to run NoLocationFlightMode on line 361 so just below I put a call in to run CheckAirplaneMode:

//await Task.Delay(3000); //Let enough time to pass so GPS actually gets a proper fix
//await NoLocationFlightMode();
connectionProfile = NetworkInformation.GetInternetConnectionProfile();
 CheckAirplaneMode();

I put the method just above the NoLocationFlightMode method you created around line 1536.

I would check it now but im watching the awards and I don't want to toggle airplane mode on and off. Is this what you meant? I built it and there were no errors and ran it with airplane mode off and it worked fine.

@ghuotvez
Copy link
Member

Awesome, we'll test it out at this place a bit later. That might be good enough.

@ghuotvez
Copy link
Member

Just did a quick test on a tablet, and the app crashes as soon as I put airplane mode while having the app opened.

Afterward, when I want to take a station and the tablet is on airplane mode it also crashes the app.

@jameljoseph
Copy link
Contributor Author

Oh boy it never crashed on me!! I will work on it more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants