Example #1
0
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            string value = string.Empty;

            if (key != "clearCache" && key != "anonymousAccess")
            {
                Preference preference = (Preference)FindPreference(key);

                value = sharedPreferences.GetString(key, string.Empty);

                FillSummary(key, value);

                if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
                {
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutBoolean("clearCache", true);
                    editor.Commit();

                    Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
                }

                if (key == "application")
                {
                    Toast.MakeText(this, D.NEED_TO_REBOOT, ToastLength.Long).Show();
                }
            }
            else
            {
                if (key == "anonymousAccess")
                {
                    string user = "";
                    string password = "";
                    if (sharedPreferences.GetBoolean("anonymousAccess", false))
                    {
                        user = Settings.AnonymousUserName;
                        password = Settings.AnonymousPassword;
                    }
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutString("user", user);
                    editor.PutString("password", password);
                    editor.Commit();
                }

                Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
            }

            BitBrowserApp.Current.SyncSettings(true);
        }
Example #2
0
        public static void SaveCookie(ISharedPreferences sharedPreferences, string cookieKey, Cookie cookie)
        {
            var editor = sharedPreferences.Edit();
            var cookieValueItems = new List<string>();
            var itemFormat = "{0}:{1}";

            cookieValueItems.Clear();

            cookieValueItems.Add(string.Format(itemFormat, "Domain", cookie.Domain));
            cookieValueItems.Add(string.Format(itemFormat, "Name", cookie.Name));
            cookieValueItems.Add(string.Format(itemFormat, "Value", cookie.Value));
            cookieValueItems.Add(string.Format(itemFormat, "Expires", cookie.Expires.ToString()));
            cookieValueItems.Add(string.Format(itemFormat, "Comment", cookie.Comment));
            cookieValueItems.Add(string.Format(itemFormat, "CommentUri", cookie.CommentUri != null ? cookie.CommentUri.AbsoluteUri : null));
            cookieValueItems.Add(string.Format(itemFormat, "Discard", cookie.Discard));
            cookieValueItems.Add(string.Format(itemFormat, "HttpOnly", cookie.HttpOnly));
            cookieValueItems.Add(string.Format(itemFormat, "Path", cookie.Path));
            cookieValueItems.Add(string.Format(itemFormat, "Port", cookie.Port));
            cookieValueItems.Add(string.Format(itemFormat, "Secure", cookie.Secure));
            cookieValueItems.Add(string.Format(itemFormat, "Version", cookie.Version));

            editor.PutString(cookieKey, string.Join("|", cookieValueItems.ToArray()));
            editor.Commit();

            var logger = DependencyResolver.Resolve<ILoggerFactory>().Create(typeof(CookieManager));
            logger.InfoFormat("Saved Cookie. Domain:{0}, Name:{1}, Value:{2}, Expires:{3}", cookie.Domain, cookie.Name, cookie.Value, cookie.Expires);
        }
Example #3
0
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            if (key != "clearCache" && key != "anonymousAccess")
            {
                string value = sharedPreferences.GetString(key, string.Empty);

                FillSummary(key, value);

                if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
                {
                    ISharedPreferencesEditor editor = sharedPreferences.Edit();
                    editor.PutBoolean("clearCache", true);
                    editor.Commit();

                    MakeToast(D.NEED_TO_REBOOT_FULL);
                }

                if (key == "application")
                    MakeToast(D.NEED_TO_REBOOT);
            }
            else
            {
                MakeToast(D.NEED_TO_REBOOT_FULL);
            }

            BitBrowserApp.Current.SyncSettings();
        }
        public void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
        {
            if (key == "listThemeStyle")
            {
                ListPreference lp = (ListPreference)FindPreference(key);
                String lpVal = lp.Value;
                if (lpVal.Contains("Dark"))
                {
                    prefs.Edit().PutInt("ThemeStyle", Resource.Style.Theme_Sherlock).Commit();
                    ThisApp.StyleTheme = Resource.Style.Theme_Sherlock;
                }
                else if (lpVal.Contains("Light"))
                {
                    prefs.Edit().PutInt("ThemeStyle", Resource.Style.Theme_Sherlock_Light).Commit();
                    ThisApp.StyleTheme = Resource.Style.Theme_Sherlock_Light;
                }

                Finish();
                StartActivity(Intent);
            }
            else if (key == "listFontSize")
            {
                ThisApp.Language = ThisApp.Language;
            }
            else if (key == "dualWebviews")
            {
                CheckBoxPreference cbp = (CheckBoxPreference)FindPreference(key);
                if (cbp.Checked)
                {
                    slp.Enabled = true;
                    slp.Selectable = true;
                    slp.SetEntries(ThisApp.DownloadedLanguages.ToArray());
                    slp.SetEntryValues(ThisApp.DownloadedLanguages.ToArray());
                    if (string.IsNullOrEmpty(slp.Value))
                    {
                        slp.SetValueIndex(ThisApp.DownloadedLanguages.IndexOf(ThisApp.Language));
                    }
                }
                else
                {
                    slp.Enabled = false;
                    slp.Selectable = false;
                }
            }
        }
Example #5
0
    public void StorePreferences(ISharedPreferences spr)
    {
      var prefsEditor = spr.Edit();

      prefsEditor.PutInt("TableOf", TableOf);
      prefsEditor.PutString("strRandomQuestions", RandomQuestions.ToString());
      prefsEditor.PutInt("UpperLimit", UpperLimit);
      prefsEditor.PutInt("CounterMin", CounterMin);
      prefsEditor.PutInt("CounterMax", CounterMax);
      prefsEditor.Commit();
    }
Example #6
0
 public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
 {
     Preference pref = FindPreference (key);
     if (pref.GetType () == typeof(ListPreference)) {
         var listPref = (ListPreference)pref;
         pref.Summary = listPref.Entry;
     } else {
         pref.Summary = sharedPreferences.GetString (key,"");
     }
     var prefEditor = sharedPreferences.Edit ();
     prefEditor.PutString (key,sharedPreferences.GetString (key,""));
     prefEditor.Commit ();
 }
Example #7
0
        protected override void OnCreate(Bundle bundle)
        {
            Delegate.InstallViewFactory();
            Delegate.OnCreate(bundle);
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.settings);
            var toolbar = FindViewById<Toolbar>(Resource.Id.settings_toolbar);
            SetSupportActionBar(toolbar);
            AddPreferencesFromResource(Resource.Xml.settings);
            SupportActionBar.Title = "Impostazioni";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            toolbar.NavigationClick += delegate (object sender, Toolbar.NavigationClickEventArgs e)
            {
                Finish();
            };

            prefs = Application.Context.GetSharedPreferences ("AndroidReport", FileCreationMode.Private);
            prefsEdit = prefs.Edit();

            Preference deleteCache = (Preference)FindPreference("delete_cache");
            deleteCache.PreferenceClick += DeleteCache_PreferenceClick;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                SwitchPreference cacheSwitch = (SwitchPreference)FindPreference("allow_cache");
                cacheSwitch.PreferenceChange += CacheSwitch_PreferenceChange;

                SwitchPreference notificationSwitch = (SwitchPreference)FindPreference("allow_notifications");
                notificationSwitch.PreferenceChange += NotificationSwitch_PreferenceChange;

                SwitchPreference animationSwitch = (SwitchPreference)FindPreference("allow_animations");
                animationSwitch.PreferenceChange += AnimationSwitch_PreferenceChange;
            }
            else
            {
                CheckBoxPreference cacheSwitch = (CheckBoxPreference)FindPreference("allow_cache");
                cacheSwitch.PreferenceChange += CacheSwitch_PreferenceChange;

                CheckBoxPreference notificationSwitch = (CheckBoxPreference)FindPreference("allow_notifications");
                notificationSwitch.PreferenceChange += NotificationSwitch_PreferenceChange;

                CheckBoxPreference animationSwitch = (CheckBoxPreference)FindPreference("allow_animations");
                animationSwitch.PreferenceChange += AnimationSwitch_PreferenceChange;
            }
        }
Example #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);

            // Shared preferences file for storing bearer token for whole app - initialization:
            preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            editor = preferences.Edit();

            mEmailField = base.FindViewById<EditText>(Resource.Id.emailField);
            mPassField = base.FindViewById<EditText>(Resource.Id.passField);
            mLoginButton = base.FindViewById<Button>(Resource.Id.loginButton);
            mRegisterButton = base.FindViewById<Button>(Resource.Id.registerButton);
            mForgottenPwButton = base.FindViewById<Button>(Resource.Id.forgottenPwButton);

            mLoginButton.Click += MLoginButton_Click;
            mRegisterButton.Click += MRegisterButton_Click;
            mForgottenPwButton.Click += MForgottenPwButton_Click;
            
        }
Example #9
0
        // metoda wywo³ania na stworzenie widoku
        protected override void OnCreate(Bundle bundle)
        {
            //przypisanie widoku AXML do klasy
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Shared preferences file for storing bearer token for whole app - initialization:
            preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            editor = preferences.Edit();

            //przypisanie kontrolek widoku do zmiennych
            mMyMessagesButton = base.FindViewById<ImageButton>(Resource.Id.msgImageButton);
            mFriendsMessagesButton = base.FindViewById<ImageButton>(Resource.Id.friendsMsgImageButton);
            mMyFriendsButton = base.FindViewById<ImageButton>(Resource.Id.friendsImageButton);
            mOtherTravelersButton = base.FindViewById<ImageButton>(Resource.Id.travelersImageButton);
            //metody dla zdarzenia klikniêcia na przycisk
            mMyMessagesButton.Click += MMyMessagesButton_Click;
            mFriendsMessagesButton.Click += MFriendsMessagesButton_Click;
            mMyFriendsButton.Click += MMyFriendsButton_Click;
            mOtherTravelersButton.Click += MOtherTravelersButton_Click;
        }
Example #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.welcome);

            prefs = GetPreferences (FileCreationMode.Append);
            firstTime = prefs.GetBoolean (FIRST, true);
            if (firstTime) {
                MakeQuestionDB ();
                MakeScoreDB ();
                editor = prefs.Edit ();
                editor.PutBoolean (FIRST, false);
                editor.Commit ();

            }

            Button button = FindViewById<Button> (Resource.Id.btnStarQuiz);
            button.Click += delegate {
                StartActivity (typeof(QuizActivity));
                Finish ();
            };
        }
