Ejemplo n.º 1
0
 public void Initialize()
 {
     if (Singleton.Any <INotifier>())
     {
         _notifier = Singleton.Resolve <INotifier>();
     }
 }
Ejemplo n.º 2
0
 public static void Initialize()
 {
     if (!Singleton.Any <ILogger>())
     {
         Singleton.Add(new LogStub());
     }
     if (!Singleton.Any <LazuriteContext>())
     {
         Singleton.Add(new LazuriteContext());
     }
     if (!Singleton.Any <SaviorBase>())
     {
         Singleton.Add(new JsonFileSavior());
     }
     if (!Singleton.Any <ISystemUtils>())
     {
         Singleton.Add(new SystemUtils());
     }
     if (!Singleton.Any <IServiceClientManager>())
     {
         Singleton.Add(new ServiceClientManager());
     }
     if (!Singleton.Any <AddictionalDataManager>())
     {
         Singleton.Add(new AddictionalDataManager());
     }
     if (!Singleton.Any <INotifier>())
     {
         Singleton.Add(new Notifier());
     }
     if (!Singleton.Any <IGeolocationView>())
     {
         Singleton.Add(new GeolocationViewIntentCreator());
     }
 }
Ejemplo n.º 3
0
 public void UpdateView(Action callback)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         if (Singleton.Any <LazuriteContext>())
         {
             warnMessageView.IsVisible = false;
             var scenariosManager      = Singleton.Resolve <LazuriteContext>().Manager;
             scenariosManager.GetListenerSettings((settings) =>
             {
                 _currentListenerSettings = settings;
                 scenariosManager.GetGeolocationListenerSettings((gpsSettings) =>
                 {
                     _currentGeolocationSettings = gpsSettings;
                     scenariosManager.GetGeolocationAccuracy((gpsAccuracy) =>
                     {
                         _currentGelocationAccuracy = gpsAccuracy;
                         callback?.Invoke();
                     });
                 });
             });
         }
         else
         {
             warnMessageView.IsVisible = true;
             callback?.Invoke();
         }
     });
 }
Ejemplo n.º 4
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (Singleton.Any <LazuriteContext>())
     {
         var scenariosManager = Singleton.Resolve <LazuriteContext>().Manager;
         scenariosManager?.ScreenOnActions(); // В старых версиях андройда это свойство может быть не инициализировано при разблокировке экрана
     }
 }
Ejemplo n.º 5
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (Singleton.Any <LazuriteContext>())
     {
         var scenariosManager = Singleton.Resolve <LazuriteContext>().Manager;
         scenariosManager.ScreenOnActions();
     }
 }
        public static void Initialize()
        {
            if (!Singleton.Any <ILogger>())
            {
                Singleton.Add(new LogStub());
            }

            if (!Singleton.Any <LazuriteContext>())
            {
                Singleton.Add(new LazuriteContext());
            }

            if (!Singleton.Any <DataEncryptor>())
            {
                Singleton.Add(new AndroidSpecificDataEncryptor());
            }

            if (!Singleton.Any <DataManagerBase>())
            {
                Singleton.Add(new JsonFileManager());
            }

            if (!Singleton.Any <ISystemUtils>())
            {
                Singleton.Add(new SystemUtils());
            }

            if (!Singleton.Any <AddictionalDataManager>())
            {
                Singleton.Add(new AddictionalDataManager());
            }

            if (!Singleton.Any <INotifier>())
            {
                Singleton.Add(new Notifier());
            }

            if (!Singleton.Any <IGeolocationView>())
            {
                Singleton.Add(new GeolocationViewIntentCreator());
            }

            if (!Singleton.Any <StoredPropertiesManager>())
            {
                Singleton.Add(new StoredPropertiesManager());
            }

            if (!Singleton.Any <IRuntimePermissionsHandler>())
            {
                Singleton.Add(new RuntimePermissionsHandler());
            }

            if (!Singleton.Any <IGeolocationListener>())
            {
                Singleton.Add(new GeolocationListener());
            }
        }
