Пример #1
0
        public static async Task <PermissionStatus> RequestPermissions(this object caller, Permission permission, string dialogTitle, string dialogMessage)
        {
            var status = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

            if (status != PermissionStatus.Granted)
            {
                if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(permission))
                {
                    CoreDependencyService.GetDependency <IDialogPrompt>().ShowMessage(new Prompt()
                    {
                        Title   = dialogTitle,
                        Message = dialogMessage
                    });
                }

                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { permission });

#if __ANDROID__
                if (Looper.MyLooper() == null)
                {
                    Looper.Prepare();
                }
#endif
                status = results[permission];
            }

            return(status);
        }
Пример #2
0
        public LocalizationService()
        {
            var culture  = CoreDependencyService.GetDependency <ILocalize>().GetCurrentCultureInfo();
            var fileName = $"{culture.TwoLetterISOLanguageName.ToLower()}.json";

            var storage = (IFileStore)CoreDependencyService.GetService <IFileStore, FileStore>(true);

            storage.GetAsync <Dictionary <string, string> >(fileName).ContinueWith((data) =>
            {
                if (data.Result.Success)
                {
                    IsLoaded    = true;
                    localString = data.Result.Response;
                    CoreDependencyService.SendViewModelMessage(CoreSettings.LocalizationLoaded, null);
                }
            });
        }