Example #11
0
		public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
		{
			// Save instance for later use
			instance = this;

			TestFlight.TakeOff(this, "0596e62a-e3cb-4107-8d05-96fa7ae0c26a");

			// Catch unhandled exceptions
			// Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html
			// Add an exception handler for all uncaught exceptions.
			AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler;
			AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler;

			preferences = Application.Context.GetSharedPreferences("WF.Player.preferences", FileCreationMode.MultiProcess);

			path = preferences.GetString("path", "");

			if (String.IsNullOrEmpty(path))
				path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + Java.IO.File.Separator + "WF.Player";

			try {
				if (!Directory.Exists (path))
					Directory.CreateDirectory (path);
			}
			catch {
			}

			if (!Directory.Exists (path))
			{
				AlertDialog.Builder builder = new AlertDialog.Builder (this);
				builder.SetTitle (GetString (Resource.String.main_error));
				builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path));
				builder.SetCancelable (true);
				builder.SetNeutralButton(Resource.String.ok,(obj,arg) => { });
				builder.Show ();
			} else {
				preferences.Edit().PutString("path", path).Commit();
			}
		}
Example #12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            userID = Intent.GetStringExtra ("id") ?? "-1";
            mainPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private);
            mainEditor = mainPrefs.Edit ();
            serviceNumer = mainPrefs.GetInt ("service_size", -1);
            SetContentView (Resource.Layout.Main);

            tabHost = FindViewById<TabHost> (Android.Resource.Id.TabHost);
            tabHost.Setup ();

            for (int i = 1; i <= 2; i++) {

                TabHost.TabSpec tabSpec;
                tabSpec = tabHost.NewTabSpec("Tab " + i);
                tabSpec.SetIndicator("Tab " + i);
                tabSpec.SetContent(new FakeContent(this));
                tabHost.AddTab(tabSpec);
            }
            tabHost.SetOnTabChangedListener(this);
            viewPager = FindViewById<ViewPager> (Resource.Id.view);
            var adaptor = new ServiceBeaconAdapter (SupportFragmentManager);
            adaptor.addFragmentView ((i, v, b) => {
                var view = i.Inflate (Resource.Layout.Page, v, false);
                var myText = view.FindViewById<TextView> (Resource.Id.textView1);
                myText.Text = myText.Text + "1";
                return view;
            });
            adaptor.addFragmentView((i,v,b) =>
            {
                var view = i.Inflate(Resource.Layout.Page,v,false);
                var myText = view.FindViewById<TextView> (Resource.Id.textView1);
                myText.Text = myText.Text + "2";
                return view;
                });
            viewPager.Adapter = adaptor;//new ServiceBeaconAdapter (SupportFragmentManager);
            viewPager.SetOnPageChangeListener(this);

            beaconStatusLabel = FindViewById<TextView> (Resource.Id.beaconStatusLabel);

            beaconMgr.Bind (this);

            //myProcessedBeacons = new JavaDictionary<string,string>();
            monitorNotifier.EnterRegionComplete += EnteredRegion;
            monitorNotifier.ExitRegionComplete += ExitedRegion;

            rangeNotifier.DidRangeBeaconsInRegionComplete += HandleBeaconsInRegion;
        }
Example #13
0
        public SettingsManager()
        {
            appPrefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);

            prefsEditor = appPrefs.Edit();
        }
Example #14
0
        public FormTime(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource                = context.Resources;
            contextx                = context;
            OwnerID                 = ownerID;
            VerifierID              = verifiedID;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            Popup                   = new InformationPopup(context);
            reportStatus            = Reportstatus;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            timeFrame = new RelativeLayout(context);

            RelativeLayout.LayoutParams parms2 = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            timeFrame.LayoutParameters = parms2;

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            RelativeLayout.LayoutParams paramsOfTimeDisplay = new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WrapContent);
            paramsOfTimeDisplay.AddRule(LayoutRules.CenterVertical);
            paramsOfTimeDisplay.AddRule(LayoutRules.AlignParentLeft);

            timeDisplay    = new EditText(context);
            timeDisplay.Id = element.Id;
            timeDisplay.SetTextColor(Color.Black);
            timeDisplay.LayoutParameters = paramsOfTimeDisplay;
            timeDisplay.Focusable        = false;
            timeDisplay.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);
            timeDisplay.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;

            RelativeLayout.LayoutParams paramsOfClearButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsOfClearButton.AddRule(LayoutRules.RightOf, timeDisplay.Id);

            timeDisplay.Touch += (s, e) =>
            {
                var handled = false;
                if (e.Event.Action == MotionEventActions.Down)
                {
                    createTimeDialog(context);
                    handled = true;
                }
                else if (e.Event.Action == MotionEventActions.Up)
                {
                    handled = true;
                }
                e.Handled = handled;
            };

            clearTimeButton          = new Button(context);
            clearTimeButton.Text     = "Clear";
            clearTimeButton.TextSize = 12;
            clearTimeButton.SetTextColor(Resources.GetColor(Resource.Color.theme_color));
            clearTimeButton.SetBackgroundResource(0);
            clearTimeButton.LayoutParameters = paramsOfClearButton;
            clearTimeButton.Click           += delegate { clearTime(); };

            hour   = DateTime.Now.Hour;
            minute = DateTime.Now.Minute;

            if (string.IsNullOrEmpty(element.Value))
            {
                timeDisplay.Text = "";
                indicatorImage.SetImageResource(0);
                clearTimeButton.Visibility = ViewStates.Gone;
            }
            else
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                timeDisplay.Text = element.Value;
            }

            timeDisplay.TextChanged += (sender, e) =>
            {
                if (!timeDisplay.Text.Equals(""))
                {
                    indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    clearTimeButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    indicatorImage.SetImageResource(0);
                    clearTimeButton.Visibility = ViewStates.Gone;
                }

                sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                sharedPreferencesEditor.Commit();
            };

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    clearTimeButton.Enabled    = false;
                    clearTimeButton.Visibility = ViewStates.Gone;
                    timeDisplay.Enabled        = false;
                    timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        clearTimeButton.Enabled    = true;
                        clearTimeButton.Visibility = ViewStates.Gone;
                        timeDisplay.Enabled        = true;
                        timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                    }
                }

                else
                {
                    clearTimeButton.Enabled    = true;
                    clearTimeButton.Visibility = ViewStates.Gone;
                    timeDisplay.Enabled        = true;
                    timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                }
            }
            else
            {
                clearTimeButton.Enabled    = false;
                clearTimeButton.Visibility = ViewStates.Gone;
                timeDisplay.Enabled        = false;
                timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }


            if (isArcheived)
            {
                timeDisplay.Enabled        = false;
                clearTimeButton.Visibility = ViewStates.Gone;
                timeDisplay.Enabled        = false;
                timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            timeFrame.AddView(timeDisplay);
            timeFrame.AddView(clearTimeButton);
            AddView(theme);
            AddView(timeFrame);
            SetPadding(45, 10, 45, 20);
        }
Example #15
0
 public AppPreferences(Context context)
 {
     this.mContext = context;
     mSharedPrefs  = PreferenceManager.GetDefaultSharedPreferences(mContext);
     mPrefsEditor  = mSharedPrefs.Edit();
 }
Example #16
0
		public override void OnScrolled (RecyclerView recyclerView, int dx, int dy)
		{
			pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
			LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager ();
			int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition();
			int totalItemCount = recyclerView.GetAdapter().ItemCount;

			if (!IsLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
				// End has been reached
				// Do something
				var currPrefPage = pref.GetString ("CurrentPage", string.Empty);
				if (!String.IsNullOrEmpty (currPrefPage)) {
					if (Int32.Parse (currPrefPage) > 0) {
						currentPage++;
					} else {
						currentPage = 2;
					}
				} else {
					currentPage++;

				}
				var editor = pref.Edit();
				editor.PutString("CurrentPage",currentPage.ToString());
				editor.Apply();

				IsLoading = true;
				Task.Factory.StartNew (async () => {
					
					try{
						var newPostList = new List<Post>();
						await WebClient.LoadPosts(newPostList,currentPage);


						(recyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList);
						//recyclerView.GetAdapter().HasStableIds = true;

						_messageShown = false;
						Application.SynchronizationContext.Post (_ => {recyclerView.GetAdapter().NotifyDataSetChanged();}, null);
						//recyclerView.GetAdapter().NotifyItemRangeInserted(recyclerView.GetAdapter().ItemCount,newPostList.Count);
					}catch(Exception ex){
						//Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error);
						var text = ex.Message;
						if(!_messageShown){
							Application.SynchronizationContext.Post (_ => {
								Toast.MakeText(Application.Context,"При загрузке данных произошла ошибка",ToastLength.Short).Show();
							}, null);
							_messageShown = true;
						}

					}


					IsLoading = false;
				});

			}
		}
        public SettingsService()
        {
			_sharedPreferences = Application.Context.GetSharedPreferences(AppConstants.AppName, FileCreationMode.Private);
            _sharedPreferencesEditor = _sharedPreferences.Edit();
        }
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(Resource.Style.Preferences);
            base.OnCreate(bundle);
            AgentApplication.getInstance().addActivity(this);
            AddPreferencesFromResource(Resource.Layout.InitialPreferenceScreen);
            settings = PreferenceManager.GetDefaultSharedPreferences(this);
            SetupToast();
            ISharedPreferencesEditor editor = settings.Edit();
            editor.PutString("pref_phoneNumber", GetPhoneNumber());
            EditTextPreference editPhoneNumberPref = (EditTextPreference)PreferenceManager.FindPreference("pref_phoneNumber");
            EditTextPreference editPhoneNamePref = (EditTextPreference)PreferenceManager.FindPreference("pref_phoneName");
            editPhoneNumberPref.Summary = GetPhoneNumber();
            editPhoneNamePref.Summary = "";
            editPhoneNumberPref.PreferenceChange += editPhoneNumberPref_PreferenceChange;
            editPhoneNamePref.PreferenceChange += editPhoneNamePref_PreferenceChange;
            // This gets the phone name, however, in android, phone names aren't clean like in iOS.
            //editor.PutString("pref_phoneName", Android.OS.Build.User);
            editor.Commit();
            if (Build.VERSION.SdkInt < BuildVersionCodes.Base11)
            {
                //RequestWindowFeature(WindowFeatures.ActionBar);
            }

            var setupDropbox = (CheckBoxPreference)PreferenceManager.FindPreference("pref_dropboxOn");
            setupDropbox.PreferenceClick += setupDropbox_PreferenceClick;

            var cancelButton = (PreferenceScreen)PreferenceManager.FindPreference("pref_cancel");
            cancelButton.PreferenceClick += cancelButton_PreferenceClick;
        }