Ejemplo n.º 7
0
 public StatusViewSwitch()
 {
     InitializeComponent();
     if (Singleton.Any <IHardwareVolumeChanger>())
     {
         _changer             = Singleton.Resolve <IHardwareVolumeChanger>();
         _changer.VolumeDown += _changer_VolumeChanged;
         _changer.VolumeUp   += _changer_VolumeChanged;
     }
 }
Ejemplo n.º 8
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (Singleton.Any <IGeolocationListener>())
     {
         // Try to start listener
         Singleton
         .Resolve <IGeolocationListener>()
         .StartListenChanges();
     }
 }
Ejemplo n.º 9
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, global::Android.Content.PM.Permission[] grantResults)
 {
     base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
     PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
     if (Singleton.Any <IRuntimePermissionsHandler>() && grantResults?.Length > 0)
     {
         var permissionsHandler = Singleton.Resolve <IRuntimePermissionsHandler>();
         permissionsHandler.ResolvePermissionCallback(requestCode, Enumerable.Range(0, permissions.Length).ToDictionary(x => permissions[x], x => grantResults[x] == Permission.Granted));
     }
 }
Ejemplo n.º 10
0
        public FloatViewSwitch()
        {
            InitializeComponent();
            if (Singleton.Any <IHardwareVolumeChanger>())
            {
                _changer             = Singleton.Resolve <IHardwareVolumeChanger>();
                _changer.VolumeDown += _changer_VolumeChanged;
                _changer.VolumeUp   += _changer_VolumeChanged;
            }

            btInput.Click += BtInput_Click;
        }
Ejemplo n.º 11
0
        public FastSwitchWindow()
        {
            if (Singleton.Any <IHardwareVolumeChanger>())
            {
                _oldChanger = Singleton.Resolve <IHardwareVolumeChanger>();
                Singleton.Clear <IHardwareVolumeChanger>();
            }
            Singleton.Add(this); // Add as IHardwareVolumeChanger

            MouseWheel += Window_MouseWheel;
            Closed     += FastSwitchWindow_Closed;
            InitializeComponent();
            switchesGrid.Initialize();
        }
        public FloatViewSliderSwitch()
        {
            InitializeComponent();
            if (Singleton.Any <IHardwareVolumeChanger>())
            {
                _changer             = Singleton.Resolve <IHardwareVolumeChanger>();
                _changer.VolumeDown += _changer_VolumeChanged;
                _changer.VolumeUp   += _changer_VolumeChanged;
            }

            btInput.Clicked  += BtInput_Clicked;
            btOn.Clicked     += (o, e) => SetMax();
            btMiddle.Clicked += (o, e) => SetMiddle();
            btOff.Clicked    += (o, e) => SetMin();
        }
Ejemplo n.º 13
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (Singleton.Any <IGeolocationListener>())
     {
         var listener = Singleton.Resolve <IGeolocationListener>();
         if (intent.GetBooleanExtra("enabled", false))
         {
             listener.StartListenChanges();
         }
         else
         {
             listener.Stop();
         }
     }
 }
Ejemplo n.º 14
0
        public void Notify(Lazurite.Shared.Message message)
        {
            var newId = GetNextNotificationId();

            var lazNotification = new LazuriteNotification();

            lazNotification.Id      = newId;
            lazNotification.Message = message;
            _notificationsCache.Insert(0, lazNotification);

            var context = global::Android.App.Application.Context;

            var activityIntent = new Intent(context, typeof(MainActivity));

            activityIntent.PutExtra(Keys.NeedOpenNotifications, newId);

            var showActivityIntent = PendingIntent.GetActivity(Application.Context, 0, activityIntent, PendingIntentFlags.UpdateCurrent);

            var notificationManager = context.GetSystemService(Context.NotificationService) as NotificationManager;
            var channelId           = Build.VERSION.SdkInt >= BuildVersionCodes.O ? CreateNotificationChannel(notificationManager) : string.Empty;

            var notificationBuilder = new NotificationCompat.Builder(context, channelId);

            notificationBuilder.SetContentTitle(message.Header);
            notificationBuilder.SetContentText(message.Text);
            notificationBuilder.SetContentIntent(showActivityIntent);
            notificationBuilder.SetSmallIcon(Resource.Drawable.message);
            notificationBuilder.SetLargeIcon(BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.icon));
            notificationBuilder.SetPriority((int)NotificationPriority.Max);
            notificationBuilder.SetDefaults((int)NotificationDefaults.All);
            notificationBuilder.SetColor(Color.Purple);
            notificationBuilder.SetOnlyAlertOnce(true);
            notificationBuilder.SetAutoCancel(true);
            notificationBuilder.SetCategory(Notification.CategoryMessage);
            notificationBuilder.SetVisibility((int)NotificationVisibility.Private);

            notificationManager.Notify(newId, notificationBuilder.Build());

            if (Singleton.Any <INotificationsHandler>())
            {
                var notificationHandler = Singleton.Resolve <INotificationsHandler>();
                if (notificationHandler.NeedViewPermanently)
                {
                    notificationHandler.UpdateNotificationsInfo();
                }
            }
        }
