Пример #1
0
        void OnProductPurchased(int response, Purchase purchase, string purchaseData, string purchaseSignature)
        {
            DeviceDebugAndroid.LogToFileMethodStatic("appstore response: " + response + " // purchase: " + purchase + " // purchaseData: " + purchaseData + " // purchaseSignature: " + purchaseSignature);

            LoadPurchases();
            NotifyListener(PurchaseStatus.Purchased);
        }
Пример #2
0
        void OnDisconnected()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            if (inAppBillingServiceConnection != null)
            {
                if (inAppBillingServiceConnection.BillingHandler != null)
                {
                    inAppBillingServiceConnection.BillingHandler.OnUserCanceled                    -= OnUserCanceled;
                    inAppBillingServiceConnection.BillingHandler.OnGetProductsError                -= OnGetProductsError;
                    inAppBillingServiceConnection.BillingHandler.OnProductPurchased                -= OnProductPurchased;
                    inAppBillingServiceConnection.BillingHandler.OnPurchaseConsumed                -= OnPurchaseConsumed;
                    inAppBillingServiceConnection.BillingHandler.OnProductPurchasedError           -= OnProductPurchasedError;
                    inAppBillingServiceConnection.BillingHandler.OnPurchaseConsumedError           -= OnPurchaseConsumedError;
                    inAppBillingServiceConnection.BillingHandler.OnPurchaseFailedValidation        -= OnPurchaseFailedValidation;
                    inAppBillingServiceConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned -= OnInvalidOwnedItemsBundleReturned;
                    inAppBillingServiceConnection.BillingHandler.QueryInventoryError               -= OnQueryInventoryError;
                    inAppBillingServiceConnection.BillingHandler.InAppBillingProcesingError        -= OnInAppBillingProcessingError;
                    inAppBillingServiceConnection.BillingHandler.BuyProductError                   -= OnBuyProductError;
                }

                inAppBillingServiceConnection.OnConnected         -= OnConnected;
                inAppBillingServiceConnection.OnInAppBillingError -= OnInAppBillingError;
                inAppBillingServiceConnection.OnDisconnected      -= OnDisconnected;

                NotifyListener(PurchaseStatus.Disconnected);
            }
        }
Пример #3
0
        void OnPurchaseConsumed(string token)
        {
            DeviceDebugAndroid.LogToFileMethodStatic("appstore token: " + token);

            LoadPurchases();
            NotifyListener(PurchaseStatus.Consumed);
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

#if DEBUG
            Config.EnableDebugBuild();
#else
            if (Config.IsConfigForReleaseBuildValid() == false)
            {
                DeviceCrashReportAndroid.sendMail(new Throwable("Release build: Config check not passed"),
                                                  ApplicationContext.Resources.GetString(Resource.String.applicationName),
                                                  ApplicationContext.Resources.GetString(Resource.String.contactMail));
            }
#endif

            DeviceDebugAndroid.LogToFileMethodStatic();

            // init xamarin.forms framework in a new backgound task, splash stays on screen
            Task task = new Task
                        (
                delegate
            {
                Forms.Init(this, savedInstanceState);
                OxyPlot.Xamarin.Forms.Platform.Android.Forms.Init();
            }
                        );

            task.Start();
        }
Пример #5
0
        // activity is visible
        protected override void OnStart()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            base.OnStart();

            devicePurchseAndroid.SetActivity(this);

            // connect to google play store
            devicePurchseAndroid.Connect();
        }
        public void Disconnect()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            if (inAppBillingServiceConnection != null)
            {
                if (inAppBillingServiceConnection.Connected)
                {
                    inAppBillingServiceConnection.Disconnect();
                }
            }
        }
Пример #7
0
        public void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            DeviceDebugAndroid.LogToFileMethodStatic("appstore result [requestCode, resultCode]: " + requestCode + ", " + resultCode);

            if (inAppBillingServiceConnection != null)
            {
                if (inAppBillingServiceConnection.BillingHandler != null)
                {
                    inAppBillingServiceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data);
                }
            }
        }
Пример #8
0
        protected override void OnStart()
        {
            base.OnStart();
            DeviceDebugAndroid.LogToFileMethodStatic();

            // switch to the main app in a new backgound task
            Task task = new Task
                        (
                () => StartActivity(typeof(ActivityMain))
                        );

            task.Start();
        }
        public void Connect()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            if (activity != null)
            {
                inAppBillingServiceConnection = new InAppBillingServiceConnection(activity, GetPublicKey());

                // below events are unregistered in OnDisconnect()
                inAppBillingServiceConnection.OnConnected         += OnConnected;
                inAppBillingServiceConnection.OnInAppBillingError += OnInAppBillingError;
                inAppBillingServiceConnection.OnDisconnected      += OnDisconnected;

                inAppBillingServiceConnection.Connect();
            }
        }