Example #19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TripStats);

            pref     = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
            prefEdit = pref.Edit();

            selectTripName = pref.GetString("selectTripName", null);

            imagesFolderPath = pref.GetString("imagesFolderPath", null);
            imagesFilePath   = System.IO.Path.Combine(imagesFolderPath.ToString(), String.Format("{0}.Jpeg", selectTripName));
            Bitmap mapBitmap = BitmapFactory.DecodeFile(imagesFilePath);

            TextView  tripStart     = FindViewById <TextView>(Resource.Id.tripStats_TripStart);
            TextView  tripFinish    = FindViewById <TextView>(Resource.Id.tripStats_TripFinish);
            TextView  tripName      = FindViewById <TextView>(Resource.Id.tripStats_TripName);
            TextView  tripDuration  = FindViewById <TextView>(Resource.Id.tripStats_TripDuration);
            TextView  tripDistance  = FindViewById <TextView>(Resource.Id.tripStats_TripDistance);
            TextView  numberOfStops = FindViewById <TextView>(Resource.Id.tripStats_NumberOfStops);
            TextView  stopDuration  = FindViewById <TextView>(Resource.Id.tripStats_StopDuration);
            TextView  avgSpeed      = FindViewById <TextView>(Resource.Id.tripStats_AvgSpeed);
            ImageView mapImage      = FindViewById <ImageView>(Resource.Id.tripStats_ImageView1);

            var dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Trips.db");

            connection = new SQLiteConnection(dbPath);

            var table = connection.Table <Trip>();

            List <Trip> list = new List <Trip>();

            list = connection.Query <Trip>("SELECT * from Trip Where _TripName=?", selectTripName);

            string avgSpeedString      = list[0].AVGSpeed.ToString();
            string tripStartString     = list[0].TripStart.ToString();
            string tripFinishString    = list[0].TripFinish.ToString();
            string tripDurationString  = list[0].TripDuration.ToString();
            string tripDistanceString  = list[0].Distance.ToString("N1");
            string numberOfStopsString = list[0].StopsCount.ToString();
            string stopDurationString  = list[0].StopsDuration.ToString();
            string milesOrKilometers   = list[0].MilesOrKms.ToString();

            if (milesOrKilometers == "Kilometers")
            {
                distanceType = "Kms";
                speedType    = "Km/h";
            }

            else if (milesOrKilometers == "Miles")
            {
                distanceType = "Miles";
                speedType    = "Mi/h";
            }


            tripName.Text       = selectTripName;
            tripName.PaintFlags = PaintFlags.UnderlineText;
            tripName.Typeface   = Typeface.DefaultBold;
            tripStart.Text      = "Trip Start:  " + tripStartString;
            tripFinish.Text     = "Trip Finish:  " + tripFinishString;
            tripDuration.Text   = "Trip Duration(d:h:m:s):  " + tripDurationString;
            tripDistance.Text   = "Trip Distance:  " + tripDistanceString + " " + distanceType;
            numberOfStops.Text  = "Number of Stops:  " + numberOfStopsString;
            stopDuration.Text   = "Minutes Stopped:  " + stopDurationString;
            avgSpeed.Text       = "Average Speed:  " + avgSpeedString + " " + speedType;
            mapImage.SetImageBitmap(mapBitmap);
        }//OnCreate()
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                FacebookSdk.SdkInitialize(this.ApplicationContext);
                SetContentView(Resource.Layout.Login);
                txtUserName       = FindViewById <EditText>(Resource.Id.etEmailPhone);
                txtPassword       = FindViewById <EditText>(Resource.Id.etPassword);
                txtForgotUsername = FindViewById <EditText>(Resource.Id.etForgotUsername);

                btnLogIn = FindViewById <Button>(Resource.Id.btnLogin);
                GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
                builder.AddConnectionCallbacks(this);
                builder.AddOnConnectionFailedListener(this);
                builder.AddApi(PlusClass.API);
                builder.AddScope(new Scope(Scopes.PlusLogin));
                mGoogleApiClient = builder.Build();
                mGoogleApiClient.Connect();

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                    Window.SetStatusBarColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.primaryDark)));
                }

                ISharedPreferences prefs = Application.Context.GetSharedPreferences("WeClip", FileCreationMode.Private);

                var FromUserScreen = Intent.GetStringExtra("FromUserName");

                if (!string.IsNullOrEmpty(FromUserScreen))
                {
                    var prefEditor = prefs.Edit();
                    prefEditor.PutBoolean("RegisterEmail", false);
                    prefEditor.PutBoolean("RegisterPhone", false);
                    prefEditor.Commit();
                }

                bool RegisterEmail = prefs.GetBoolean("RegisterEmail", false);
                bool RegisterPhone = prefs.GetBoolean("RegisterPhone", false);

                llayoutSignIn         = FindViewById <LinearLayout>(Resource.Id.llayoutSignIn);
                llayoutSignUpOptions  = FindViewById <LinearLayout>(Resource.Id.llayoutSignUpOptions);
                llayoutForgotPassword = FindViewById <LinearLayout>(Resource.Id.llayoutForgot);


                btnSignUpWsocial        = FindViewById <TextView>(Resource.Id.btnSignUpWsocial);
                btnSignUpWsocial.Click += BtnSignUpWsocial_Click;

                btnSignInView        = FindViewById <TextView>(Resource.Id.btnSignInView);
                btnSignInView.Click += BtnSignInView_Click;

                btnForgotPassword        = FindViewById <TextView>(Resource.Id.btnForgotPassword);
                btnForgotPassword.Click += BtnForgotPassword_Click;

                btnsignInInForgotPassword        = FindViewById <TextView>(Resource.Id.tvSigninInForgotPassword);
                btnsignInInForgotPassword.Click += BtnSigninForgotPassword_Click;


                btnSignupWithEmail     = FindViewById <Button>(Resource.Id.btnSignUpWithEmail);
                btnSignupWithPhone     = FindViewById <Button>(Resource.Id.btnSignUpWithPhone);
                btnSignupWithGoogle    = FindViewById <Button>(Resource.Id.btnGPlus);
                btnSignUpWithFacebook  = FindViewById <Button>(Resource.Id.btnFacebook);
                btnSumitForgotPassword = FindViewById <Button>(Resource.Id.btnSubmitForgotPassword);
                mcallBackManager       = CallbackManagerFactory.Create();

                btnSignupWithPhone.Visibility = ViewStates.Gone;

                LoginManager.Instance.RegisterCallback(mcallBackManager, this);

                btnSignupWithEmail.Click     += btnSignupWithEmail_Click;
                btnSignupWithPhone.Click     += BtnSignupWithPhone_Click;
                btnSignupWithGoogle.Click    += BtnSignupWithGoogle_Click;
                btnSignUpWithFacebook.Click  += BtnSignUpWithFacebook_Click;
                btnSumitForgotPassword.Click += BtnSumitForgotPassword_Click;
                btnLogIn.Click += BtnLogIn_Click;

                if (RegisterEmail == true)
                {
                    SignUpView();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                new CrashReportAsync("LoginActivity", "OnCreate", ex.Message + ex.StackTrace).Execute();
            }
        }
        public static void Set(string key, string value)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            prefs.Edit().PutString(key, value).Commit();
        }
Example #22
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //InitializeLocationManager();

            connectivityManager = (ConnectivityManager)GetSystemService(Context.ConnectivityService);
            NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo;

            isOnline = (activeConnection != null) && activeConnection.IsConnected;

            Log.Debug("DEBUG", "The value of isOnline is: {0}", isOnline);

            NetConnectionChangeReceiver.activity = this;

            /*NetworkInfo wifiInfo = connectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
             * if (wifiInfo.IsConnected)
             * {
             *      Log.Debug("DEBUG", "Wifi connected.");
             *
             * }
             * else
             * {
             *      Log.Debug("DEBUG", "Wifi disconnected.");
             *
             * }
             *
             * NetworkInfo mobileInfo = connectivityManager.GetNetworkInfo(ConnectivityType.Mobile);
             * if (mobileInfo.IsRoaming && mobileInfo.IsConnected)
             * {
             *      Log.Debug("DEBUG", "Roaming.");
             *
             * }
             * else
             * {
             *      Log.Debug("DEBUG", "Not roaming.");
             *
             * }*/

            CheckInternetConnection();

            preferences = PreferenceManager.GetDefaultSharedPreferences(this);
            editor      = preferences.Edit();

            CheckIfFirstTime();

            restaurantSearchButton       = FindViewById <Button>(Resource.Id.button1);
            advancedSearchButton         = FindViewById <Button>(Resource.Id.button2);
            hideButton                   = FindViewById <Button>(Resource.Id.buttonHide);
            cityEditText                 = FindViewById <EditText>(Resource.Id.editText2);
            restaurantTypeEditText       = FindViewById <EditText>(Resource.Id.editText1);
            invisibleButton              = FindViewById <Button>(Resource.Id.invisibleButton);
            noInternetConnectionTextView = FindViewById <TextView>(Resource.Id.noInternetConnectionTextView);
            weatherIcon                  = FindViewById <ImageView>(Resource.Id.weatherImageView);
            temperatureTextView          = FindViewById <TextView>(Resource.Id.temperatureTextView);
            conditionTextView            = FindViewById <TextView>(Resource.Id.conditionTextView);
            humidityTextView             = FindViewById <TextView>(Resource.Id.humidityTextView);
            dateTextView                 = FindViewById <TextView>(Resource.Id.dateTextView);
            loadingImageView             = FindViewById <ImageView>(Resource.Id.ImageViewLoading);
            weatherInfoLayout            = FindViewById <LinearLayout>(Resource.Id.linearLayoutWeather);
            toolBarTitle                 = FindViewById <TextView>(Resource.Id.toolbar_title);

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

            SetSupportActionBar(toolBar);
            SupportActionBar.SetDisplayShowTitleEnabled(false);
            toolBarTitle.Text = "Restaurant Finder";

            loadingImageView.Visibility  = ViewStates.Visible;
            weatherInfoLayout.Visibility = ViewStates.Gone;

            noInternetConnectionTextView.Visibility = ViewStates.Gone;

            cityEditText.Visibility = ViewStates.Invisible;
            isNear = true;

            hideButton.Visibility = ViewStates.Gone;

            restaurantTypeEditText.SetCursorVisible(false);

            restaurantSearchButton.Click += RestaurantSearchButtonClicked;

            advancedSearchButton.Click += AdvancedButtonClicked;

            hideButton.Click += HideButtonClicked;

            invisibleButton.Click += InvisibleButtonClicked;

            cityEditText.KeyPress += (object sender, View.KeyEventArgs e) =>
            {
                if ((e.Event.Action == KeyEventActions.Down) && (e.KeyCode == Keycode.Enter))
                {
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.HideSoftInputFromWindow(cityEditText.WindowToken, 0);
                    Console.WriteLine("Enter key pressed");
                }
            };

            //await InitializeWeatherData();
        }
