public static Action <string> CreateUpServerNotificationFunc(ContextWrapper context, int notificationID, Func <string, Notification> func)
 {
     return((contentText) =>
     {
         MainThread.BeginInvokeOnMainThread(() =>
         {
             ((NotificationManager)context.GetSystemService(Context.NotificationService))
             .Notify(notificationID, func(contentText));
         });
     });
 }
        USBBroadCastReceiver _USBBroadCastReceiver;       // The permission broadcast receiver for USB permission intent

        /// <summary>
        /// We initialize all Android context
        /// </summary>
        /// <param name="context"></param>
        public void Init(Object context)
        {
            _context = (ContextWrapper)context;
            _devHandle.usbManager = (UsbManager)_context.GetSystemService(Context.UsbService);
            _usbPermissionIntent  = PendingIntent.GetBroadcast(_context, 0, new Intent(USBBroadCastReceiver.ACTION_USB_PERMISSION), 0);
            IntentFilter filter = new IntentFilter(USBBroadCastReceiver.ACTION_USB_PERMISSION);

            _USBBroadCastReceiver = new USBBroadCastReceiver();
            _USBBroadCastReceiver.NotifyUsbPermissionCompleted += _USBBroadCastReceiver_NotifyUsbPermissionCompleted;
            _context.RegisterReceiver(_USBBroadCastReceiver, filter);
        }
 public static void CreateNotificationChannel(ContextWrapper context, string channelID, string channelName)
 {
     if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
     {
         ((NotificationManager)context.GetSystemService(Context.NotificationService))
         .CreateNotificationChannel(new NotificationChannel(channelID, channelName, NotificationImportance.Max)
         {
             LockscreenVisibility = NotificationVisibility.Public
         });
     }
 }
        //Creates the view
        private void GenerateView()
        {
            //Dialog Shaded Back
            _RootView = new LinearLayout(this.Context);
            _RootView.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            _RootView.SetDpPadding(RtGraphicsLayouts, DIALOGPADDING, DIALOGPADDING, DIALOGPADDING, DIALOGPADDING);
            _RootView.SetBackgroundColor(RtGraphicsColours.SemiTransparentBlack);
            _RootView.Visibility = ViewStates.Gone;
            _RootView.SetGravity(GravityFlags.Center);

            //Dialog Back
            LinearLayout DialogLayout = new LinearLayout(this.Context);

            DialogLayout.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, RtGraphicsLayouts.EXPAND);
            DialogLayout.Orientation      = Orientation.Vertical;
            DialogLayout.SetBackgroundResource(Resource.Drawable.StyleCornerBox);
            _RootView.AddView(DialogLayout);

            //Dialog Top Bar
            LinearLayout DialogTopBar = new LinearLayout(this.Context);

            DialogTopBar.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, DIALOGHORIZONTALSHEIGHT);
            DialogTopBar.SetDpPadding(RtGraphicsLayouts, ZERO, SMALLPADDING, ZERO, SMALLPADDING);
            DialogLayout.AddView(DialogTopBar);

            //Location Icon
            ImageView DialogLocation = new ImageView(this.Context);

            DialogLocation.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogLocation.SetImageResource((Option_SearchLocation) ? Resource.Drawable.Icon_Location : Resource.Drawable.Icon_LocationFaded);
            DialogTopBar.AddView(DialogLocation);

            //Navigable Icon
            ImageView DialogNavigatable = new ImageView(this.Context);

            DialogNavigatable.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogNavigatable.SetImageResource((Option_SearchNavigable) ? Resource.Drawable.Icon_Navigation : Resource.Drawable.Icon_NavigationFaded);
            DialogTopBar.AddView(DialogNavigatable);

            //Cancel Icon
            ImageView DialogCancel = new ImageView(this.Context);

            DialogCancel.LayoutParameters = RtGraphicsLayouts.LayoutParameters(ICONSWIDTH, ICONSHEIGHT);
            DialogCancel.SetImageResource(Resource.Drawable.IconCancel);
            DialogTopBar.AddView(DialogCancel);

            //Search Input
            SearchInput = new EditText(this.Context);
            SearchInput.LayoutParameters = RtGraphicsLayouts.LayoutParameters(RtGraphicsLayouts.EXPAND, DIALOGHORIZONTALSHEIGHT);
            SearchInput.SetDpPadding(RtGraphicsLayouts, DIALOGPADDING, SMALLPADDING, DIALOGPADDING, SMALLPADDING);
            SearchInput.SetBackgroundColor(RtGraphicsColours.Orange);
            SearchInput.Format(RtGraphicsExt.TextFormats.Heading);
            DialogLayout.AddView(SearchInput);

            //Results Scroller
            ScrollView ResultsScroll = new ScrollView(this.Context);

            DialogLayout.AddView(ResultsScroll);

            //Results Root
            LinearLayout ResultsRoot = new LinearLayout(this.Context);

            ResultsRoot.Orientation = Orientation.Vertical;
            ResultsScroll.AddView(ResultsRoot);

            //GPS Instance
            RtGPS GPS = new RtGPS((LocationManager)ContextWrapper.GetSystemService(ContextWrapper.LocationService));

            //Event Handlers
            _RootView.Click              += delegate { CloseDialog(); };
            DialogCancel.Click           += delegate { CloseDialog(); };
            SearchInput.AfterTextChanged += delegate { DrawResults(ResultsRoot, GPS); };
            DialogLocation.Click         += delegate { ToggleLocationOption(DialogLocation); };
            DialogNavigatable.Click      += delegate { ToggleNavigableOption(DialogNavigatable); };
        }
Exemple #5
0
        public WakeLockWrapper(ContextWrapper contextWrapper)
        {
            var powerManager = (PowerManager)contextWrapper.GetSystemService(Context.PowerService);

            m_wakeLock = powerManager.NewWakeLock(WakeLockFlags.ScreenBright, "tracking_wake_lock");
        }