コード例 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var view = (EntryWithCurvedCorners)Element;

                if (view.IsCurvedCornersEnabled)
                {
                    // creating gradient drawable for the curved background
                    var _gradientBackground = new GradientDrawable();
                    _gradientBackground.SetShape(ShapeType.Rectangle);
                    _gradientBackground.SetColor(view.BackgroundColor.ToAndroid());

                    // Thickness of the stroke line
                    _gradientBackground.SetStroke(view.BorderWidth, view.BorderColor.ToAndroid());

                    // Radius for the curves
                    _gradientBackground.SetCornerRadius(
                        AndroidHelpers.DpToPixels(this.Context,
                                                  Convert.ToSingle(view.CornerRadius)));

                    // set the background of the label
                    Control.SetBackground(_gradientBackground);
                }

                // Set padding for the internal text from border
                Control.SetPadding(
                    (int)AndroidHelpers.DpToPixels(this.Context, Convert.ToSingle(12)),
                    Control.PaddingTop,
                    (int)AndroidHelpers.DpToPixels(this.Context, Convert.ToSingle(12)),
                    Control.PaddingBottom);
            }
        }
コード例 #2
0
ファイル: MainView.cs プロジェクト: ameetmanit/MvvmQuickCross
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.MainView);
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            // One-time initialization of application and helpers.
            // This can be done in the startup view, or in the android application object, or in the application loading screen.
            EnsureApplication();
            AndroidHelpers.Initialize(typeof(Resource));

            CloudAuctionApplication.Instance.ContinueToMain(skipNavigation: true);
            // Ensure that our viewmodel is initialized, in case we navigated to this view by some other means
            // than through a call to CloudAuctionApplication.Instance.ContinueToMain().
            // E.g. when the OS creates this view at application startup, because it is marked as MainLauncher.

            ActionBar.Tab[] tabs = new ActionBar.Tab[] {
                ActionBar.NewTab().SetText("Auction").SetTag(new AuctionView()),
                ActionBar.NewTab().SetText("Products").SetTag(new ProductsView()),
                ActionBar.NewTab().SetText("Help").SetTag(new Fragment())
            };
            foreach (var tab in tabs)
            {
                tab.TabSelected += Tab_TabSelected;
            }

            Initialize(FindViewById(Resource.Id.MainView), CloudAuctionApplication.Instance.MainViewModel);
            // This call initializes data binding and updates the view with the current viewmodel values.

            for (int position = 0; position < tabs.Length; position++)
            {
                ActionBar.AddTab(tabs[position], setSelected: (MainViewModel.SubView)position == CurrentSubView);
            }
        }
コード例 #3
0
 private Tuple <SendType, string, byte[], string> GetCreateSendRequest(Intent intent)
 {
     if (intent.Action == Intent.ActionSend && intent.Type != null)
     {
         var type = intent.Type;
         if (type.Contains("text/"))
         {
             var subject = intent.GetStringExtra(Intent.ExtraSubject);
             var text    = intent.GetStringExtra(Intent.ExtraText);
             return(new Tuple <SendType, string, byte[], string>(SendType.Text, subject, null, text));
         }
         else
         {
             var data     = intent.ClipData?.GetItemAt(0);
             var uri      = data?.Uri;
             var filename = AndroidHelpers.GetFileName(ApplicationContext, uri);
             try
             {
                 using (var stream = ContentResolver.OpenInputStream(uri))
                     using (var memoryStream = new MemoryStream())
                     {
                         stream.CopyTo(memoryStream);
                         return(new Tuple <SendType, string, byte[], string>(SendType.File, filename, memoryStream.ToArray(), null));
                     }
             }
             catch (Java.IO.FileNotFoundException) { }
         }
     }
     return(null);
 }
コード例 #4
0
 public async override void OnReceive(Context context, Intent intent)
 {
     if (intent.Action == Intent.ActionApplicationRestrictionsChanged)
     {
         await AndroidHelpers.SetPreconfiguredRestrictionSettingsAsync(context);
     }
 }
コード例 #5
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout._VIEWNAME_View);
     AndroidHelpers.Initialize(typeof(Resource));
     EnsureApplication();
     CloudAuctionApplication.Instance.ContinueTo_VIEWNAME_(skipNavigation: true);
     Initialize(FindViewById(Resource.Id._VIEWNAME_View), CloudAuctionApplication.Instance._VIEWNAME_ViewModel);
 }