Example #23
0
        public FormGPS(Context context, ReportElement element, int ownerID, int userID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource    = context.Resources;
            contextx    = context;
            OwnerID     = userID;
            VerifierID  = verifiedID;
            theme       = new FormTheme(context, element.Title);
            Orientation = Orientation.Vertical;
            RelativeLayout gpsHolder = new RelativeLayout(contextx);

            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            List <KeyValue> existingValue = element.Values;

            Popup        = new InformationPopup(context);
            reportStatus = Reportstatus;

            editText = new EditText(context);
            Id       = element.Id;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            if (existingValue != null)
            {
                foreach (var address in existingValue)
                {
                    if (address.Name == "address")
                    {
                        editText.Text = address.Value;
                        curaddress    = address.Value;
                    }

                    if (address.Name == "longitude")
                    {
                        longtitude = address.Value;
                    }

                    if (address.Name == "latitude")
                    {
                        latitude = address.Value;
                    }
                }
            }

            editText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);

            RelativeLayout.LayoutParams paramsForGPSHolder = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent);
            gpsHolder.LayoutParameters = paramsForGPSHolder;

            ImageButton locationBtn = new ImageButton(context);

            locationBtn.Id = 891;
            locationBtn.SetBackgroundResource(0);
            locationBtn.SetImageResource(Resource.Drawable.android_form_gps_icon);
            locationBtn.Click += (senderGPS, e) => AddressButton_OnClick(editText, this);

            RelativeLayout.LayoutParams paramsForlocationBtn = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForlocationBtn.AddRule(LayoutRules.AlignParentTop);
            paramsForlocationBtn.AddRule(LayoutRules.AlignParentEnd);
            locationBtn.LayoutParameters = paramsForlocationBtn;

            RelativeLayout.LayoutParams paramsForEditText = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForEditText.AddRule(LayoutRules.AlignParentTop);
            paramsForEditText.AddRule(LayoutRules.AlignParentStart);
            paramsForEditText.AddRule(LayoutRules.StartOf, locationBtn.Id);
            editText.LayoutParameters = paramsForEditText;
            //editText.Gravity = GravityFlags.CenterVertical;

            gpsHolder.AddView(editText);
            gpsHolder.AddView(locationBtn);

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);
            editText.TextChanged += (sender, e) =>
            {
                if (!editText.Text.Equals(""))
                {
                    indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    curaddress = editText.Text;
                }
                else
                {
                    indicatorImage.SetImageResource(0);
                }
            };

            //when opening a Draft or Archive
            if (!editText.Text.Equals(""))
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }


            if (string.IsNullOrEmpty(element.FilledBy))
            {
                //do nothing
            }
            else if (element.FilledBy == userID + "")
            {
                //do nothing
            }
            else
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            TextView elementSplitLine = new TextView(context);

            elementSplitLine.TextSize = 0.5f;
            elementSplitLine.SetBackgroundColor(Color.ParseColor(resource.GetString(Resource.Color.grey)));


            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    editText.Enabled = false;
                    editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                    locationBtn.Enabled = false;
                    locationBtn.Click  += null;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        editText.Enabled = true;
                        editText.SetTextColor(Resources.GetColor(Resource.Color.black));
                        locationBtn.Enabled = true;
                    }
                }

                else
                {
                    editText.Enabled = true;
                    editText.SetTextColor(Resources.GetColor(Resource.Color.black));
                    locationBtn.Enabled = true;
                }
            }
            else
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                locationBtn.Enabled = false;
                locationBtn.Click  += null;
            }

            if (isArcheived)
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                locationBtn.Enabled = false;
                locationBtn.Click  += null;
            }


            AddView(theme);
            AddView(gpsHolder);
            SetPadding(45, 10, 45, 20);
        }
Example #24
0
        public void OnClick(View v)
        {
            if (v.Id == Resource.Id.nextbutton)
            {
                year       = FindViewById <EditText>(Resource.Id.year);
                month      = FindViewById <EditText>(Resource.Id.month);
                day        = FindViewById <EditText>(Resource.Id.day);
                birthdata += year.Text + month.Text + day.Text;

                if (city.Length == 0 || birthdata.Length == 0)
                {
                    Toast.MakeText(this, "请确保信息全部填写!", ToastLength.Long).Show();
                }
                else
                {
                    ISharedPreferences mySharedPreferences = GetSharedPreferences("information", FileCreationMode.Private);
                    //实例化SharedPreferences.Editor对象(第二步)   
                    ISharedPreferencesEditor editor = mySharedPreferences.Edit();
                    //用putString的方法保存数据   
                    editor.PutString("sex", sex);
                    editor.PutString("birth", birthdata);
                    editor.PutString("city", city);
                    //提交当前数据   
                    editor.Commit();
                    SetContentView(Resource.Layout.Donteat);
                    Button finishbutton = FindViewById <Button>(Resource.Id.finishbutton);
                    finishbutton.SetOnClickListener(this);
                }
            }
            else if (v.Id == Resource.Id.finishbutton)
            {
                meattext = FindViewById <EditText>(Resource.Id.textmeat);
                vegtext  = FindViewById <EditText>(Resource.Id.textveg);
                seatext  = FindViewById <EditText>(Resource.Id.textsea);

                if (!(meattext.Length() == 0 || vegtext.Length() == 0 || seatext.Length() == 0))
                {
                    ISharedPreferences
                        mySharedPreferences = GetSharedPreferences("information", FileCreationMode.Append);
                    //实例化SharedPreferences.Editor对象(第二步)   
                    ISharedPreferencesEditor editor = mySharedPreferences.Edit();
                    //用putString的方法保存数据   
                    if (!(meattext.Length() == 0))
                    {
                        editor.PutString("meat", meattext.Text.ToString());
                    }
                    if (!(vegtext.Length() == 0))
                    {
                        editor.PutString("veg", vegtext.Text.ToString());
                    }
                    if (!(seatext.Length() == 0))
                    {
                        editor.PutString("sea", seatext.Text.ToString());
                    }
                    //提交当前数据   
                    editor.Commit();
                }
                Intent intent = new Intent(this, typeof(EndActivity));
                StartActivity(intent);
                Finish();
            }
        }
 protected override void OnCreate(Bundle bundle)
 {
     RequestWindowFeature (WindowFeatures.NoTitle);
     base.OnCreate (bundle);
     SetContentView (Resource.Layout.CheckInPassive);
     mGeoIntentUp = (PendingIntent.GetService (this, 0,
         new Intent (this, Java.Lang.Class.FromType(typeof(GeofenceTransitionsIntentService))),
         PendingIntentFlags.NoCreate) != null);
     if (mGeoIntentUp) {
         geofenceRequestIntent = PendingIntent.GetService (this, 0,
             new Intent (this, Java.Lang.Class.FromType (typeof(GeofenceTransitionsIntentService))),
             PendingIntentFlags.UpdateCurrent);
         FindViewById<Button>(Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
         FindViewById<TextView> (Resource.Id.lblConfirm).SetText ("A record that you have checked-in will be made in the log of your education activity for this ROMP rotation when this device enters a 1km radius surrounding the facility of your ROMP rotation.", TextView.BufferType.Normal);
     } else {
         geofenceList = new List<IGeofence> ();
         geofenceRequestIntent = null;
         string sessionKey = Intent.GetStringExtra ("SessionKey");
         int groupID = Intent.GetIntExtra ("GroupID", 0);
         int userID = Intent.GetIntExtra ("UserID", 0);
         if (sessionKey != "") {
             mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private);
             ISharedPreferencesEditor editor = mSharedPreferences.Edit ();
             editor.PutString ("SessionKey", sessionKey);
             editor.Commit ();
         }
         var locSvc = new ROMPLocation ();
         FindViewById<Button> (Resource.Id.btnCloseP).Click += btnCloseP_OnClick;
         myFacilities = locSvc.GetLocations (sessionKey, groupID);
         if (myFacilities.Count () > 0) {
             connectedGeofences = new List<ROMPGeofence> ();
             CreateGeofences ();
             FindViewById<Button> (Resource.Id.btnBegin).Click += BeginGeofencing;
             BuildGoogleApiClient ();
         } else {
             FindViewById<Button> (Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
             FindViewById<TextView> (Resource.Id.lblConfirm).Text = "You have no locations to check in to. Please start the application during a rotation to properly utilize the functionality. Thank you.";
         }
     }
 }
Example #26
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view   = inflater.Inflate(Resource.Layout.fragment_tsumikomi_select, container, false);
            prefs  = PreferenceManager.GetDefaultSharedPreferences(Context);
            editor = prefs.Edit();

            // TITLE SETTING
            SetTitle("積込検品");

            // PARAMETER SETTING
            souko_cd   = prefs.GetString("souko_cd", "");
            kitaku_cd  = prefs.GetString("kitaku_cd", "");
            syuka_date = prefs.GetString("syuka_date", "");
            nohin_date = prefs.GetString("nohin_date", "");
            course     = prefs.GetString("course", "");
            bin_no     = prefs.GetString("bin_no", "");
            kansen_kbn = prefs.GetString("kansen_kbn", "");

            // ITEM EVENT SETTING
            etSyukaDate              = view.FindViewById <BootstrapEditText>(Resource.Id.et_tsumikomiSelect_syukaDate);
            etSyukaDate.FocusChange += (sender, e) => {
                if (e.HasFocus)
                {
                    etSyukaDate.Text = etSyukaDate.Text.Replace("/", "");
                    etSyukaDate.SetSelection(etSyukaDate.Text.Length);
                }
                else
                {
                    if (etSyukaDate.Text != "")
                    {
                        try
                        {
                            etSyukaDate.Text = CommonUtils.GetDateYYYYMMDDwithSlash(etSyukaDate.Text);
                        }
                        catch
                        {
                            ShowDialog("エラー", "正しい日付を入力してください。", () => {
                                etSyukaDate.Text = "";
                                etSyukaDate.RequestFocus();
                            });
                        }
                    }
                }
            };

            etCourse           = view.FindViewById <BootstrapEditText>(Resource.Id.et_tsumikomiSelect_course);
            etCourse.KeyPress += (sender, e) => {
                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    e.Handled = true;
                    CommonUtils.HideKeyboard(Activity);
                    Confirm();
                }
                else
                {
                    e.Handled = false;
                }
            };

            btnConfirm        = view.FindViewById <BootstrapButton>(Resource.Id.btn_tsumikomiSelect_confirm);
            btnConfirm.Click += delegate { Confirm(); };

            // FIRST FOCUS
            etCourse.RequestFocus();

            // DUMMY DATA
            //etSyukaDate.Text = "18/03/20";
            etSyukaDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
            return(view);
        }