Ejemplo n.º 15
0
        public ScenariosManager()
        {
            if (!Singleton.Any <IGeolocationListener>())
            {
                var listener = new GeolocationListener();
                Singleton.Add(listener);
                listener.StartListenChanges();
            }

            if (!Bus.Any <GeolocationDataHandler>())
            {
                Bus.Register <GeolocationDataHandler>();
            }
            if (!Bus.Any <DeviceDataHandler>())
            {
                Bus.Register <DeviceDataHandler>();
            }
            if (!Bus.Any <MessagesDataHandler>())
            {
                Bus.Register <MessagesDataHandler>();
            }
        }
        public StatusViewSwitch()
        {
            InitializeComponent();

            // Extra f****** crutch, list view calculates wrong height
            bool crutch = true;

            listView.SizeChanged += (o, e) =>
            {
                if (crutch)
                {
                    crutch = false;
                    listView.HeightRequest = listView.Height + 5;
                }
            };

            if (Singleton.Any <IHardwareVolumeChanger>())
            {
                _changer             = Singleton.Resolve <IHardwareVolumeChanger>();
                _changer.VolumeDown += _changer_VolumeChanged;
                _changer.VolumeUp   += _changer_VolumeChanged;
            }
        }
Ejemplo n.º 17
0
        public void Notify(Lazurite.Shared.Message message)
        {
            var newId = GetNextNotificationId();

            var lazNotification = new LazuriteNotification();

            lazNotification.Id      = newId;
            lazNotification.Message = message;
            _notificationsCache.Insert(0, lazNotification);

            var context = global::Android.App.Application.Context;

            var notificationManager =
                context.GetSystemService(Context.NotificationService) as NotificationManager;

            Notification.Builder builder;

            if (Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.O)
            {
                var channelId = "channel1";
                NotificationChannel mChannel;

                mChannel = new NotificationChannel(channelId, "laz", NotificationImportance.High);
                mChannel.EnableLights(true);
                mChannel.LightColor = Color.White;
                mChannel.SetShowBadge(true);
                mChannel.LockscreenVisibility = NotificationVisibility.Private;
                notificationManager.CreateNotificationChannel(mChannel);
                builder = new Notification.Builder(context, channelId);
            }
            else
            {
                builder = new Notification.Builder(context);
            }

            builder.SetContentTitle(message.Header);
            builder.SetContentText(message.Text);
            builder.SetSmallIcon(Resource.Drawable.icon);
            builder.SetVisibility(NotificationVisibility.Private);
            builder.SetOnlyAlertOnce(true);
            builder.SetDefaults(NotificationDefaults.All);
            builder.SetAutoCancel(true);
            builder.SetColor(Color.Argb(0, 255, 255, 255).ToArgb());

            var activityIntent = new Intent(context, typeof(MainActivity));

            activityIntent.PutExtra(Keys.NeedOpenNotifications, newId);

            var showActivityIntent = PendingIntent.GetActivity(Application.Context, 0,
                                                               activityIntent, PendingIntentFlags.UpdateCurrent);

            builder.SetContentIntent(showActivityIntent);

            var notification = builder.Build();

            notificationManager.Notify(newId, notification);

            if (Singleton.Any <INotificationsHandler>())
            {
                var notificationHandler = Singleton.Resolve <INotificationsHandler>();
                if (notificationHandler.NeedViewPermanently)
                {
                    notificationHandler.UpdateNotificationsInfo();
                }
            }
        }