protected override void OnMessage(Context context, Intent intent)
        {
            Debug.WriteLine("GCM Message Received!");
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(context);

            setupSingleton.EnsureInitialized();

            intent.PrintExtras();

            var notificationResult = GetNotificationResult(intent);

            // No valid notification
            if (notificationResult == null)
            {
                return;
            }

            // Check if activity is running
            if (MainApplication.ApplicationOnPause)
            {
                // Application is not running, create notification
                if (!string.IsNullOrEmpty(notificationResult.Message) && notificationResult.ViewModelIntent != null)
                {
                    var pendingIntent = PendingIntent.GetActivity(Application.Context, 0,
                                                                  notificationResult.ViewModelIntent, 0);
                    CreateNotification(notificationResult.Message, notificationResult.Message, pendingIntent);
                }
            }
            else
            {
                // App is running!!!!
            }
        }
        private static ValueTask EnsureSetupInitialized(this IMvxAndroidView androidView)
        {
            var activity = androidView.ToActivity();
            var setup    = MvxAndroidSetupSingleton.EnsureSingletonAvailable(activity.ApplicationContext);

            return(setup.EnsureInitialized());
        }
Ejemplo n.º 3
0
        public override bool OnStartJob(JobParameters @params)
        {
            // Background sync is temporary disabled due to a crash that is hard to reproduce
            // Calling JobFinished and eturning early here stops the background job from running
            JobFinished(@params, false);
            return(true);

            MvxAndroidSetupSingleton
            .EnsureSingletonAvailable(ApplicationContext)
            .EnsureInitialized();

            var dependencyContainer = AndroidDependencyContainer.Instance;

            if (!dependencyContainer.UserAccessManager.CheckIfLoggedIn())
            {
                return(false);
            }

            disposable = dependencyContainer.InteractorFactory
                         .RunBackgroundSync()
                         .Execute()
                         .Subscribe(_ => JobFinished(@params, false));

            return(true);
        }
        public static void EnsureSetupInitialized(this IMvxFragmentView fragmentView)
        {
            var fragment       = fragmentView.ToFragment();
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(fragment.Activity.ApplicationContext);

            setupSingleton.EnsureInitialized();
        }
Ejemplo n.º 5
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action != Telephony.Sms.Intents.SmsReceivedAction)
            {
                return;
            }

            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(context);

            setup.EnsureInitialized();
            var barrierLogic = Mvx.Resolve <IBarrierLogic>();
            var contactLogic = Mvx.Resolve <IContactLogic>();

            var barrier  = barrierLogic.GetBarrier();
            var contacts = contactLogic.GetAll();

            SmsMessage[] messages = Telephony.Sms.Intents.GetMessagesFromIntent(intent);
            foreach (var t in messages)
            {
                var sender  = t.OriginatingAddress;
                var message = t.MessageBody;
                if (message == barrier.MessageText && contacts.Any(c => c.NumberPrefix.Prefix + c.Number == sender))
                {
                    var callIntent = new Intent(Intent.ActionCall);
                    callIntent.SetData(Uri.Parse("tel:" + barrier.FullNumber));
                    context.StartActivity(callIntent);
                }
            }
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            // Prevents crash when activity in background with history enable is reopened after
            // Android does some auto memory management.
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);

            setup.EnsureInitialized();

            base.OnCreate(bundle);

            if (bundle == null)
            {
                var fragmentRequestText = Intent.Extras?.GetString(ViewModelRequestBundleKey);
                if (fragmentRequestText == null)
                {
                    return;
                }

                var converter       = Mvx.Resolve <IMvxNavigationSerializer> ();
                var fragmentRequest = converter.Serializer.DeserializeObject <MvxViewModelRequest> (fragmentRequestText);

                var mvxAndroidViewPresenter = Mvx.Resolve <IMvxAndroidViewPresenter> ();
                mvxAndroidViewPresenter.Show(fragmentRequest);
            }
        }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);

            setup.EnsureInitialized();

            Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            //SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            Couchbase.Lite.Support.Droid.Activate(ApplicationContext);

            // Setup the application
            Xamarin.Forms.Forms.Init(this, bundle);
            UserDialogs.Init(this);
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            // Register platform specific implementations
            Mvx.RegisterSingleton <IDevice>(() => AndroidDevice.CurrentDevice);
            Mvx.RegisterSingleton <IImageService>(() => new ImageService());

            //Start the application
            var startup = new CoreAppStart();
            var hint    = CoreAppStart.CreateHint();

            startup.Start(hint);

            LoadApplication(FormsApplication);
        }
Ejemplo n.º 9
0
        protected override void OnCreate(Android.OS.Bundle bundle)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnCreate(bundle);

            SetContentView(LayoutId());

            toolbar = FindViewById <SupportToolbar>(Resource.Id.ToolBar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                if (HomeIconId() > -1)
                {
                    SupportActionBar.SetHomeAsUpIndicator(HomeIconId());
                }
                SupportActionBar.SetDisplayShowHomeEnabled(true);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            }


            this.AddLinqBinding(ViewModel, vm => vm.Title, (value) =>
            {
                Title = value;
            });
        }