Example #27
0
        public FormIntEditText(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource     = context.Resources;
            contextx     = context;
            OwnerID      = ownerID;
            VerifierID   = verifiedID;
            theme        = new FormTheme(context, element.Title);
            Popup        = new InformationPopup(context);
            reportStatus = Reportstatus;

            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            SetPadding(45, 10, 45, 20);

            EditText intEditText = new EditText(context);

            intEditText.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.TextFlagNoSuggestions;
            intEditText.Id        = element.Id;
            intEditText.Text      = element.Value;
            intEditText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);

            ImageView indicatorImageView = (ImageView)theme.GetChildAt(1);

            indicatorImageView.SetImageResource(0);
            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            intEditText.TextChanged += (sender, e) =>
            {
                if (!intEditText.Text.Equals(""))
                {
                    indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                }
                else
                {
                    indicatorImageView.SetImageResource(0);
                }
                sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                sharedPreferencesEditor.Commit();
            };

            //when opening a Draft or Archive
            if (!intEditText.Text.Equals(""))
            {
                indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    intEditText.Enabled = false;
                    intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey));

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        intEditText.Enabled = true;
                        intEditText.SetTextColor(Resources.GetColor(Resource.Color.black));
                    }
                }

                else
                {
                    intEditText.Enabled = true;
                    intEditText.SetTextColor(Resources.GetColor(Resource.Color.black));
                }
            }
            else
            {
                intEditText.Enabled = false;
                intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            if (isArcheived)
            {
                intEditText.Enabled = false;
                intEditText.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            AddView(theme);
            AddView(intEditText);
        }
Example #28
0
        public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate, string searchUrl)
        {
            var hadKeyboardData = ClearNotifications();

            String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField);

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            var notBuilder           = new PasswordAccessNotificationBuilder(this, _notificationManager);

            if (prefs.GetBoolean(GetString(Resource.String.CopyToClipboardNotification_key), Resources.GetBoolean(Resource.Boolean.CopyToClipboardNotification_default)))
            {
                if (entry.OutputStrings.ReadSafe(PwDefs.PasswordField).Length > 0)
                {
                    notBuilder.AddPasswordAccess();
                }

                if (entry.OutputStrings.ReadSafe(PwDefs.UserNameField).Length > 0)
                {
                    notBuilder.AddUsernameAccess();
                }
            }

            bool hasKeyboardDataNow = false;

            if (prefs.GetBoolean(GetString(Resource.String.UseKp2aKeyboard_key), Resources.GetBoolean(Resource.Boolean.UseKp2aKeyboard_default)))
            {
                //keyboard
                hasKeyboardDataNow = MakeAccessibleForKeyboard(entry, searchUrl);
                if (hasKeyboardDataNow)
                {
                    notBuilder.AddKeyboardAccess();

                    if (closeAfterCreate && Keepass2android.Autofill.AutoFillService.IsAvailable)
                    {
                        if (IsKp2aInputMethodEnabled)
                        {
                            ActivateKeyboardIfAppropriate(closeAfterCreate, prefs);
                        }
                        else if (Keepass2android.Autofill.AutoFillService.IsRunning)
                        {
                            //don't do anything, service is notified
                        }
                        else                         //neither keyboard nor activity service are running/enabled. Ask the user what to do.
                        {
                            var i = new Intent(this, typeof(ActivateAutoFillActivity));
                            i.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                            StartActivity(i);
                            prefs.Edit().PutBoolean("has_asked_autofillservice", true).Commit();
                        }
                    }
                    else
                    {
                        ActivateKeyboardIfAppropriate(closeAfterCreate, prefs);
                    }
                }
            }

            if ((!hasKeyboardDataNow) && (hadKeyboardData))
            {
                ClearKeyboard(true);                 //this clears again and then (this is the point) broadcasts that we no longer have keyboard data
            }
            _numElementsToWaitFor = notBuilder.CreateNotifications(entryName);

            if (_numElementsToWaitFor == 0)
            {
                StopSelf();
                return;
            }

            IntentFilter filter = new IntentFilter();

            filter.AddAction(Intents.CopyUsername);
            filter.AddAction(Intents.CopyPassword);
            filter.AddAction(Intents.CheckKeyboard);

            //register receiver to get notified when notifications are discarded in which case we can shutdown the service
            _notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this);
            IntentFilter deletefilter = new IntentFilter();

            deletefilter.AddAction(ActionNotificationCancelled);
            RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter);
        }
 /// <summary>
 /// 删除一个本地存储以及他的全部数据。如果该存储不存在,返回false;否则返回true。
 /// </summary>
 /// <param name="key">本地存储名称</param>
 public void remove(string key)
 {
     _sharedPreferences?.Edit().Remove(key).Apply();
 }
Example #30
0
        private async void Btn_ok_Click(object sender, EventArgs e)
        {
            var intent = new Intent(this, typeof(MainActivity));

            serv_data = new Currencies();
            this.StartActivity(intent);

            var list = new List <ListForSharedPref>();
            ListForSharedPref o;

            for (var i = 0; i < listNames.Count; i++)
            {
                o = new ListForSharedPref()
                {
                    Name        = listNames[i],
                    Value       = listValues[i],
                    OverOrUnder = switches[i].Checked
                };
                list.Add(o);
                listOver[i] = switches[i].Checked;
            }

            if (listNames.Count >= 1)
            {
                serv_data.FirstCurrency      = listNames[0];
                serv_data.FirstCurrencyValue = listValues[0];
                serv_data.FirstCurrencyOver  = listOver[0];
            }
            if (listNames.Count >= 2)
            {
                serv_data.SecondCurrency      = listNames[1];
                serv_data.SecondCurrencyValue = listValues[1];
                serv_data.SecondCurrencyOver  = listOver[1];
            }
            if (listNames.Count >= 3)
            {
                serv_data.ThirdCurrency      = listNames[2];
                serv_data.ThirdCurrencyValue = listValues[2];
                serv_data.ThirdCurrencyOver  = listOver[2];
            }
            if (listNames.Count >= 4)
            {
                serv_data.FourthCurrency      = listNames[3];
                serv_data.FourthCurrencyValue = listValues[3];
                serv_data.FourthCurrencyOver  = listOver[3];
            }
            if (listNames.Count >= 5)
            {
                serv_data.FifthCurrency      = listNames[4];
                serv_data.FifthCurrencyValue = listValues[4];
                serv_data.FifthCurrencyOver  = listOver[4];
            }

            ChangeObjectIfValuesChanges(); //zmiana wartosci jesli sie textboxy zmieniaja

            ISharedPreferences       pref = Application.Context.GetSharedPreferences("ListPref", FileCreationMode.Private);
            ISharedPreferencesEditor edit = pref.Edit();
            //edit.Clear();

            var temp_ID = (RegiID._id == null) ?
                          pref.GetString("regiID", string.Empty) :
                          RegiID._id;

            edit.PutString("regiID", temp_ID);
            serv_data.UserID = temp_ID;

            var tags = new List <string>
            {
                serv_data.FirstCurrencyValue,
                serv_data.SecondCurrencyValue,
                serv_data.ThirdCurrencyValue,
                serv_data.FourthCurrencyValue,
                serv_data.FifthCurrencyValue
            };

            string jsonListValues = JsonConvert.SerializeObject(listValues);

            edit.PutString("listValues", jsonListValues);
            string jsonTags = JsonConvert.SerializeObject(tags);

            edit.PutString("tagsList", jsonTags);
            string jsonListOver = JsonConvert.SerializeObject(listOver);

            edit.PutString("listOver", jsonListOver);
            var listUserValues = new List <string>()
            {
                tb1.Text, tb2.Text, tb3.Text, tb4.Text, tb5.Text
            };
            var jsonUserValues = JsonConvert.SerializeObject(listUserValues);

            edit.PutString("userValues", jsonUserValues);

            string jsonList = JsonConvert.SerializeObject(list);

            edit.PutString("list", jsonList);
            edit.Apply();

            try
            {
                await SyncAsync();
            }
            catch (Exception ex)
            {
                var exception = ex.Message;
            }

            Log.Info("MainActivity", "Registering...");
            GcmClient.Register(this, Constants.SenderID);

            //this.StartActivity(intent);
        }
Example #31
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            SetContentView(Resource.Layout.settingsLayout);

            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.settingsToolbar);
            SetSupportActionBar (toolbar);
            SupportActionBar.Title = "Settings";
            SupportActionBar.SetDisplayHomeAsUpEnabled (true);

            var madview = FindViewById<AdView>(Resource.Id.mysettingadview);
            AdRequest myrqst = new AdRequest.Builder ().AddTestDevice(AdRequest.DeviceIdEmulator).Build ();
            madview.LoadAd (myrqst);

            prefs = Application.Context.GetSharedPreferences ("WingsRecorder", FileCreationMode.Private);

            //			var formattypes = new String[]{ "MP3", "3GP", "AMR" };
            var fileFormatTextview = FindViewById<TextView> (Resource.Id.textViewFileFormat);
            fileFormatTextview.Text = prefs.GetString("FileType", MainActivity.formattypes[0]);
            var fileformatLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutFileFormat);
            fileformatLinLay.Click += delegate {
                var builder = new Android.Support.V7.App.AlertDialog.Builder (this);
                builder.SetTitle ("Select File Format")
                    .SetItems(MainActivity.formattypes,
                        new EventHandler<DialogClickEventArgs>(delegate(object sender, DialogClickEventArgs e) {
                            var prefedit = prefs.Edit ();
                            fileFormatTextview.Text = MainActivity.formattypes[e.Which];
                            prefedit.PutString ("FileType", MainActivity.formattypes[e.Which]);
                            prefedit.Commit();
                        }))
                    .SetNegativeButton("Cancel", delegate {
                    });
                builder.Create().Show ();
            };

            //			var audioSourceTypes = new String[]{"Camcorder", "Mic", "Voice Call",
            //				"Voice Communication", "Voice Recognition", "Voice UpLink", "Voice DownLink"};
            var audioSouceTextview = FindViewById<TextView> (Resource.Id.textViewAudioSource);
            audioSouceTextview.Text = prefs.GetString("AudioSource", MainActivity.audioSourceTypes[2]);
            var audiosourceLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutAudioSource);
            audiosourceLinLay.Click += delegate {
                var builder = new Android.Support.V7.App.AlertDialog.Builder (this);
                builder.SetTitle ("Select Audio Source")
                    .SetItems (MainActivity.audioSourceTypes,
                        new EventHandler<DialogClickEventArgs>(delegate(object sender, DialogClickEventArgs e) {
                            var prefedit = prefs.Edit ();
                            audioSouceTextview.Text = MainActivity.audioSourceTypes[e.Which];
                            prefedit.PutString ("AudioSource", MainActivity.audioSourceTypes[e.Which]);
                            prefedit.Commit();
                        }))
                    .SetNegativeButton("Cancel", delegate {
                    });
                builder.Create().Show ();
            };

            //			var currentpath = "/storage/emulated/0/";
            //			var f = new File(currentpath).ListFiles();
            //			var files = f.Where(x=>x.IsDirectory).ToList();
            //
            var storagePathLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutStorageLocation);
            storagePathLinLay.Click += delegate {
                StartActivity (new Intent (this, typeof(pathChooseActivity)));
            };
        }
