protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            myInstance = this;
            SetContentView(Resource.Layout.TrackingActivityLayout);
            OnNewIntent(Intent);
            if (savedInstanceState != null)
            {
                isStarted = savedInstanceState.GetBoolean(Constants.SERVICE_STARTED_KEY, false);
            }

            startServiceIntent = new Intent(this, typeof(SensorTrackingService));
            startServiceIntent.SetAction(Constants.ACTION_START_SERVICE);

            stopServiceIntent = new Intent(this, typeof(SensorTrackingService));
            stopServiceIntent.SetAction(Constants.ACTION_STOP_SERVICE);

            switchServiceButton        = FindViewById <FloatingTextButton>(Resource.Id.start_service_button);
            switchServiceButton.Click += SwitchService_Click;

            mCoordinator = FindViewById <CoordinatorLayout>(Resource.Id.coordinator);

            //AnimatedVectorDrawableCompat aa= AnimatedVectorDrawableCompat.Create(this,Resource.Drawable;
            startIcon = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_play, Theme);
            stopIcon  = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_stop, Theme);

            if (isStarted)
            {
                switchServiceButton.Text             = GetText(Resource.String.stop);
                switchServiceButton.LeftIconDrawable = (stopIcon);
            }
            else
            {
                switchServiceButton.LeftIconDrawable = (startIcon);
                switchServiceButton.Text             = GetText(Resource.String.start);
            }

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayShowHomeEnabled(true);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            }
            mySensorDataReceiver = new XYZDataReceiver();
            myStopSignalReceiver = new StopSignalReceiver();
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(mySensorDataReceiver, new IntentFilter("SensorBroadcast"));
            LocalBroadcastManager.GetInstance(this).RegisterReceiver(myStopSignalReceiver, new IntentFilter("StoppingSignal"));
        }
Ejemplo n.º 2
0
        public MainMenuPage(
            AssetsLoader assetsLoader,
            GameOrchestrator gameOrchestrator,
            IScreenTransformationMatrixProvider matrixScaleProvider,
            ILocalizedStringsRepository localizedStringsRepository,
            RateMeDialog rateMeDialog,
            ISettingsRepository settingsRepository)
        {
            _backgroundRectangle = new Rectangle(0, 0, matrixScaleProvider.VirtualWidth, matrixScaleProvider.VirtualHeight);

            var titleFont = assetsLoader.TitleFont;

            _writingFont  = assetsLoader.WritingFont;
            _rateMeDialog = rateMeDialog ?? throw new ArgumentNullException(nameof(rateMeDialog));

            const string titleText = "RELLOW";

            _title = new FloatingText(
                titleText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 250f),
                Origin       = titleFont.GetTextCenter(titleText),
                OverlayColor = _foregroundColor
            },
                titleFont);

            var playText = localizedStringsRepository.Get(GameStringsLoader.PlayStringKey);

            _playButton = new FloatingTextButton(
                playText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 850f),
                Origin       = _writingFont.GetTextCenter(playText),
                OverlayColor = _foregroundColor
            },
                _writingFont,
                () =>
            {
                gameOrchestrator.SetGameState();
            });

            var aboutText = localizedStringsRepository.Get(GameStringsLoader.AboutStringKey);

            _aboutButton = new FloatingTextButton(
                aboutText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 1150f),
                Origin       = _writingFont.GetTextCenter(aboutText),
                OverlayColor = _foregroundColor
            },
                _writingFont,
                () =>
            {
                gameOrchestrator.SetAboutState();
            });

            var currentScore = settingsRepository.GetOrSetInt(Definitions.SCORE_KEY, 0);

            _scoreText         = $"{localizedStringsRepository.Get(GameStringsLoader.ScoreStringKey)}:{currentScore}";
            _scoreDrawingInfos = new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, matrixScaleProvider.VirtualHeight - 250f - 200f),
                Origin       = _writingFont.GetTextCenter(_scoreText),
                OverlayColor = _scoreColor,
                Scale        = 0.5f
            };
        }