Пример #10
0
        // activity is not visible or being distroyed by the system
        protected override void OnStop()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            if (Config.Purchase.ConsumeOnExitEnabled)
            {
                base.OnStop();
                // disconnect from google play store
                devicePurchseAndroid.Disconnect();
            }
            else
            {
                // disconnect from google play store
                devicePurchseAndroid.Disconnect();
                base.OnStop();
            }
        }
        void Log(string s = "",
                 [System.Runtime.CompilerServices.CallerMemberName] string methodName     = "",
                 [System.Runtime.CompilerServices.CallerFilePath]   string sourceFilePath = "")
        {
            if (s != null)
            {
                if (Config.Purchase.ListenerLogEnabled)
                {
                    if (listener != null)
                    {
                        listener.OnPurchaseLog(s);
                    }
                }

                DeviceDebugAndroid.LogToFileMethodStatic("appstore " + s, methodName, sourceFilePath);
            }
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            DeviceDebugAndroid.LogToFileMethodStatic();

            // setup handler for uncaught exceptions
            Thread.DefaultUncaughtExceptionHandler = this;

            // request screen is always on
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            //UncaughtException(null, new Exception());

            // our google play store
            devicePurchseAndroid = new DevicePurchaseAndroid();

            // start xamarin.forms app
            LoadApplication(new App());
        }
        void LoadPurchases()
        {
            DeviceDebugAndroid.LogToFileMethodStatic();

            if (purchases != null)
            {
                purchases.Clear();
            }
            else
            {
                purchases = new List <Purchase>();
            }

            if (inAppBillingServiceConnection != null)
            {
                if (inAppBillingServiceConnection.BillingHandler != null)
                {
                    purchases = inAppBillingServiceConnection.BillingHandler.GetPurchases(ItemType.Product);
                }
            }
        }
Пример #14
0
        void OnBuyProductError(int responseCode, string sku)
        {
            DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // sku: " + sku);

            NotifyListener(PurchaseStatus.Cancelled);
        }
Пример #15
0
 void OnInAppBillingProcessingError(string message)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore message: " + message);
 }
Пример #16
0
 void OnQueryInventoryError(int responseCode, Bundle skuDetails)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // skuDetails: " + skuDetails);
 }
Пример #17
0
 void OnUserCanceled()
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore user cancaled");
     NotifyListener(PurchaseStatus.Cancelled);
 }
Пример #18
0
 public void OnAccuracyChanged(Sensor sensor, SensorStatus accuracy) // ISensorEventListener
 {
     status = "sensor accuracy changed to " + accuracy;
     DeviceDebugAndroid.LogToFileMethodStatic(status);
 }
Пример #19
0
 void OnGetProductsError(int responseCode, Bundle ownedItems)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // ownedItems: " + ownedItems);
 }
Пример #20
0
 public void OnProviderEnabled(string provider) // ILocationListener
 {
     status = IDeviceGpsStatus.Enabled;
     DeviceDebugAndroid.LogToFileMethodStatic(status.ToString());
 }
Пример #21
0
        public void OnGpsStatusChanged(GpsEvent e) // GpsStatus.IListener
        {
            if (locationManager != null)
            {
                gpsStatus = locationManager.GetGpsStatus(gpsStatus);

                switch (e)
                {
                case GpsEvent.FirstFix:
                    status = IDeviceGpsStatus.FirstFix;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;

                case GpsEvent.SatelliteStatus:
                    if (gpsStatus != null)
                    {
                        gpsSatellitesVisible       = 0;
                        gpsSatellitesUsedInFix     = 0;
                        gpsSatellitesWithEphemeris = 0;
                        gpsSatellitesWithAlmanac   = 0;

                        var satellites = gpsStatus.Satellites;
                        if (satellites != null)
                        {
                            Java.Util.IIterator iterator = satellites.Iterator();
                            {
                                while (iterator.HasNext)
                                {
                                    gpsSatellitesVisible++;

                                    var s = (GpsSatellite)iterator.Next();
                                    if (s.UsedInFix())
                                    {
                                        gpsSatellitesUsedInFix++;
                                    }
                                    if (s.HasEphemeris)
                                    {
                                        gpsSatellitesWithEphemeris++;
                                    }
                                    if (s.HasAlmanac)
                                    {
                                        gpsSatellitesWithAlmanac++;
                                    }
                                }
                            }

                            if (gpsSatellitesUsedInFix > 3)
                            {
                                status = IDeviceGpsStatus.Connected;
                            }
                        }
                    }
                    break;

                case GpsEvent.Started:
                    status = IDeviceGpsStatus.Started;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;

                case GpsEvent.Stopped:
                    status = IDeviceGpsStatus.Stopped;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;
                }

                if (listener != null)
                {
                    listener.OnGpsStatusUpdate();
                }
            }
        }
Пример #22
0
 void OnInAppBillingError(InAppBillingErrorType error, string message)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore *** error *** " + error + " // message: " + message);
 }