Example #32
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            OnImagePicked += (sender, image) =>
            {
                if (image == null)
                {
                    return;
                }

                AppPreference appPreference = new AppPreference();
                CvInvoke.UseOpenCL = appPreference.UseOpenCL;
                String oclDeviceName = appPreference.OpenClDeviceName;
                if (!String.IsNullOrEmpty(oclDeviceName))
                {
                    CvInvoke.OclSetDefaultDevice(oclDeviceName);
                }

                ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
                String             appVersion = PackageManager.GetPackageInfo(PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName;
                if (!preference.Contains("cascade-data-version") || !preference.GetString("cascade-data-version", null).Equals(appVersion) ||
                    !(preference.Contains("cascade-eye-data-path") || preference.Contains("cascade-face-data-path")))
                {
                    AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite;

                    FileInfo eyeFile  = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_eye.xml", "cascade", overwriteMethod);
                    FileInfo faceFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_frontalface_default.xml", "cascade", overwriteMethod);

                    //save tesseract data path
                    ISharedPreferencesEditor editor = preference.Edit();
                    editor.PutString("cascade-data-version", appVersion);
                    editor.PutString("cascade-eye-data-path", eyeFile.FullName);
                    editor.PutString("cascade-face-data-path", faceFile.FullName);
                    editor.Commit();
                }

                string           eyeXml  = preference.GetString("cascade-eye-data-path", null);
                string           faceXml = preference.GetString("cascade-face-data-path", null);
                long             time;
                List <Rectangle> faces = new List <Rectangle>();
                List <Rectangle> eyes  = new List <Rectangle>();

                DetectFace.Detect(image, faceXml, eyeXml, faces, eyes, out time);

                String computeDevice = CvInvoke.UseOpenCL ? "OpenCL: " + Emgu.CV.Ocl.Device.Default.Name : "CPU";
                SetMessage(String.Format("Detected with {1} in {0} milliseconds.", time, computeDevice));

                foreach (Rectangle rect in faces)
                {
                    CvInvoke.Rectangle(image, rect, new Bgr(System.Drawing.Color.Red).MCvScalar, 2);
                }

                foreach (Rectangle rect in eyes)
                {
                    CvInvoke.Rectangle(image, rect, new Bgr(System.Drawing.Color.Blue).MCvScalar, 2);
                }

                SetImageBitmap(image.ToBitmap());
                image.Dispose();

                if (CvInvoke.UseOpenCL)
                {
                    CvInvoke.OclFinish();
                }
            };

            OnButtonClick += (sender, args) =>
            {
                PickImage("lena.jpg");
            };
        }
Example #33
0
 public void SaveUserName(string username)
 {
     mPrefsEditor = mSharedPrefs.Edit();
     mPrefsEditor.PutString(PREFERENCE_USER_NAME_KEY, username);
     mPrefsEditor.Commit();
 }
Example #34
0
        /// <summary>
        /// Resets all show once flags
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        public static void ResetShowOnce(Context context, string id)
        {
            ISharedPreferences sharedPrefs = context.GetSharedPreferences(PREF_NAME, FileCreationMode.Private);

            sharedPrefs.Edit().Remove(id).Commit();
        }
Example #35
0
        public void ClearCrashButton()
        {
            ISharedPreferences appCenterPreferences = Android.App.Application.Context.GetSharedPreferences("AppCenter", FileCreationMode.Private);

            appCenterPreferences.Edit().Remove(CrashesUserConfirmationStorageKey).Apply();
        }
Example #36
0
        void IPreferencesBackend.Commit()
        {
            if (!dirty)
            {
                return;
            }

            dirty = false;

            using (MemoryStream s = new MemoryStream()) {
                using (BinaryWriter w = new BinaryWriter(s)) {
                    w.Write((ushort)data.Count);

                    foreach (var pair in data)
                    {
                        w.Write(pair.Key);

                        switch (pair.Value)
                        {
                        case string value: {
                            w.Write((byte)0);
                            w.Write(value);
                            break;
                        }

                        case bool value: {
                            w.Write((byte)1);
                            w.Write(value);
                            break;
                        }

                        case byte value: {
                            w.Write((byte)2);
                            w.Write(value);
                            break;
                        }

                        case int value: {
                            w.Write((byte)3);
                            w.Write(value);
                            break;
                        }

                        case long value: {
                            w.Write((byte)4);
                            w.Write(value);
                            break;
                        }

                        case string[] value: {
                            w.Write((byte)10);
                            w.Write((byte)value.Length);
                            for (int j = 0; j < value.Length; j++)
                            {
                                w.Write(value[j]);
                            }
                            break;
                        }

                        case bool[] value: {
                            w.Write((byte)11);
                            w.Write((byte)value.Length);
                            for (int j = 0; j < value.Length; j++)
                            {
                                w.Write(value[j]);
                            }
                            break;
                        }

                        case byte[] value: {
                            w.Write((byte)12);
                            w.Write((byte)value.Length);
                            for (int j = 0; j < value.Length; j++)
                            {
                                w.Write(value[j]);
                            }
                            break;
                        }

                        case int[] value: {
                            w.Write((byte)13);
                            w.Write((byte)value.Length);
                            for (int j = 0; j < value.Length; j++)
                            {
                                w.Write(value[j]);
                            }
                            break;
                        }

                        case long[] value: {
                            w.Write((byte)14);
                            w.Write((byte)value.Length);
                            for (int j = 0; j < value.Length; j++)
                            {
                                w.Write(value[j]);
                            }
                            break;
                        }

                        default:
                            Console.WriteLine("Unknown preference type: " + pair.Value.GetType().FullName);
                            break;
                        }
                    }
                }

                ArraySegment <byte> buffer;
                if (s.TryGetBuffer(out buffer))
                {
                    string base64 = Base64.EncodeToString(buffer.Array, buffer.Offset, buffer.Count, Base64Flags.NoPadding | Base64Flags.NoWrap);

                    ISharedPreferencesEditor editor = sharedPrefs.Edit();

                    editor.PutString("Root", base64);

                    editor.Commit();
                }
                else
                {
                    Console.WriteLine("Can't get memory buffer to save preferences.");
                }
            }
        }
Example #37
0
 private void SetPrefrenceValue()
 {
     _preferences.Edit().PutBoolean(AppConstant.PrefIsAdmin, false).Apply();
     _preferences.Edit().PutInt(AppConstant.PrefStudentID, -1).Apply();
 }
Example #38
0
 public static void SaveToken(string token)
 {
     _editor = _preferences.Edit();
     _editor.PutString("token", token);
     _editor.Apply();
 }
Example #39
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            OnImagePicked += (sender, image) =>
            {
                if (image == null)
                {
                    return;
                }

                ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
                String             appVersion = PackageManager.GetPackageInfo(PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName;
                if (!preference.Contains("tesseract-data-version") || !preference.GetString("tesseract-data-version", null).Equals(appVersion) ||
                    !preference.Contains("tesseract-data-path"))
                {
                    AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite;

                    FileInfo a8 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.traineddata", "tmp", overwriteMethod);
                    FileInfo a0 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.bigrams", "tmp", overwriteMethod);
                    FileInfo a1 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.fold", "tmp", overwriteMethod);
                    FileInfo a2 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.lm", "tmp", overwriteMethod);
                    FileInfo a3 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.nn", "tmp", overwriteMethod);
                    FileInfo a4 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.params", "tmp", overwriteMethod);
                    FileInfo a5 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.size", "tmp", overwriteMethod);
                    FileInfo a6 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.cube.word-freq", "tmp", overwriteMethod);
                    FileInfo a7 = AndroidFileAsset.WritePermanantFileAsset(this, "tessdata/eng.tesseract_cube.nn", "tmp", overwriteMethod);

                    //save tesseract data path
                    ISharedPreferencesEditor editor = preference.Edit();
                    editor.PutString("tesseract-data-version", appVersion);
                    editor.PutString("tesseract-data-path", System.IO.Path.Combine(a0.DirectoryName, "..") + System.IO.Path.DirectorySeparatorChar);
                    editor.Commit();
                }

                LicensePlateDetector detector = new LicensePlateDetector(preference.GetString("tesseract-data-path", null));
                Stopwatch            watch    = Stopwatch.StartNew(); // time the detection process

                List <IInputOutputArray> licensePlateImagesList         = new List <IInputOutputArray>();
                List <IInputOutputArray> filteredLicensePlateImagesList = new List <IInputOutputArray>();
                List <RotatedRect>       licenseBoxList = new List <RotatedRect>();
                List <string>            words          = detector.DetectLicensePlate(
                    image,
                    licensePlateImagesList,
                    filteredLicensePlateImagesList,
                    licenseBoxList);

                watch.Stop(); //stop the timer

                StringBuilder builder = new StringBuilder();
                builder.Append(String.Format("{0} milli-seconds. ", watch.Elapsed.TotalMilliseconds));
                foreach (String w in words)
                {
                    builder.AppendFormat("{0} ", w);
                }
                SetMessage(builder.ToString());

                foreach (RotatedRect box in licenseBoxList)
                {
                    Rectangle rect = box.MinAreaRect();
                    CvInvoke.Rectangle(image, rect, new Bgr(System.Drawing.Color.Red).MCvScalar, 2);
                }

                SetImageBitmap(image.ToBitmap());
                image.Dispose();
            };


            OnButtonClick += delegate
            {
                PickImage("license-plate.jpg");
            };
        }