コード例 #6
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.SampleItemListView);
     AndroidHelpers.Initialize(typeof(Resource));
     EnsureApplication();
     SampleAppApplication.Instance.ContinueToSampleItemList(skipNavigation: true);
     Initialize(FindViewById(Resource.Id.SampleItemListView), SampleAppApplication.Instance.SampleItemListViewModel);
 }
コード例 #7
0
ファイル: MainView.cs プロジェクト: ameetmanit/MvvmQuickCross
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.MainView);
     AndroidHelpers.Initialize(typeof(Resource));
     EnsureApplication();
     TwitterApplication.Instance.CurrentNavigationContext = this;
     TwitterApplication.Instance.ContinueToMain(skipNavigation: true);
     Initialize(FindViewById(Resource.Id.MainView), TwitterApplication.Instance.MainViewModel);
 }
コード例 #8
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout._VIEWNAME_View);
     AndroidHelpers.Initialize(typeof(Resource));
     EnsureApplication();
     TwitterNavigator.Instance.NavigationContext = this;
     TwitterApplication.Instance.ContinueTo_VIEWNAME_();
     Initialize(FindViewById(Resource.Id._VIEWNAME_View), TwitterApplication.Instance._VIEWNAME_ViewModel);
 }
コード例 #9
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (resultCode == Result.Ok &&
                (requestCode == Constants.SelectFileRequestCode || requestCode == Constants.SaveFileRequestCode))
            {
                Android.Net.Uri uri      = null;
                string          fileName = null;
                if (data != null && data.Data != null)
                {
                    uri      = data.Data;
                    fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
                }
                else
                {
                    // camera
                    var file = new Java.IO.File(FilesDir, "temp_camera_photo.jpg");
                    uri      = FileProvider.GetUriForFile(this, "com.x8bit.bitwarden.fileprovider", file);
                    fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
                }

                if (uri == null)
                {
                    return;
                }

                if (requestCode == Constants.SaveFileRequestCode)
                {
                    _messagingService.Send("selectSaveFileResult",
                                           new Tuple <string, string>(uri.ToString(), fileName));
                    return;
                }

                try
                {
                    using (var stream = ContentResolver.OpenInputStream(uri))
                        using (var memoryStream = new MemoryStream())
                        {
                            stream.CopyTo(memoryStream);
                            _messagingService.Send("selectFileResult",
                                                   new Tuple <byte[], string>(memoryStream.ToArray(), fileName ?? "unknown_file_name"));
                        }
                }
                catch (Java.IO.FileNotFoundException)
                {
                    return;
                }
            }
            else if (resultCode == Result.Ok && Enum.IsDefined(typeof(Fido2CodesTypes), requestCode)) // Check if any event or result to this activity as information about FIDO2
            {
                // Send the event code and the data to the FIDO2 Services to be process
                Fido2Service.INSTANCE.OnActivityResult(requestCode, resultCode, data);
            }
        }
コード例 #10
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (resultCode == Result.Ok &&
                (requestCode == Constants.SelectFileRequestCode || requestCode == Constants.SaveFileRequestCode))
            {
                Android.Net.Uri uri      = null;
                string          fileName = null;
                if (data != null && data.Data != null)
                {
                    uri      = data.Data;
                    fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
                }
                else
                {
                    // camera
                    var file = new Java.IO.File(FilesDir, "temp_camera_photo.jpg");
                    uri      = FileProvider.GetUriForFile(this, "com.x8bit.bitwarden.fileprovider", file);
                    fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
                }

                if (uri == null)
                {
                    return;
                }

                if (requestCode == Constants.SaveFileRequestCode)
                {
                    _messagingService.Send("selectSaveFileResult",
                                           new Tuple <string, string>(uri.ToString(), fileName));
                    return;
                }

                try
                {
                    using (var stream = ContentResolver.OpenInputStream(uri))
                        using (var memoryStream = new MemoryStream())
                        {
                            stream.CopyTo(memoryStream);
                            _messagingService.Send("selectFileResult",
                                                   new Tuple <byte[], string>(memoryStream.ToArray(), fileName ?? "unknown_file_name"));
                        }
                }
                catch (Java.IO.FileNotFoundException)
                {
                    return;
                }
            }
            else if (resultCode == Result.Ok && requestCode == REQUEST_CODE_SIGN)
            {
                var signResponseData = data.GetParcelableExtra(Fido.KeyResponseExtra);
                Log.Info("bitwarden-u2f", "FIDO Activity received");
            }
        }
