Beispiel #1
0
        public void OnLocationChanged(Location location)
        {
            currentLocation = location;
            Context        mContext = Application.Context;
            AppPreferences applicationPreferences = new AppPreferences(mContext);

            if (currentLocation == null)
            {
                TrackingScan.SetBackgroundColor(Android.Graphics.Color.LightPink);
                coordinates.Text = "No GPS fix yet ";
                //Error Message
            }
            else
            {
                applicationPreferences.SaveAccessKey("lastKnownLongitude", currentLocation.Longitude.ToString());
                applicationPreferences.SaveAccessKey("lastKnownLatitude", currentLocation.Latitude.ToString());
                coordinates.Text = "Lat:" + currentLocation.Latitude.ToString(("#.00000")) + " / Long:" + currentLocation.Longitude.ToString(("#.00000"));
            }
        }
Beispiel #2
0
        private void SetBatchNumber(bool regenerate)
        {
            Context        AppContext             = Application.Context;
            AppPreferences applicationPreferences = new AppPreferences(AppContext);

            if (string.IsNullOrEmpty(applicationPreferences.GetAccessKey("batchnumber")) || regenerate)
            {
                Guid batch = Guid.NewGuid();
                applicationPreferences.SaveAccessKey("batchnumber", batch.ToString());
            }

            string batchnumber = applicationPreferences.GetAccessKey("batchnumber");
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            switch (item.ItemId)
            {
            case Resource.Id.menu_settings:
                StartActivity(typeof(SettingsActivity));
                break;

            case Resource.Id.menu_signature:
                Context        mContext = Application.Context;
                AppPreferences applicationPreferences = new AppPreferences(mContext);
                applicationPreferences.SaveAccessKey("lastKnownLongitude", currentLocation.Longitude.ToString());
                applicationPreferences.SaveAccessKey("lastKnownLatitude", currentLocation.Latitude.ToString());
                StartActivity(typeof(SignaturPadActivity));
                break;

            case Resource.Id.menu_sqldata:
                StartActivity(typeof(SqliteActivity));
                break;

            case Resource.Id.menu_about:
                StartActivity(typeof(AboutActivity));
                break;

            case Resource.Id.menu_exportdata:
                ExportScanData();
                break;

            case Resource.Id.menu_exit:
                // This should exit the app
                this.FinishAffinity();
                break;
                ;
            }

            return(base.OnOptionsItemSelected(item));
        }
Beispiel #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestedOrientation = ScreenOrientation.Portrait;
            Context        AppContext             = Application.Context;
            AppPreferences applicationPreferences = new AppPreferences(AppContext);

            base.OnCreate(savedInstanceState);

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

            // Load up any stored applicationPreferences
            TextView submitDataUrl = FindViewById <TextView>(Resource.Id.submit_data_url);

            submitDataUrl.Text = applicationPreferences.GetAccessKey("submitDataUrl");
            submitDataUrl.Text = submitDataUrl.Text.TrimEnd('\r', '\n');

            TextView loadConfigUrl = FindViewById <TextView>(Resource.Id.load_config_url);

            loadConfigUrl.Text = applicationPreferences.GetAccessKey("loadConfigUrl");
            loadConfigUrl.Text = loadConfigUrl.Text.TrimEnd('\r', '\n');

            TextView applicationKey = FindViewById <TextView>(Resource.Id.application_key);

            applicationKey.Text = applicationPreferences.GetAccessKey("applicationKey");
            applicationKey.Text = applicationKey.Text.TrimEnd('\r', '\n');

            TextView retentionPeriod = FindViewById <TextView>(Resource.Id.retention_period);

            retentionPeriod.Text = applicationPreferences.GetAccessKey("retentionPeriod");
            retentionPeriod.Text = retentionPeriod.Text.TrimEnd('\r', '\n');

            string databasePath = System.IO.Path.Combine(
                System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
                GetString(Resource.String.database_name));
            SQLiteConnection databaseConnection = new SQLiteConnection(databasePath);

            databaseConnection.CreateTable <ScanSKUDataBase.TrackingNumberPatterns>();

            PopulateRegExView();
            TrackingScan = FindViewById <EditText>(Resource.Id.txtentry);


            TrackingScan.Text = "";
            TrackingScan.RequestFocus();

            TrackingScan.KeyPress += (object sender, View.KeyEventArgs e) =>
            {
                if ((e.Event.Action == KeyEventActions.Down) && (e.KeyCode == Keycode.Enter))
                {
                    if (e.Event.RepeatCount == 0)
                    {
                        string jsonstring = TrackingScan.Text;
                        //jsonstring = Regex.Replace(jsonstring, @"\s+", "");
                        Configuration configuration = new Configuration();
                        try
                        {
                            configuration = JsonConvert.DeserializeObject <Configuration>(jsonstring);
                            if (configuration.UpdateConfiguration.Count == 1)
                            {
                                foreach (UpdateConfiguration configItem in configuration.UpdateConfiguration)
                                {
                                    submitDataUrl.Text   = configItem.UploadEndPoint.ToString();
                                    loadConfigUrl.Text   = configItem.RegexEndPoint.ToString();
                                    applicationKey.Text  = configItem.ApplicationKey.ToString();
                                    retentionPeriod.Text = configItem.RetentionPeriod.ToString();
                                }
                                // Save some application preferences
                                applicationPreferences.SaveAccessKey("submitDataUrl", submitDataUrl.Text, true);
                                applicationPreferences.SaveAccessKey("loadConfigUrl", loadConfigUrl.Text, true);
                                applicationPreferences.SaveAccessKey("applicationKey", applicationKey.Text, true);
                                applicationPreferences.SaveAccessKey("retentionPeriod", retentionPeriod.Text, true);
                                try
                                {
                                    applicationPreferences.SaveAccessKey("serialNumber", Android.OS.Build.Serial.ToString(), true);
                                }
                                catch
                                {
                                    applicationPreferences.SaveAccessKey("serialNumber", "", true);
                                }
                                Log.Info("TAG-SETTINGS", "Settings - Call FetchTrackingRegExData");
                                System.Threading.Tasks.Task taskA = System.Threading.Tasks.Task.Factory.StartNew(() => FetchTrackingRegExData(loadConfigUrl.Text));
                                taskA.Wait();
                                Toast.MakeText(this, "Config QR code read successful", ToastLength.Long).Show();
                            }
                        }
                        catch (Exception ex)
                        {
                            // Any Error in the above block will cause this catch to fire - Even if the json keys don't exist
                            Toast.MakeText(this, "Config QR code not recognised", ToastLength.Long).Show();
                        }
                        PopulateRegExView();
                        TrackingScan.Text = "";
                    }
                }
            };
        }