Example #40
0
        /// <summary>
        /// Saves the current user info to the SharedPreferences
        /// </summary>
        public void SaveUserInfoToSp()
        {
            string json = JsonConvert.SerializeObject(application.UserInfo);

            sharedPreferences.Edit().PutString(UserInfoSharedPreference, json).Commit();
        }
 public override void OnBackPressed()
 {
     var builder = new Android.App.AlertDialog.Builder(this);
     builder.SetTitle ("Exit.");
     builder.SetIcon (Android.Resource.Drawable.IcDialogAlert);
     builder.SetMessage("Exit App?");
     builder.SetPositiveButton("OK", (s, e) =>
         {
             mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private);
             ISharedPreferencesEditor editor = mSharedPreferences.Edit ();
             editor.Remove ("SessionKey");
             editor.Commit ();
             if (!(geofenceRequestIntent == null)) {
                 geofenceRequestIntent.Cancel ();
             }
             Finish();
             Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
             //System.Environment.Exit(0);
         });
     builder.SetNegativeButton("Cancel", (s, e) => { });
     builder.Create().Show();
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByPreference(this);
            SetContentView(Resource.Layout.consent_conversation);

            SupportActionBar.Title = StringResources.consent_gabber_toolbar_title;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            ISharedPreferences _prefs          = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            Project            selectedProject = Queries.ProjectById(_prefs.GetInt("SelectedProjectID", 0));

            FindViewById <TextView>(Resource.Id.GabberConsentDecisionTitle).Text =
                StringResources.consent_gabber_title_decision;

            FindViewById <TextView>(Resource.Id.GabberConsentDecisionDesc).Text =
                string.Format(StringResources.consent_gabber_body_decision, Config.PRINT_URL);

            FindViewById <TextView>(Resource.Id.chooseLanguageTitle).Text =
                StringResources.conversation_language_prompt;

            RadioButton consentTypePublic = FindViewById <RadioButton>(Resource.Id.GabberConsentTypePublic);

            consentTypePublic.Text = StringResources.consent_gabber_consent_type_public_brief;

            FindViewById <TextView>(Resource.Id.GabberConsentTypePublicFull).Text =
                StringResources.consent_gabber_consent_type_public_full;

            RadioButton consentTypeMembers = FindViewById <RadioButton>(Resource.Id.GabberConsentTypeMembers);
            var         title = LanguageChoiceManager.ContentByLanguage(selectedProject).Title;

            consentTypeMembers.Text = string.Format(StringResources.consent_gabber_consent_type_members_brief, title);

            TextView consentTypeMembersFull = FindViewById <TextView>(Resource.Id.GabberConsentTypeMembersFull);

            consentTypeMembersFull.Text =
                string.Format(StringResources.consent_gabber_consent_type_members_full,
                              selectedProject.Members.Count,
                              (selectedProject.Members.Count > 1) ?
                              StringResources.consent_gabber_consent_type_members_full_plural :
                              StringResources.consent_gabber_consent_type_members_full_singular);

            if (selectedProject.IsPublic)
            {
                consentTypeMembers.Visibility     = ViewStates.Gone;
                consentTypeMembersFull.Visibility = ViewStates.Gone;
            }

            var consentTypePrivate = FindViewById <RadioButton>(Resource.Id.GabberConsentTypePrivate);

            consentTypePrivate.Text = StringResources.consent_gabber_consent_type_private_brief;

            var consentTypePrivateFull = FindViewById <TextView>(Resource.Id.GabberConsentTypePrivateFull);
            var participants           = BuildParticipants(Queries.SelectedParticipants().ToList());

            consentTypePrivateFull.TextFormatted = Html.FromHtml(string.Format(StringResources.consent_gabber_consent_type_private_full, participants));

            var isConsented = FindViewById <RadioGroup>(Resource.Id.GabberConsentProvided);

            submitButton         = FindViewById <AppCompatButton>(Resource.Id.GabberConsentSubmit);
            submitButton.Text    = StringResources.consent_gabber_submit;
            submitButton.Enabled = false;

            submitButton.Click += (s, e) =>
            {
                var consent = "";
                if (consentTypePublic.Checked)
                {
                    consent = "public";
                }
                if (consentTypeMembers.Checked)
                {
                    consent = "members";
                }
                if (consentTypePrivate.Checked)
                {
                    consent = "private";
                }
                // This is used then deleted when saving the recording session
                _prefs.Edit().PutString("SESSION_CONSENT", consent).Commit();

                LanguageChoice chosenLang = languageChoices.FirstOrDefault((arg) => arg.Endonym == selectedLanguage);

                _prefs.Edit().PutInt("SESSION_LANG", chosenLang.Id).Commit();

                StartActivity(new Intent(this, typeof(RecordStoryActivity)));
            };

            isConsented.CheckedChange += (s, e) =>
            {
                consentChecked = true;
                CheckIfCanSubmit();
            };

            languageSpinner = FindViewById <Spinner>(Resource.Id.chooseLanguageSpinner);
            languageSpinner.ItemSelected += LanguageSpinner_ItemSelected;

            LoadLanguages();
        }
		public Security_Android()
		{
			_preferences = Forms.Context.GetSharedPreferences(_keyChainServiceName, FileCreationMode.Private);
			_preferenceEditor = _preferences.Edit();
		}
Example #44
0
 public static void SetBool(ISharedPreferences prefs, string key, bool val)
 {
     prefs.Edit().PutBoolean(key, val).Commit();
 }
Example #45
0
 protected override void OnCreate(Bundle bundle)
 {
     RequestWindowFeature(WindowFeatures.NoTitle);
     base.OnCreate (bundle);
     SetContentView (Resource.Layout.Main);
     mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private);
     string storedUser = mSharedPreferences.GetString ("StoredUser", "NONE");
     string storedPass = mSharedPreferences.GetString ("StoredPass", "NONE");
     if (!storedUser.Equals("NONE") || !storedPass.Equals("NONE")) {
         FindViewById<EditText>(Resource.Id.txtUsername).SetText(storedUser, TextView.BufferType.Normal);
         FindViewById<EditText>(Resource.Id.txtPassword).SetText(storedPass, TextView.BufferType.Normal);
         FindViewById<CheckBox>(Resource.Id.cbStoreUser).Checked = true;
     }
     FindViewById<CheckBox>(Resource.Id.cbStoreUser).CheckedChange += delegate {
         ISharedPreferencesEditor cbeditor = mSharedPreferences.Edit ();
         cbeditor.Remove("StoredUser");
         cbeditor.Remove("StoredPass");
         cbeditor.Commit();
     };
     Button button = FindViewById<Button> (Resource.Id.btnLogin);
     button.Click += delegate {
         TextView txtPassword = FindViewById<TextView> (Resource.Id.txtPassword);
         TextView txtUsername = FindViewById<TextView> (Resource.Id.txtUsername);
         if (string.IsNullOrEmpty(txtPassword.Text) || string.IsNullOrEmpty(txtUsername.Text)) {
             var myHandler = new Handler();
             myHandler.Post(() => {
                 Android.Widget.Toast.MakeText(this, "Please Provide a Username and Password.", Android.Widget.ToastLength.Long).Show();
             });
         } else {
             try {
                 var locSvc = new ROMPLocation();
                 var loginResp = new LoginResponse();
                 loginResp = locSvc.LearnerLogin(txtUsername.Text, txtPassword.Text);
                 if (loginResp.Success) {
                     CheckBox rememberMe = FindViewById<CheckBox> (Resource.Id.cbStoreUser);
                     ISharedPreferencesEditor editor = mSharedPreferences.Edit ();
                     if (rememberMe.Checked) {
                         editor.PutString("StoredUser", txtUsername.Text);
                         editor.PutString("StoredPass", txtPassword.Text);
                     } else {
                         editor.Remove("StoredUser");
                     }
                     editor.Commit();
                     if (loginResp.GroupID <= 2) {
                         var nextActivity = new Intent(this, typeof(ChooseModeActivity));
                         nextActivity.PutExtra("SessionKey", loginResp.SessionKey);
                         nextActivity.PutExtra("GroupID", loginResp.GroupID);
                         nextActivity.PutExtra("UserID", loginResp.UserID);
                         StartActivity(nextActivity);
                         Finish();
                     } else {
                         var nextActivity = new Intent(this, typeof(CheckInActivity));
                         nextActivity.PutExtra("SessionKey", loginResp.SessionKey);
                         nextActivity.PutExtra("GroupID", loginResp.GroupID);
                         nextActivity.PutExtra("UserID", loginResp.UserID);
                         StartActivity(nextActivity);
                         Finish();
                     }
                 } else {
                     var myHandler = new Handler();
                     myHandler.Post(() => {
                         Android.Widget.Toast.MakeText(this, "Login Failed. Please Try Again.", Android.Widget.ToastLength.Long).Show();
                     });
                 }
             } catch (Exception e) {
                 var myHandler = new Handler();
                 myHandler.Post(() => {
                     Android.Widget.Toast.MakeText(this, e.Message, Android.Widget.ToastLength.Long).Show();
                 });
                 System.Diagnostics.Debug.Write(e.Message);
             }
         }
     };
 }
 public AppSettings(Context context)
 {
     this.context = context;
     sharedPrefs  = PreferenceManager.GetDefaultSharedPreferences(this.context);
     prefsEditor  = sharedPrefs.Edit();
 }
Example #47
0
		private void InitView()
		{
			//设置标题栏
			var img_header_back = FindViewById<ImageView> (Resource.Id.img_header_back);
			img_header_back.Click += (sender, e) => 
			{
				this.Finish();
				OverridePendingTransition(Resource.Animation.bottom_out,0);
			};

			var tv_back = FindViewById<TextView> (Resource.Id.tv_back);
			tv_back.Text = "";
			var tv_desc = FindViewById<TextView> (Resource.Id.tv_desc);
			tv_desc.Text = "登录";



			_jpushUtil = new JPushUtil (this);
			// Create your application here
			//或得共享实例变量
			sp_userinfo = this.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private);
			//获得实例对象
			edit_userName = FindViewById<EditText>(Resource.Id.edit_UserName);
			edit_userPassword = FindViewById<EditText> (Resource.Id.edit_PassWord);
			cb_passWord = FindViewById<CheckBox> (Resource.Id.cb_Password);
			btn_login = FindViewById<Button> (Resource.Id.btn_Login);
			tv_Register = FindViewById<TextView> (Resource.Id.tv_Register);
			var tv_forgetPwd = FindViewById<TextView> (Resource.Id.tv_forgetPwd);
			var img_eye = FindViewById<ImageView> (Resource.Id.img_eye);
			img_eye.Click += (sender, e) => 
			{
				if(edit_userPassword.InputType == (Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationPassword))
				{
					edit_userPassword.InputType = Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationVisiblePassword;
					img_eye.SetImageResource(Resource.Drawable.ic_login_eye_selected);
				}
				else if(edit_userPassword.InputType == (Android.Text.InputTypes.ClassText| Android.Text.InputTypes.TextVariationVisiblePassword))
				{
					edit_userPassword.InputType = Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationPassword;
					img_eye.SetImageResource(Resource.Drawable.ic_login_eye_normal);
				}

			};

			//点击注册
			tv_Register.Click += (sender, e) => 
			{
				
				StartActivity(typeof(RegisterStepOneActivity));
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);
			};

			//找回密码
			tv_forgetPwd.Click += (sender, e) => 
			{
				var intent = new Intent(this,typeof(SendSecurityCodeActivity));
				var sendbundle = new Bundle();
				sendbundle.PutString("SendType","FindPwd");
				sendbundle.PutString("PhoneNumber",string.Empty);
				intent.PutExtras(sendbundle);
				StartActivity(intent);
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);
			};

			//如果选择了记住密码,则赋值
			if (sp_userinfo.GetBoolean (Global.refrence_Password_Check, false)) {
				cb_passWord.Checked = true;
				edit_userName.Text = sp_userinfo.GetString (Global.refrence_UserName, string.Empty);
				edit_userPassword.Text = sp_userinfo.GetString (Global.refrence_Password, string.Empty);
			}



			//记住密码选择事件
			cb_passWord.CheckedChange += (sender, e) => 
			{
				if(cb_passWord.Checked)
					sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,true).Commit();
				else
					sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,false).Commit();
			};


			//登录按钮事件
			btn_login.Click += (sender, e) => 
			{

				Login();
			};
		}