コード例 #11
0
 protected override void OnResume()
 {
     base.OnResume();
     if (_deviceActionService.SupportsNfc())
     {
         try
         {
             _messagingService.Send("resumeYubiKey");
         }
         catch { }
     }
     var setRestrictions = AndroidHelpers.SetPreconfiguredRestrictionSettingsAsync(this);
 }
コード例 #12
0
        /// <summary>
        /// A public folder representing storage which contains Pictures.
        /// </summary>
        public Task <IFolder> PicturesFolderAsync()
        {
            var folderPath = "";

            if (AndroidHelpers.IsExternalStorageWritable())
            {
                var f = AndroidEnvironment.GetExternalStoragePublicDirectory(AndroidEnvironment.DirectoryPictures);
                folderPath = f.Path;
            }
            else
            {
                return(null);
            }

            return(Task.FromResult((IFolder) new DroidFileSystemFolder(folderPath, Storage.Pictures)));
        }
コード例 #13
0
ファイル: MainView.cs プロジェクト: mnguye2s/cleverbook
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SmartLearningNavigator.Instance.NavigationContext = this;
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.MainView);

            AndroidHelpers.Initialize(typeof(Resource));
            EnsureApplication();

            SmartLearningNavigator.Instance.NavigationContext = this;
            InitDatabase.Init("SmartLearning.db3");
            SmartLearningApplication.Instance.DatabaseName = "SmartLearning.db3";
            SmartLearningApplication.Instance.ContinueToMainView();
            Initialize(FindViewById(Resource.Id.MainView), SmartLearningApplication.Instance.MainViewModel);
        }
コード例 #14
0
 protected override void OnResume()
 {
     base.OnResume();
     Xamarin.Essentials.Platform.OnResume();
     AppearanceAdjustments();
     if (_deviceActionService.SupportsNfc())
     {
         try
         {
             _messagingService.Send("resumeYubiKey");
         }
         catch { }
     }
     AndroidHelpers.SetPreconfiguredRestrictionSettingsAsync(this)
     .GetAwaiter()
     .GetResult();
 }
コード例 #15
0
ファイル: MainActivity.cs プロジェクト: cozy/cozy-pass-mobile
        protected override void OnResume()
        {
            base.OnResume();

            if (Intent.Data?.Scheme == "cozypass")
            {
                OnOpenURL(Intent.DataString);
            }

            if (_deviceActionService.SupportsNfc())
            {
                try
                {
                    _messagingService.Send("resumeYubiKey");
                }
                catch { }
            }
            var setRestrictions = AndroidHelpers.SetPreconfiguredRestrictionSettingsAsync(this);
        }
コード例 #16
0
ファイル: MainActivity.cs プロジェクト: dai640/mobile
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (requestCode == Constants.SelectFileRequestCode && resultCode == Result.Ok)
            {
                Android.Net.Uri uri      = null;
                string          fileName = null;
                if (data != null && data.Data != null)
                {
                    uri      = data.Data;
                    fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
                }
                else
                {
                    // camera
                    var root = new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory, "bitwarden");
                    var file = new Java.IO.File(root, "temp_camera_photo.jpg");
                    uri      = Android.Net.Uri.FromFile(file);
                    fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
                }

                if (uri == null)
                {
                    return;
                }
                try
                {
                    using (var stream = ContentResolver.OpenInputStream(uri))
                        using (var memoryStream = new MemoryStream())
                        {
                            stream.CopyTo(memoryStream);
                            _messagingService.Send("selectFileResult",
                                                   new Tuple <byte[], string>(memoryStream.ToArray(), fileName ?? "unknown_file_name"));
                        }
                }
                catch (Java.IO.FileNotFoundException)
                {
                    return;
                }
            }
        }