Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            orientationListener = new OrientationListener(this);
            if (orientationListener.CanDetectOrientation())
            {
                orientationListener.Enable();
            }

            // hide window title
            this.RequestedOrientation = ScreenOrientation.Landscape;
            RequestWindowFeature(WindowFeatures.NoTitle);

            // make app fullscreen
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Create our OpenGL view, and display it
            view = new GLView(this);

            SetContentView(view);

            view.Run();

            //Accelerometer.SetupAccelerometer(this);
        }
    // Use this for initialization
    void Awake()
    {
        instance = this;

        screenWidth  = Screen.width;
        screenHeight = Screen.height;

        if (activateOnPortrait == null)
        {
            activateOnPortrait = new List <GameObject>();
        }
        if (activateOnLandscape == null)
        {
            activateOnLandscape = new List <GameObject>();
        }
        if (activateScriptsOnPortrait == null)
        {
            activateScriptsOnPortrait = new List <Behaviour>();
        }
        if (activateScriptsOnLandscape == null)
        {
            activateScriptsOnLandscape = new List <Behaviour>();
        }
        if (repositionOnPortrait == null)
        {
            repositionOnPortrait = new List <RepositionPair>();
        }
        if (repositionOnLandscape == null)
        {
            repositionOnLandscape = new List <RepositionPair>();
        }

        HandleObjects();
    }
	// Use this for initialization
	void Awake ()
	{
		instance = this;
		
		screenWidth = Screen.width;
		screenHeight = Screen.height;
		
		if (activateOnPortrait == null) {
			activateOnPortrait = new List<GameObject>();
		}
		if (activateOnLandscape == null) {
			activateOnLandscape = new List<GameObject>();
		}
		if (activateScriptsOnPortrait == null) {
			activateScriptsOnPortrait = new List<Behaviour>();
		}
		if (activateScriptsOnLandscape == null) {
			activateScriptsOnLandscape = new List<Behaviour>();
		}
		if (repositionOnPortrait == null) {
			repositionOnPortrait = new List<RepositionPair>();
		}
		if (repositionOnLandscape == null) {
			repositionOnLandscape = new List<RepositionPair>();
		}
		
		HandleObjects();
	}
Exemplo n.º 4
0
		protected override void OnCreate (Bundle savedInstanceState)
		{			
			base.OnCreate (savedInstanceState);
			o = new OrientationListener(this);	
			if (o.CanDetectOrientation())
			{
				o.Enable();				
			}						
		}	
Exemplo n.º 5
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			o = new OrientationListener(this);	
			if (o.CanDetectOrientation())
			{
				o.Enable();				
			}					

            RequestWindowFeature(WindowFeatures.NoTitle);
		}
Exemplo n.º 6
0
		/// <summary>
		/// OnCreate called when the activity is launched from cold or after the app
		/// has been killed due to a higher priority app needing the memory
		/// </summary>
		/// <param name='savedInstanceState'>
		/// Saved instance state.
		/// </param>
		protected override void OnCreate (Bundle savedInstanceState)
		{
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);

			IntentFilter filter = new IntentFilter();
		    filter.AddAction(Intent.ActionScreenOff);
		    filter.AddAction(Intent.ActionScreenOn);
		    filter.AddAction(Intent.ActionUserPresent);
		    
		    screenReceiver = new ScreenReceiver();
		    RegisterReceiver(screenReceiver, filter);

            _orientationListener = new OrientationListener(this);

			Game.Activity = this;
		}
Exemplo n.º 7
0
		/// <summary>
		/// OnCreate called when the activity is launched from cold or after the app
		/// has been killed due to a higher priority app needing the memory
		/// </summary>
		/// <param name='savedInstanceState'>
		/// Saved instance state.
		/// </param>
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			o = new OrientationListener(this);	
			if (o.CanDetectOrientation())
			{
				o.Enable();				
			}					

			IntentFilter filter = new IntentFilter();
		    filter.AddAction(Intent.ActionScreenOff);
		    filter.AddAction(Intent.ActionScreenOn);
		    filter.AddAction(Intent.ActionUserPresent);
		    
		    screenReceiver = new ScreenReceiver();
		    RegisterReceiver(screenReceiver, filter);

            RequestWindowFeature(WindowFeatures.NoTitle);
		}
Exemplo n.º 8
0
 public void SetListener(OrientationListener listener)
 {
     this.listener = listener;
 }
Exemplo n.º 9
0
 public OrientationManager(Context context, [GeneratedEnum] SensorDelay rate, OrientationListener listener) : base(context, rate)
 {
     SetListener(listener);
 }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(Resource.Style.AppThemeClearStatusBar);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_camera);

            //CrashLytics
            Fabric.Fabric.With(this, new Crashlytics.Crashlytics());
            Crashlytics.Crashlytics.HandleManagedExceptions();

            RequestPermissions(permissions, 0);

            if (Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape)
            {
                RequestedOrientation = ScreenOrientation.Portrait;
            }

            toggleFlashButton       = FindViewById <ImageButton>(Resource.Id.toggleFlashButton);
            takePictureButton       = FindViewById <Button>(Resource.Id.takePictureButton);
            openGalleryButton       = FindViewById <ImageButton>(Resource.Id.openGalleryButton);
            openDefaultCameraButton = FindViewById <ImageButton>(Resource.Id.openDefaultCamera);

            cameraPreview = FindViewById <FrameLayout>(Resource.Id.cameraView);

            imageManager = new ImageManager();
            imageManager.AddOnImageResultListener(delegate(Bitmap bitmap, string path, Exception ex)
            {
                if (path != null)
                {
                    StopCamera();
                    Intent intent = new Intent(this, typeof(MainViewActivity));
                    intent.PutExtra("image", path);
                    StartActivity(intent);
                }
                else if (ex != null)
                {
                    Toast.MakeText(Application.Context, ex.Message, ToastLength.Short).Show();
                    StartCamera();
                }
                else
                {
                    StartCamera();
                }
            });

            //Выбор режима activity на весь экран
            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat)
            {
                Window w = Window;
                w.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            }

            takePictureButton.Click += delegate
            {
                TakePicture();
            };

            toggleFlashButton.Click += delegate
            {
                ToggleFlash();
            };

            openGalleryButton.Click += delegate
            {
                imageManager.PickPhoto();
            };

            openDefaultCameraButton.Click += delegate
            {
                StopCamera();
                imageManager.TakePhoto();
            };

            //Отслеживание смены угла экрана
            orientationListener = new OrientationListener(this, delegate(int angle)
            {
                if (lastAngle != angle)
                {
                    if (lastAngle == -90 && angle == 180)
                    {
                        angle = -180;
                    }
                    toggleFlashButton.Animate().Rotation(angle).Start();
                    openGalleryButton.Animate().Rotation(angle).Start();
                    openDefaultCameraButton.Animate().Rotation(angle).Start();
                    if (angle == -180)
                    {
                        lastAngle = 180;
                    }
                    else
                    {
                        lastAngle = angle;
                    }
                }
            });
        }
Exemplo n.º 11
0
		protected override void OnDestroy ()
		{
            UnregisterReceiver(screenReceiver);
            ScreenReceiver.ScreenLocked = false;
            _orientationListener = null;
            if (Game != null)
                Game.Dispose();
            Game = null;
			base.OnDestroy ();
		}