Example #48
0
        public static ISharedPreferencesEditor GetPreferencesEditor(string Name, FileCreationMode CreationMode = FileCreationMode.Private)
        {
            ISharedPreferences Editor = GetPreferences(Name, CreationMode);

            return(Editor.Edit());
        }
Example #49
0
 public AppPreferences(Context context)
 {
     this.mContext = context;
     mSharedPrefs = PreferenceManager.GetDefaultSharedPreferences(mContext);
     mPrefsEditor = mSharedPrefs.Edit();
 }
Example #50
0
 static Settings()
 {
     SharedPreferences = Application.Context.GetSharedPreferences(PrefName, FileCreationMode.Private);
     SharedPreferencesEditor = SharedPreferences.Edit();
 }
Example #51
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            userID = Intent.GetStringExtra ("id") ?? "-1";
            mainPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private);
            mainEditor = mainPrefs.Edit ();
            serviceNumer = mainPrefs.GetInt ("service_size", -1);
            categoryNumber = mainPrefs.GetInt ("category_size", 0);
            SetContentView (Resource.Layout.Main);

            tabHost = FindViewById<TabHost> (Android.Resource.Id.TabHost);

            tabHost.Setup ();

            for (int i = 0; i < categoryNumber; i++) {

                TabHost.TabSpec tabSpec;
                tabSpec = tabHost.NewTabSpec(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower());
                tabSpec.SetIndicator(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower());
                tabSpec.SetContent(new FakeContent(this));
                tabHost.AddTab(tabSpec);
            }
            tabHost.SetOnTabChangedListener(this);
            setSelectedTabColor ();
            /*for(int i = 0; i < tabHost.TabWidget.ChildCount; i++) {
                View v = tabHost.TabWidget.GetChildTabViewAt(i);

                // Look for the title view to ensure this is an indicator and not a divider.

                v.SetBackgroundResource(Resource.Drawable.apptheme_tab_indicator_holo);
            }*/
            viewPager = FindViewById<ViewPager> (Resource.Id.view);
            var adaptor = new ServiceBeaconAdapter (SupportFragmentManager);

            for (int i = 0; i < categoryNumber; i++) {
                adaptor.addFragmentView ((k, v, b) => {
                    var view = k.Inflate (Resource.Layout.Page, v, false);
                    var myText = view.FindViewById<TextView> (Resource.Id.textView1);
                    myText.Text = mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower();
                    return view;
                });
            }

            viewPager.Adapter = adaptor;//new ServiceBeaconAdapter (SupportFragmentManager);
            viewPager.SetOnPageChangeListener(this);

            beaconStatusLabel = FindViewById<TextView> (Resource.Id.beaconStatusLabel);

            beaconMgr.Bind (this);

            //myProcessedBeacons = new JavaDictionary<string,string>();
            monitorNotifier.EnterRegionComplete += EnteredRegion;
            monitorNotifier.ExitRegionComplete += ExitedRegion;

            rangeNotifier.DidRangeBeaconsInRegionComplete += HandleBeaconsInRegion;
        }
		// Parse the user data, then permits , user accessing the app
		private void ParseAndProcess (JsonValue json)
		{
			// Extract the array of name/value results for the field name "weatherObservation". 
			JsonValue authResults = json;

			if (json["idUser"] == null) {
				AlertDialog.Builder alert = new AlertDialog.Builder (this);
				/*editLogin.SetError ("",errorIcon);
				editPassword.SetError ("",errorIcon);*/
				alert.SetTitle ("Login Error");
				alert.SetMessage ("Mismatched Login and Password");
				alert.SetPositiveButton ("Retry", (senderAlert, args) => {
					//change value write your own set of instructions
					//you can also create an event for the same in xamarin
					//instead of writing things here
				} );
				alert.Show ();

			} else {
				var userInfo = new UserInfo ();
				String stringValue = authResults.ToString();
				userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (stringValue);



				loginPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private);
				loginEditor = loginPrefs.Edit ();

				accounts.Add (userInfo.userEmail+"|"+editPassword.Text);		
				foreach (PrivateService pService in userInfo.privateServices) {
					services.Add (userInfo.idUser+"|"+pService.serviceName+" "+pService.serviceDescription+"|" +pService.locations[0].idLocation);
				}
				foreach (Bdp bdp in userInfo.bdps) {
					devicesBDP.Add (bdp.uuId + "|" + bdp.location.idLocation);
				}
				foreach (ServiceCategory serviceCategory in userInfo.serviceCategories) {
					serviceCategories.Add (serviceCategory.idServiceCategory + "|" + serviceCategory.categoryName);
				}
				saveArray ();


				loginIntent = new Intent (this, typeof(MainActivity));
				loginIntent.PutExtra ("id",editPassword.Text.ToString () );
				StartActivity (loginIntent);
			}

			// Extract the "stationName" (location string) and write it to the location TextBox:
			//location.Text = weatherResults["stationName"];

		}
Example #53
0
 private AppConfig()
 {
     m_Read=Android.App.Application.Context.GetSharedPreferences("AppSetting", FileCreationMode.Private);
     m_Edit=m_Read.Edit();
 }
Example #54
0
 public Settings(Context c)
 {
     _sCont = c.GetSharedPreferences (File, 0);
     _sEdit = _sCont.Edit ();
 }
Example #55
0
        private void sendRegistrationToServer(String token)
        {
            ISharedPreferences sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);

            sharedPreferences.Edit().PutBoolean(SENT_TOKEN_TO_SERVER, true).Apply();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                ISharedPreferences       sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);
                ISharedPreferencesEditor editorfacture     = sharedPreferences.Edit();

                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.CreationClient1);
                Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

                SetSupportActionBar(toolbar);
                //SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                //SupportActionBar.SetHomeButtonEnabled(true);
                toolbar.SetTitleTextColor(Android.Graphics.Color.Rgb(0, 250, 154));
                toolbar.SetBackgroundColor(Android.Graphics.Color.Rgb(27, 49, 71));
                toolbar.Title = "Vos Informations";
                nom           = FindViewById <EditText>(Resource.Id.textInputEditTextNomCreation);
                Email         = FindViewById <EditText>(Resource.Id.textInputEditTextEmailCreation);
                tel           = FindViewById <EditText>(Resource.Id.editTextTelePhoneCration);
                Adresse       = FindViewById <EditText>(Resource.Id.textInputEditTextAdresseCreation);
                CodePostal    = FindViewById <EditText>(Resource.Id.textInputEditTextCodePostalCreation);
                Ville         = FindViewById <EditText>(Resource.Id.textInputEditTextVilleCreation);
                Pays          = FindViewById <EditText>(Resource.Id.textInputEditTextPaysCreation);
                btnsuivant    = FindViewById <Button>(Resource.Id.buttonsuivantcreation1);

                ad1 = FindViewById <AdView>(Resource.Id.adView2Crearion);
                ad2 = FindViewById <AdView>(Resource.Id.adView3creation11);

                nom.Text   = sharedPreferences.GetString("Nom", "");
                Email.Text = sharedPreferences.GetString("Email", "");
                tel.Text   = sharedPreferences.GetString("Tel", "");



                Adresse.Text      = sharedPreferences.GetString("Adresse", "");
                CodePostal.Text   = sharedPreferences.GetString("CodePostal", "");
                Ville.Text        = sharedPreferences.GetString("Ville", "");
                Pays.Text         = sharedPreferences.GetString("Pays", "");
                btnsuivant.Click += delegate
                {
                    editorfacture.PutString("Nom", nom.Text);
                    editorfacture.PutString("Email", Email.Text);
                    editorfacture.PutString("Tel", tel.Text);
                    editorfacture.PutString("Adresse", Adresse.Text);
                    editorfacture.PutString("CodePostal", CodePostal.Text);
                    editorfacture.PutString("Ville", Ville.Text);
                    editorfacture.PutString("Pays", Pays.Text);
                    editorfacture.Apply();


                    Intent intent = new Intent(this, typeof(CreationClient2));

                    StartActivity(intent);
                };

                // Create your application here
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
        }
Example #57
0
 public Persistencia(Context cont)
 {
     prefs  = PreferenceManager.GetDefaultSharedPreferences(cont);
     editor = prefs.Edit();
 }
    public void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
    {
        MainActivity parentActivity = (MainActivity)Activity;

        if (key.CompareTo(Resources.GetString(Resource.String.pref_key)) == 0)
        {
            ListPreference connectionPref = (ListPreference)FindPreference(key);
            Log.Debug(TAG, "Template PreferenceChanged: " + connectionPref.Value);
            parentActivity.localSettings.selectedFileIndex = int.Parse(connectionPref.Value);
            connectionPref.Summary = connectionPref.Entry;
            //save last template used

            /*ISharedPreferences iprefs = null;
             * iprefs.Edit();
             * iprefs = (ISharedPreferences)prefs.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
             * prefs.Apply();*/

            ISharedPreferencesEditor editor = (ISharedPreferencesEditor)prefs.Edit();
            editor.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
            editor.Apply();
        }
        else if (key.CompareTo("timeout_identification") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Identification PreferenceChanged: " + connectionPref.Text);

            int idto = parentActivity.localSettings.identificationTimeout;

            try {
                idto = int.Parse(connectionPref.Text);
                if (idto < 5000)
                {
                    idto = 5000;
                }
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }

            connectionPref.Text = idto.ToString();
            parentActivity.localSettings.identificationTimeout = idto;
        }
        else if (key.CompareTo("timeout_processing") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Processing PreferenceChanged: " + connectionPref.Text);

            int processingTimeout = parentActivity.localSettings.processingTimeout;;

            try
            {
                processingTimeout = int.Parse(connectionPref.Text);
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            connectionPref.Text = processingTimeout.ToString();
            parentActivity.localSettings.processingTimeout = processingTimeout;
        }
        else if (key.CompareTo("ui_result_confirmation") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "result confrmation PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableResultConfirmation = connectionPref.Checked;
        }
        else if (key.CompareTo("auto_capture") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Auto capture PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableAutoCapture = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_audio") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Audio PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableFeedbackAudio = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_haptic") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Haptic PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableHaptic = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_led") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "LED PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableLED = connectionPref.Checked;
        }
    }
		public FloatListPreference(Context context, IAttributeSet attrs) : base(context, attrs) 
		{
			_sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context);
			_sharedPreferencesEditor = _sharedPreferences.Edit();
		}
Example #60
0
 public DroidStorage(Context context, string sharedPreferencesName)
 {
     prefs = context.GetSharedPreferences(sharedPreferencesName, 0);
     editor = prefs.Edit();
 }