Пример #23
0
 void OnPurchaseConsumedError(int responseCode, string token)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // token: " + token);
 }
Пример #24
0
 void OnProductPurchasedError(int responseCode, string sku)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // sku: " + sku);
 }
Пример #25
0
 void OnInvalidOwnedItemsBundleReturned(Bundle ownedItems)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore ownedItems: " + ownedItems);
 }
Пример #26
0
        public void OnSensorChanged(SensorEvent e) // ISensorEventListener
        {
            if (e != null)
            {
                if ((e.Sensor.Type == SensorType.LinearAcceleration) || (e.Sensor.Type == SensorType.Accelerometer))
                {
                    long launchTimeNow = stopwatch.ElapsedMilliseconds;

                    sensorX = e.Values[0];
                    sensorY = e.Values[1];
                    sensorZ = e.Values[2];

                    sensorTimestamp = e.Timestamp;

                    // e.Timestamp = nanoseconds since 01. januar 1970
                    // e.Timestamp / 1 000 000 000 = seconds

                    if (isFirstRun)
                    {
                        isFirstRun              = false;
                        launchTimeLastUpdate    = launchTimeNow;
                        launchTimeDetectedStart = 0;
                        sensorTimestampFirst    = sensorTimestamp;
                        sensorAcceleration      = 0;
                        sensorSpeed             = 0;
                        DeviceDebugAndroid.LogToFileMethodStatic("first values received");
                        DeviceDebugAndroid.LogToFileMethodStatic("accelerometer info: " + GetInfo());
                    }
                    else
                    {
                        sensorXDelta = sensorX - sensorXLast;
                        sensorYDelta = sensorY - sensorYLast;
                        sensorZDelta = sensorZ - sensorZLast;

                        sensorTimestampDelta = sensorTimestampLast - sensorTimestamp;

                        var dt           = sensorTimestampDelta / 1000000000.0f; // from nanoseconds to seconds
                        var sensorSpeedX = sensorXDelta * dt;                    // from acceleration to velocity (x component)
                        var sensorSpeedY = sensorYDelta * dt;                    // from acceleration to velocity (y component)
                        var sensorSpeedZ = sensorZDelta * dt;                    // from acceleration to velocity (z component)

                        // speed magnitude of all components
                        var magnitude = (float)Math.Sqrt(sensorSpeedX * sensorSpeedX + sensorSpeedY * sensorSpeedY + sensorSpeedZ * sensorSpeedZ);

                        // integrate the magnitude onto previous speed
                        // take the direction into account
                        if (sensorIsAccelerating)
                        {
                            sensorSpeed += magnitude;
                        }
                        else
                        {
                            sensorSpeed -= magnitude;
                        }

                        // acceleration calculation
                        var sensorXCompensated = sensorX - sensorAxisOffsetX;
                        var sensorYCompensated = sensorY - sensorAxisOffsetY;
                        var sensorZCompensated = sensorZ - sensorAxisOffsetZ;

                        // acceleration magnitude of all components
                        sensorAcceleration = (float)Math.Sqrt(sensorXCompensated * sensorXCompensated +
                                                              sensorYCompensated * sensorYCompensated +
                                                              sensorZCompensated * sensorZCompensated);

                        if (isRawDataLoggingEnabled)
                        {
                            DeviceDebugAndroid.LogToFileSensorStatic(GetTimeStamp(), sensorX, sensorY, sensorZ, sensorAcceleration);
                        }

                        long launchTimeDiff = launchTimeNow - launchTimeLastUpdate;

                        if (launchTimeDiff > launchTimeUpdateInterval)
                        {
                            launchTimeLastUpdate = launchTimeNow;
                            var launchForce = Math.Abs(sensorXDelta + sensorYDelta + sensorZDelta);

                            if (launchForce * 10 > launchForceDetectLimit)
                            {
                                if (launchTimeDetectedStart == 0)
                                {
                                    launchTimeDetectedStart = launchTimeNow;
                                }

                                if (launchTimeNow - launchTimeDetectedStart > launchTimeDetectLimit)
                                {
                                    if (listener != null)
                                    {
                                        listener.OnAcceleromterLaunchDetected();
                                        launchTimeDetectedStart = 0;
                                    }
                                }
                            }
                        }
                    }

                    sensorXLast         = sensorX;
                    sensorYLast         = sensorY;
                    sensorZLast         = sensorZ;
                    sensorTimestampLast = sensorTimestamp;

                    if (listener != null)
                    {
                        listener.OnAcceleromterUpdate();
                    }
                }
            }
        }
Пример #27
0
 void OnPurchaseFailedValidation(Purchase purchase, string purchaseData, string purchaseSignature)
 {
     DeviceDebugAndroid.LogToFileMethodStatic("appstore purchase: " + purchase + " // purchaseData: " + purchaseData + " // purchaseSignature: " + purchaseSignature);
 }