Ejemplo n.º 10
0
        protected override void OnCreate(Bundle bundle)
        {
            // Prevents crash when activity in background with history enable is reopened after
            // Android does some auto memory management.
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);

            setup.EnsureInitialized();

            base.OnCreate(bundle);

            if (bundle == null)
            {
                HandleIntent(Intent);
            }
            else
            {
                IMvxJsonConverter serializer;
                if (!Mvx.TryResolve(out serializer))
                {
                    Mvx.Trace(
                        "Could not resolve IMvxJsonConverter, it is going to be hard to create ViewModel cache");
                    return;
                }

                FragmentCacheConfiguration.RestoreCacheConfiguration(bundle, serializer);
                // Gabriel has blown his trumpet. Ressurect Fragments from the dead
                RestoreFragmentsCache();

                RestoreViewModelsFromBundle(serializer, bundle);
            }
        }
Ejemplo n.º 11
0
        protected override void OnResume()
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            Task.Run(async() => await Initialize(setup).ConfigureAwait(false));
            base.OnResume();
        }
        protected override void OnCreate(Bundle bundle)
        {
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);

            setupSingleton.EnsureInitialized();
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.FirstLayout);
        }
Ejemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();
            base.OnCreate(bundle);
            SetContentView(LayoutId);
        }
Ejemplo n.º 14
0
        public override void OnCreate()
        {
            base.OnCreate();

            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this);

            setup.EnsureInitialized();
        }
        protected override void OnUnRegistered(Context context, string registrationId)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnUnRegistered(context, registrationId);
        }
Ejemplo n.º 16
0
        protected override void OnResume()
        {
            base.OnResume();
            _isResumed = true;
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.InitializeFromSplashScreen(this);
        }
Ejemplo n.º 17
0
        protected override void OnPause()
        {
            _isResumed = false;
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.RemoveSplashScreen(this);
            base.OnPause();
        }
Ejemplo n.º 18
0
        public override void OnReceive(Context context, Intent intent)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this.ApplicationContext);

            setup.EnsureInitialized();

            base.OnReceive(context, intent);
        }
Ejemplo n.º 19
0
        protected override void OnPause()
        {
            _isResumed = false;
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.CancelMonitor(this);
            base.OnPause();
        }
Ejemplo n.º 20
0
        public void OnLocationChanged(Location location)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(Application.Context);

            setup.EnsureInitialized();

            Mvx.Resolve <IGeoLocationWatcher>().Location = location.GetGeolocationFromAndroidLocation();
        }
        protected override void OnError(Context context, string errorId)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnError(context, errorId);
        }
        protected override void OnHandleIntent(Intent intent)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnHandleIntent(intent);
        }
        protected override void OnMessage(Context context, Intent intent)
        {
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnMessage(context, intent);
        }
Ejemplo n.º 24
0
        protected override void OnStart()
        {
            base.OnStart();
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this.ApplicationContext);

            setup.EnsureInitialized();

            SalesApplication.IsInBackground = false;
        }
Ejemplo n.º 25
0
        protected override void OnCreate(Bundle bundle)
        {
            // Required for proper Push notifications handling
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setupSingleton.EnsureInitialized();

            base.OnCreate(bundle);
            ViewModel?.ViewCreated();
            InitializeForms(bundle);
        }
Ejemplo n.º 26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Required for proper Push notifications handling
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setupSingleton.EnsureInitialized();

            LifetimeListener.OnCreate(this);
        }
Ejemplo n.º 27
0
        protected override void OnCreate(Bundle bundle)
        {
            // The following two lines can be removed if this activity is navigated to immediately after the splash screen
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setupSingleton.EnsureInitialized();

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.my_resource_name);
        }
Ejemplo n.º 28
0
 public static async Task Init(Context context)
 {
     while (MvvmCrossHelper.IsRunning)
     {
         Log.Debug(nameof(MvvmCrossHelper), "MvvmCrossHelper.Init is running");
         Log.Debug(nameof(MvvmCrossHelper), "Context:" + ((object)context).GetType().ToString());
         Log.Debug(nameof(MvvmCrossHelper), string.Format("Context is Activity:{0}", (object)(context is Activity)));
         await Task.Delay(200);
     }
     ((MvxSetupSingleton)MvxAndroidSetupSingleton.EnsureSingletonAvailable(context)).EnsureInitialized();
 }
        protected override async void OnHandleIntent(Intent intent)
        {
            // mvvmcross might not be initialized when service starts
            var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this.ApplicationContext);

            setupSingleton.EnsureInitialized();

            await FetchAndDisplayBitcoinPrice(intent);

            return;
        }
        protected override void OnCreate(Bundle bundle)
        {
            // ensuring mvvmcross is running here is required
            // otherwise app will crash when inflating the view because of the Forms base class
            var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);

            setup.EnsureInitialized();

            base.OnCreate(bundle);
            ViewModel?.ViewCreated();
            RunAppStart(bundle);
        }