Пример #1
0
 // Getting an authentication token is not supported //throws NetworkErrorException
 public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
 {
     var result = new Bundle();
     var am = AccountManager.Get(mContext.ApplicationContext);
     var authToken = am.PeekAuthToken(account, authTokenType);
     if (string.IsNullOrEmpty(authToken))
     {
         var password = am.GetPassword(account);
         if (!string.IsNullOrEmpty(password))
         {
             authToken = AuthTokenLoader.SignIn(mContext, account.Name, password);
         }
     }
     if (!string.IsNullOrEmpty(authToken))
     {
         result.PutString(AccountManager.KeyAccountName, account.Name);
         result.PutString(AccountManager.KeyAccountType, account.Type);
         result.PutString(AccountManager.KeyAuthtoken, authToken);
     }
     else
     {
         var intent = new Intent(mContext, typeof(LoginActivity));
         intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
         intent.PutExtra(LoginActivity.EXTRA_TOKEN_TYPE, authTokenType);
         var bundle = new Bundle();
         bundle.PutParcelable(AccountManager.KeyIntent, intent);
     }
     return result;
 }
		private void InitView()
		{
			//设置标题栏
			var btn_header_back = FindViewById<Button> (Resource.Id.btn_header_back);
			btn_header_back.Click += (sender, e) => 
			{
				this.Finish();
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);
			};
			var tv_header_title = FindViewById<TextView> (Resource.Id.tv_header_title);
			tv_header_title.Text = "账户安全";



			//登录密码
			var rl_person_loginPwd = FindViewById<RelativeLayout>(Resource.Id.rl_person_loginPwd);
			rl_person_loginPwd.Click += (sender, e) => 
			{
				var intent = new Intent(this,typeof(SendSecurityCodeActivity));
				var sendbundle = new Bundle();
				sendbundle.PutString("SendType","ModifyPwd");//修改密码
				sendbundle.PutString("PhoneNumber",Global.MyInfo.PhoneNumberOne);
				intent.PutExtras(sendbundle);
				StartActivity(intent);
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);

			};
			//修改支付密码
			var rl_person_payPwd = FindViewById<RelativeLayout>(Resource.Id.rl_person_payPwd);
			rl_person_payPwd.Click += (sender, e) => 
			{
				var intent = new Intent(this,typeof(SendSecurityCodeActivity));
				var sendbundle = new Bundle();
				sendbundle.PutString("SendType","ModifyPayPwd");//设置支付密码
				sendbundle.PutString("PhoneNumber",Global.MyInfo.PhoneNumberOne);
				intent.PutExtras(sendbundle);
				StartActivity(intent);
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);
			};
			tv_payPwd = FindViewById<TextView> (Resource.Id.tv_payPwd);

			//手机绑定
			var rl_person_phoneBind = FindViewById<RelativeLayout>(Resource.Id.rl_person_phoneBind);
			rl_person_phoneBind.Click += (sender, e) => 
			{

			};
			tv_phoneBind = FindViewById<TextView> (Resource.Id.tv_phoneBind);

			//身份认证
			var rl_person_identity = FindViewById<RelativeLayout>(Resource.Id.rl_person_identity);
			rl_person_identity.Click += (sender, e) => 
			{

			};
			tv_identity = FindViewById<TextView> (Resource.Id.tv_identity);


		}
Пример #3
0
        protected Bundle makeRequestBundle(string method) 
		{
            var request = new Bundle();
            request.PutString(Consts.BILLING_REQUEST_METHOD, method);
            request.PutInt(Consts.BILLING_REQUEST_API_VERSION, 2);
			request.PutString(Consts.BILLING_REQUEST_PACKAGE_NAME, Service.PackageName);
            return request;
        }
Пример #4
0
		/// <Docs>Bundle in which to place your saved state.</Docs>
		/// <summary>
		/// Raises the save instance state event.
		/// </summary>
		/// <param name="outState"> Activity's bundle
		/// </param>
		protected override void OnSaveInstanceState (Bundle outState)
		{
			outState.PutString ("editText", editText.Text);
			outState.PutString ("masterCodeText", masterCodeText.Text);
			outState.PutString ("serviceCodeText", serviceCodeText.Text);

			base.OnSaveInstanceState (outState);
		}
Пример #5
0
		public static ConfirmationDialog Instance(string title, string message)
		{
			ConfirmationDialog dialog = new ConfirmationDialog();
			Bundle arguments = new Bundle();
			arguments.PutString(MESSAGE, message);
			arguments.PutString(TITLE, title);
			dialog.Arguments = arguments;
			return dialog;
		}
Пример #6
0
 public static MessageDialog NewInstance(string message, string title)
 {
     var dialog = new MessageDialog();
     var args = new Bundle();
     args.PutString(MESSAGE, message);
     args.PutString(TITLE, title);
     dialog.Arguments = args;
     return dialog;
 }
Пример #7
0
		public static ErrorDialog Instance(string title, string errors)
		{
			ErrorDialog dialog = new ErrorDialog();
			Bundle arguments = new Bundle();
			arguments.PutString(ERRORS, errors);
			arguments.PutString(TITLE, title);
			dialog.Arguments = arguments;
			return dialog;
		}
		private void SaveViewFieldsValues(Bundle outState) {
			outState.PutAll(outState);
			outState.PutString(keyAdvertisementTitleText, advertisementTitle.Text);
			outState.PutString(keyAdvertisementDescriptionText, advertisementDescription.Text);
			outState.PutBoolean(keyRdBtnOnlyForSellValue, rdBtnOnlyForSell.Checked);
			outState.PutString(keyAdvertisementPriceValue, advertisementPrice.Text);
			outState.PutString(keyPhotoView1Path, mPhotoPath);
			outState.PutBoolean(keyPhotoIsTakingValue, photoIsTaking);
		}
Пример #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //Log.Info(tag, "STUFF WILL HAPPEN");
            base.OnCreate (savedInstanceState);
            string username = "";
            string password = "";
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Login);

            // Get our button from the layout resource,
            // and attach an event to it
            Button login = FindViewById<Button> (Resource.Id.LoginButton);
            TextView userName = FindViewById<TextView> (Resource.Id.UserName);
            TextView passWord = FindViewById<TextView> (Resource.Id.Password);
            userName.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                username = e.Text.ToString();
            };

            passWord.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                password = e.Text.ToString();
            };

            login.Click += async (sender, e) =>  {

                try{
                    var login_er =new LoginUtility();
                    Task<LoginResponse> asdfg = login_er.LoginAsync(username, password);

                    LoginResponse result = await asdfg;
                    if(result.validate){
                        Intent intent = new Intent(this, typeof(HomeScreenActivity));
                        var b = new Bundle();
                        b.PutString("user",result.username);
                        b.PutString("key",result.KEY);
                        intent.PutExtras(b);

                        StartActivity(intent);

                        LoginInfo.username = result.username;
                        LoginInfo.KEY = result.KEY;
                    }else{
                        Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        AlertDialog alertDialog = builder.Create();
                        alertDialog.SetTitle("Login Failed");
                        alertDialog.SetMessage("Login Failed, Please Try Again");
                        alertDialog.Show();

                        //Log.Info(tag, "STUFF WILL HAPPEN"+ result.ToString());
                    }
                }
                catch (AndroidException){

                }

            };
        }
Пример #10
0
 void NavigateToNextScreen()
 {
     // Navigate to video player
     var extras = new Bundle();
     extras.PutString("nextView", "LevelSelectActivity");
     extras.PutString("videoPath", DataHolder.Current.Common.IntroVideoPath);
     var intent = new Intent(this, typeof(VideoActivity));
     intent.PutExtras(extras);
     StartActivity(intent);
 }
Пример #11
0
        private void SaveCurrentPlayerData(Bundle state)
        {
            state?.PutString(General.PLAYER_TITLE_PLAYING, current_title);
            state?.PutString(General.PLAYER_IMAGE_SRC_PLAYING, current_image);
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            var edits = prefs.Edit();

            edits.PutString(General.PLAYER_TITLE_PLAYING, current_title);
            edits.PutString(General.PLAYER_IMAGE_SRC_PLAYING, current_image);
            edits.Commit();
        }
Пример #12
0
 public static InputDialogFragment NewInstance(Activity context, string title, string message, Action<int> okAction)
 {
     var frag = new InputDialogFragment();
     var args = new Bundle();
     args.PutString("title", title);
     args.PutString("message", message);
     frag.Arguments = args;
     _actionOk = okAction;
     _context = context;
     return frag;
 }
Пример #13
0
		void listView_ItemClick(object sender, AdapterView.ItemLongClickEventArgs e){
			// content to pass to dialog fragment
			var bundle1 = new Bundle();
			bundle1.PutString ("MH", list[e.Position].MaMH);
			bundle1.PutBoolean ("check", true);
			bundle1.PutString ("NamHoc", list[e.Position].NamHoc);
			bundle1.PutString ("HocKy", list[e.Position].HocKy);
			Intent myintent = new Intent (Activity, typeof(Remider));
			myintent.PutExtra ("RemindValue", bundle1);
			StartActivity (myintent);
		}
        public CreateProjectDialogFragment (TimeEntryModel timeEntry, WorkspaceModel workspace, int color)
        {
            var args = new Bundle ();

            if (timeEntry != null) {
                args.PutString (TimeEntryIdArgument, timeEntry.Id.ToString ());
            }
            args.PutString (WorkspaceIdArgument, workspace.Id.ToString ());
            args.PutInt (ProjectColorArgument, color);

            Arguments = args;
        }
Пример #15
0
        // Обработка текста письма и передача его в Activity1
        private void response_Clicked(object sender, EventArgs e)
        {
            count = 0;
            Intent intent = new Intent(this, typeof(Activity1));
            Bundle extras = new Bundle();

            extras.PutString("answer", letter.Text);
            extras.PutString("id", count.ToString());
            intent.PutExtras(extras);
            count++;
            StartActivity(intent);
        }
Пример #16
0
		protected override void OnSaveInstanceState(Bundle outState)
		{
			base.OnSaveInstanceState(outState);
			if (currentImageUri == null)
			{
				outState.PutString("current_image_uri", string.Empty);
			}
			else
			{
				outState.PutString("current_image_uri", currentImageUri.ToString());
			}
		}
        private void MoreData(string index, string SelectCity)
        {
            Intent deviceList = new Intent(this, typeof(Detail));

            Bundle bundle = new Bundle();  //  Bundle的底层是一个HashMap<String, Object
            bundle.PutString("index",index);
            bundle.PutString("SelectCity", SelectCity);

            deviceList.PutExtra("bundle", bundle);

            StartActivity(deviceList);
        }
Пример #18
0
            public override void HandleMessage(Message msg)
            {
                Message msg1 = Message.Obtain();
                Bundle bundle = new Bundle();
                bundle.PutString("arg1", "index.html");
                bundle.PutString("arg2", "http://www.vogella.com/index.html");
                msg1.Data = bundle;
                Messenger replyto = new Messenger(msg.ReplyTo.Binder);
                replyto.Send(msg1);

                 	         // Log.Error(this.Class.DeclaringClass.Class.Name, "Handlign message, ComputeService");
            }
Пример #19
0
        protected override void OnSaveInstanceState(Bundle outState)
        {
            outState.PutInt(ExtraRequestId, _requestId);
            outState.PutString(ExtraMediaAction, _mediaAction);
            outState.PutString(ExtraMediaType, _mediaType);
            outState.PutString(ExtraPhotosDir, _photoSubDir);
            outState.PutBoolean(PresentedBundleKey, _presented);

            if (_file != null)
                outState.PutString(FilePathKey, _file.Path);

            base.OnSaveInstanceState(outState);
        }
Пример #20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.PassFrom);

            // using Bundles
            Bundle thisBundle = new Bundle();
            thisBundle.PutString("MyData", "A string of data.");
            thisBundle.PutString("MyData2", "Another string of data.");
            var intent = new Intent(this, typeof(PassBundleToActivity));
            intent.PutExtras(thisBundle);
            StartActivity(intent);
        }
Пример #21
0
        // Static factory method that creates and initializes a new flash card fragment:
        public static FlashCardFragment newInstance(String question, String answer)
        {
            // Instantiate the fragment class:
            FlashCardFragment fragment = new FlashCardFragment();

            // Pass the question and answer to the fragment:
            Bundle args = new Bundle();
            args.PutString(FLASH_CARD_QUESTION, question);
            args.PutString(FLASH_CARD_ANSWER, answer);
            fragment.Arguments = args;

            return fragment;
        }
Пример #22
0
		public static WebViewDialog Instance(string title, string url, bool okay = false)
		{
			WebViewDialog d = new WebViewDialog ();

			Bundle args = new Bundle ();

			args.PutString (StringVarConsts.EXTRA_TITLE, title);
			args.PutString (StringVarConsts.EXTRA_URL, url);
			args.PutBoolean (StringVarConsts.EXTRA_OK_FLAG, okay);

			d.Arguments = args;

			return d;
		}
        public static QuickFireFragment NewInstance(IAssessmentTask passed, ActivityHelp helper)
        {
            QuickFireFragment fragment = new QuickFireFragment();
            QuickFireTask task = passed as QuickFireTask;

            Bundle args = new Bundle();
            args.PutInt("ID", task.Id);
            args.PutString("TITLE", task.Title);
            args.PutString("HELPER", JsonConvert.SerializeObject(helper));
            args.PutString("PROMPTS", JsonConvert.SerializeObject(task.PromptCol));
            fragment.Arguments = args;

            return fragment;
        }
		public static TrickDescriptionFragment newInstance(Trick trick)
		{
			var frag = new TrickDescriptionFragment();

			// Supply num input as an argument.
			var args = new Bundle();
			args.PutString("desc", trick.Description);
			args.PutString("type", trick.Type.ToString());
			args.PutString("name", trick.Name);
			args.PutString("vidID", trick.SearchID);
			frag.Arguments = args;

			return frag;
		}
		public static SimpleDialogFragment Instance(string title, string textValue, bool html = false, bool okay = false)
		{
			SimpleDialogFragment d = new SimpleDialogFragment ();

			Bundle args = new Bundle ();

			args.PutString (StringVarConsts.EXTRA_TITLE, title);
			args.PutString (StringVarConsts.EXTRA_TEXT_1, textValue);
			args.PutBoolean (StringVarConsts.EXTRA_HTML_FLAG, html);
			args.PutBoolean (StringVarConsts.EXTRA_OK_FLAG, okay);

			d.Arguments = args;

			return d;
		}
Пример #26
0
		void listView_ItemClick(object sender, AdapterView.ItemLongClickEventArgs e){
			// content to pass 
			var bundle1 = new Bundle();
			LichHoc lh = BLichHoc.GetLH(SQLite_Android.GetConnection (),listCT[e.Position].Id);

			bundle1.PutString ("MH", lh.Id);
			bundle1.PutBoolean ("isLHT", false);
			bundle1.PutBoolean ("check", false);
			bundle1.PutString ("Thu", listCT [e.Position].Thu);
			bundle1.PutString ("TietBD", listCT [e.Position].TietBatDau);

			Intent myintent = new Intent (Activity, typeof(Remider));
			myintent.PutExtra ("RemindValue", bundle1);
			StartActivity (myintent);
		}
		public override Task<OAuthResult> Login(string oauthLoginUrl)
		{
			logger.d (LOG_TAG, "Got oauth url = " + oauthLoginUrl, null);
			Bundle data = new Bundle ();
			data.PutString ("url", oauthLoginUrl);
			data.PutString ("title", "Login");
			Intent i = new Intent (this.appContext, typeof(FHOAuthIntent));
			receiver = new OAuthURLRedirectReceiver (this);
			IntentFilter filter = new IntentFilter (FHOAuthWebview.BROADCAST_ACTION_FILTER);
			this.appContext.RegisterReceiver (this.receiver, filter);
			i.PutExtra ("settings", data);
			i.AddFlags (ActivityFlags.NewTask);
			this.appContext.StartActivity (i);
			return tcs.Task;
		}
Пример #28
0
        public EditTimeEntryFragment (TimeEntryModel model)
        {
            var args = new Bundle ();
            args.PutString (TimeEntryIdArgument, model.Id.ToString ());

            Arguments = args;
        }
        public override void OnSaveInstanceState(Bundle outState)
        {
            string serializedShow = JsonConvert.SerializeObject(_myShow);
            outState.PutString("showSerialized", serializedShow);
            base.OnSaveInstanceState(outState);

        }
Пример #30
0
        public override void Start()
        {
            Bundle hints = new Bundle();
            foreach (Symbology symbology in _enabled)
            {
                switch (symbology)
                {
                    case Symbology.UPCE: hints.PutBoolean(DO_UPCE, true); break;
                    case Symbology.EAN8: hints.PutBoolean(DO_EAN8, true); break;
                    case Symbology.EAN13: hints.PutBoolean(DO_EAN13, true); break;
                    case Symbology.Code39: hints.PutBoolean(DO_CODE93, true); break;
                    case Symbology.Code93: hints.PutBoolean(DO_CODE39, true); break;
                    case Symbology.Code128: hints.PutBoolean(DO_CODE128, true); break;
                    case Symbology.Sticky: hints.PutBoolean(DO_STICKY, true); break;

                    case Symbology.UPCA: break;
                    default: break;
                }
            }
            hints.PutString(DO_BROADCAST_TO, RedLaserScanReceiver.BROADCAST_ACTION);

            Intent i = new Intent();
            i.SetAction("com.target.redlasercontainer.SCAN");
            i.PutExtras(hints);

            Log.Info("BarcodeScanning", "broadcast intent with action com.target.redlasercontainter.SCAN sent");
            try
            {
                _context.SendBroadcast(i);
            }
            catch (Exception ex)
            {
                Log.Error("BarcodeScanning", ex.Message);
            }
        }
        public ChangeTimeEntryStopTimeDialogFragment (TimeEntryModel model) : base ()
        {
            var args = new Bundle ();
            args.PutString (TimeEntryIdArgument, model.Id.ToString ());

            Arguments = args;
        }
Пример #32
0
 protected override void OnSaveInstanceState(Bundle outState)
 {
     outState.PutString(SavedTabIndexStateKey, _tabHost.CurrentTabTag);
     base.OnSaveInstanceState(outState);
 }
Пример #33
0
 /// <summary>
 /// Save our current state into a bundle
 /// </summary>
 /// <param name="outState">The bundle</param>
 public override void OnSaveInstanceState(Bundle outState)
 {
     base.OnSaveInstanceState(outState);
     outState.PutString(BundledRegistrationInfo, JsonConvert.SerializeObject(this.personRegistrationInfo));
 }
Пример #34
0
 protected override void OnSaveInstanceState(Bundle outState)
 {
     outState.PutString("DrawerState", myDrawer.IsDrawerOpen((int)GravityFlags.Left) ? "Opened" : "Closed");
     base.OnSaveInstanceState(outState);
 }
Пример #35
0
        protected override void OnCreate(Bundle bundle)
        {
            sInstance = this;

            base.OnCreate(bundle);

#if MONOGAME_4_4
            _game = new Game1();
            SetContentView((View)_game.Services.GetService(typeof(View)));
#else
            Game1.Activity = this;
            _game          = new Game1();
            SetContentView(_game.Window);
#endif

            _ouyaInputView = new TV.Ouya.Sdk.OuyaInputView(this);

            View content = FindViewById(Android.Resource.Id.Content);
            if (null != content)
            {
                content.KeepScreenOn = true;
            }
            _game.Run();

            Bundle developerInfo = new Bundle();

            developerInfo.PutString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID);

            byte[] applicationKey = null;

            // load the application key from assets
            try {
                AssetManager        assetManager = ApplicationContext.Assets;
                AssetFileDescriptor afd          = assetManager.OpenFd(SIGNING_KEY);
                int size = 0;
                if (null != afd)
                {
                    size = (int)afd.Length;
                    afd.Close();
                    using (Stream inputStream = assetManager.Open(SIGNING_KEY, Access.Buffer))
                    {
                        applicationKey = new byte[size];
                        inputStream.Read(applicationKey, 0, size);
                        inputStream.Close();
                    }
                }
            } catch (Exception e) {
                Log.Error(TAG, string.Format("Failed to read application key exception={0}", e));
            }

            if (null != applicationKey)
            {
                Log.Debug(TAG, "Read signing key");
                developerInfo.PutByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, applicationKey);
            }
            else
            {
                Log.Error(TAG, "Failed to authorize with signing key");
                Finish();
                return;
            }

            //developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_ID, "0000000000000");
            //developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_KEY, "000000000000000000");

            //developerInfo.PutStringArray(OuyaFacade.OUYA_PRODUCT_ID_LIST, Game1.PURCHASABLES);

            _ouyaFacade = OuyaFacade.Instance;
            _ouyaFacade.Init(this, developerInfo);
        }
Пример #36
0
 public override void OnSaveInstanceState(Bundle outState)
 {
     outState.PutString(VIEWMODEL_ROUTE, ScreenRoute);
     base.OnSaveInstanceState(outState);
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //
            // Load the state either from a configuration change or from the intent.
            //
            state = LastNonConfigurationInstance as State;
            if (state == null && Intent.HasExtra("StateKey"))
            {
                var stateKey = Intent.GetStringExtra("StateKey");
                state = StateRepo.Remove(stateKey);
            }
            if (state == null)
            {
                Finish();
                return;
            }

            Title = state.Authenticator.Title;

            //
            // Watch for completion
            //
            state.Authenticator.Completed +=
                (s, e) =>
            {
                SetResult(e.IsAuthenticated ? Result.Ok : Result.Canceled);

                #region
                ///-------------------------------------------------------------------------------------------------
                /// Pull Request - manually added/fixed
                ///		Added IsAuthenticated check #88
                ///		https://github.com/xamarin/Xamarin.Auth.Compat/pull/88
                if (e.IsAuthenticated)
                {
                    if (state.Authenticator.GetAccountResult != null)
                    {
                        var accountResult = state.Authenticator.GetAccountResult(e.Account);

                        Bundle result = new Bundle();
                        result.PutString(global::Android.Accounts.AccountManager.KeyAccountType, accountResult.AccountType);
                        result.PutString(global::Android.Accounts.AccountManager.KeyAccountName, accountResult.Name);
                        result.PutString(global::Android.Accounts.AccountManager.KeyAuthtoken, accountResult.Token);
                        result.PutString(global::Android.Accounts.AccountManager.KeyAccountAuthenticatorResponse, e.Account.Serialize());

                        SetAccountAuthenticatorResult(result);
                    }
                }
                ///-------------------------------------------------------------------------------------------------
                #endregion

                Finish();
            };

            state.Authenticator.Error +=
                (s, e) =>
            {
                if (!state.Authenticator.ShowErrors)
                {
                    return;
                }

                if (e.Exception != null)
                {
                    this.ShowError("Authentication Error e.Exception = ", e.Exception);
                }
                else
                {
                    this.ShowError("Authentication Error e.Message = ", e.Message);
                }
                BeginLoadingInitialUrl();
            };

            //---------------------------------------------------------------------------------
            //
            // Build the UI
            //
            webView = new WebView(this)
            {
                Id = 42,
            };
            webView.Settings.UserAgentString = WebViewConfiguration.Android.UserAgent;
            Client web_view_client = new Client(this);  // UserAgent set in the class

            webView.Settings.JavaScriptEnabled = true;
            webView.SetWebViewClient(web_view_client);
            SetContentView(webView);

            //---------------------------------------------------------------------------------

            //
            // Restore the UI state or start over
            //
            if (savedInstanceState != null)
            {
                webView.RestoreState(savedInstanceState);
            }
            else
            {
                if (Intent.GetBooleanExtra("ClearCookies", true))
                {
                    WebAuthenticator.ClearCookies();
                }

                BeginLoadingInitialUrl();
            }

            return;
        }
Пример #38
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddApi(LocationServices.API)
                              .AddConnectionCallbacks(this)
                              .AddOnConnectionFailedListener(this)
                              .Build();
            googleApiClient.Connect();

            if (IsThereAnAppToTakePictures())
            {
                CreateDirectoryForPictures();
            }

            FragmentManager.BeginTransaction().Add(Resource.Id.gmap, new WelcomePage()).Commit();
            ImageButton map = FindViewById <ImageButton>(Resource.Id.map);

            map.Click += delegate
            {
                if (_mapFragment == null)
                {
                    InitMap();
                }
                else
                {
                    FragmentManager.BeginTransaction().Replace(Resource.Id.gmap, _mapFragment, "map").Commit();
                    _mapFragment.GetMapAsync(this);
                }
            };

            ImageButton camera = FindViewById <ImageButton>(Resource.Id.camera);

            camera.Click += delegate
            {
                pictureTaken = new PictureTaken();

                Bundle mybundle2 = new Bundle();
                CreateDirectoryForPictures();
                if (App._dir.ListFiles().Length == 0)
                {
                    mybundle2.PutString("path", "null");
                }
                else
                {
                    Java.IO.File newfile = App._dir.ListFiles()[App._dir.ListFiles().Length - 1];
                    mybundle2.PutString("path", newfile.Path.ToString());
                }

                pictureTaken.Arguments = mybundle2;

                FragmentManager.BeginTransaction().Replace(Resource.Id.gmap, pictureTaken, "slika").Commit();
                Intent intent = new Intent(MediaStore.ActionImageCapture);
                App._file = new Java.IO.File(App._dir, System.String.Format("report_{0}.jpg", Guid.NewGuid()));
                intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(App._file));
                StartActivityForResult(intent, 0);
            };

            ImageButton can = FindViewById <ImageButton>(Resource.Id.can);

            can.Click += delegate
            {
                _pictures = new Pictures();
                Bundle mybundle = new Bundle();
                CreateDirectoryForPictures();
                if (App._dir.ListFiles().Length == 0)
                {
                    mybundle.PutString("path", "null");
                }
                else
                {
                    Java.IO.File newfile = App._dir.ListFiles()[App._dir.ListFiles().Length - 1];
                    mybundle.PutString("path", newfile.Path.ToString());
                }

                mybundle.PutString("lon", _currentLocation.Longitude.ToString());
                mybundle.PutString("lat", _currentLocation.Latitude.ToString());


                _pictures.Arguments = mybundle;
                FragmentManager.BeginTransaction().Replace(Resource.Id.gmap, _pictures, "pictures").Commit();
            };

            ImageButton help = FindViewById <ImageButton>(Resource.Id.help) as ImageButton;

            help.Click += delegate
            {
                HelpPage hp = new HelpPage();
                FragmentManager.BeginTransaction().Replace(Resource.Id.gmap, hp, "help").Commit();
            };

            ImageButton welcome = FindViewById <ImageButton>(Resource.Id.first) as ImageButton;

            welcome.Click += delegate
            {
                WelcomePage wp = new WelcomePage();
                FragmentManager.BeginTransaction().Replace(Resource.Id.gmap, wp, "help").Commit();
            };
        }
Пример #39
0
        void OnClickAccept(object sender, EventArgs e)
        {
            if ((DateTime.Now.Date == Date && (DateTime.Now.Hour > Hour || DateTime.Now.Hour == Hour && DateTime.Now.Minute >= Minute)) || DateTime.Now.Date > Date) //If current date, check hour is not less current hour, and if current date and hour, check minute
            {
                Toast toast = Toast.MakeText(Context, "Нельзя установить прошедшее время или дату.", ToastLength.Short);
                toast.Show();
            }
            else
            {
                Id = SqlHelper.SaveText(Editable, Args);

                if (Args == null)
                {
                    Args = new Bundle();
                    Args.PutString("_id", Id.ToString());
                }
                cursor  = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + Id.ToString()), null);
                Content = Multitools.GetNameNote(Editable.ToString().Split("\n")[0], cursor);
                Calendar calendar = Calendar.Instance;

                calendar.Set(CalendarField.Year, Date.Year);
                calendar.Set(CalendarField.Month, Date.Month - 1);
                calendar.Set(CalendarField.DayOfMonth, Date.Day);
                calendar.Set(CalendarField.HourOfDay, Hour);
                calendar.Set(CalendarField.Minute, Minute);
                calendar.Set(CalendarField.Second, 0);
                NotifyManager notify = new NotifyManager();
                alarm  = (Android.App.AlarmManager)Context.GetSystemService(Context.AlarmService);
                intent = new Intent(Context, typeof(NotifyManager));

                intent.PutExtra("_id", Id);
                intent.PutExtra("message", Content);
                //ChangeIntent(Context);
                pendingIntent = Android.App.PendingIntent.GetBroadcast(Context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);



                if (Convert.ToInt32(Build.VERSION.Sdk) >= 19)
                {
                    alarm.SetExact(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }
                else
                {
                    alarm.Set(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }

                ContentValues cv = new ContentValues();
                cv.Put(Databasehelper.COLUMN_NOTIFY, 1);
                cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.START_ID, uniqueId);
                //cv.Put(Databasehelper.NEW_ID, Id); //While id is identific

                Db.Update(Databasehelper.TEXTTABLE, cv, "_id=?", new string[] { Id.ToString() });
                //PrefsEditor.PutBoolean(Id.ToString(), true);
                //PrefsEditor.Apply();


                Dialog.Cancel();
            }
        }
Пример #40
0
        private static async Task UpdateDayBeforeNotification(AccountDataItem account, AgendaViewItemsGroup agendaItems, Context context, NotificationManager notificationManager, bool fromForeground)
        {
            string tag = account.LocalAccountId.ToString();

            // If no current semester, or no items, then just clear
            if (agendaItems == null || agendaItems.Items.Count == 0)
            {
                notificationManager.Cancel(tag, NotificationIds.DAY_BEFORE_NOTIFICATION);
                return;
            }

            StatusBarNotification existing;

            if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                existing = notificationManager.GetActiveNotifications().FirstOrDefault(i => i.Id == NotificationIds.DAY_BEFORE_NOTIFICATION && i.Tag.Equals(tag));
            }
            else
            {
                // GetActiveNotifications didn't exist till API 23
                existing = null;
            }

            const string EXTRA_UNIQUE_ID = "UniqueId";

            DateTime now = DateTime.Now;

            DateTime reminderTime = RemindersExtension.GetDayBeforeReminderTime(now.Date, account, agendaItems);

            bool sendingDueTomorrow = now >= reminderTime;

            NotificationCompat.Builder builder;

            if (sendingDueTomorrow)
            {
                var itemsDueTomorrow = agendaItems.Items.Where(i => i.Date.Date == now.Date.AddDays(1)).OrderBy(i => i).ToArray();

                // If nothing tomorrow, we clear
                if (itemsDueTomorrow.Length == 0)
                {
                    notificationManager.Cancel(tag, NotificationIds.DAY_BEFORE_NOTIFICATION);
                    return;
                }

                string extraUniqueId = "DueTomorrow" + string.Join(";", itemsDueTomorrow.Select(i => i.Name)).GetHashCode();

                // If already updated
                if (existing != null && existing.Notification.Extras.GetString(EXTRA_UNIQUE_ID).Equals(extraUniqueId))
                {
                    return;
                }

                // If all the items have been updated more recently than the reminder time, we won't show a new notification
                if (existing == null && itemsDueTomorrow.All(i => i.Updated.ToLocalTime() > reminderTime))
                {
                    return;
                }

                // If we already sent the notification today
                if (account.DateLastDayBeforeReminderWasSent.Date == now.Date)
                {
                    // If the notification has been dismissed, do nothing
                    if (existing == null)
                    {
                        return;
                    }
                }

                // Otherwise we need to update the date that it was sent
                else
                {
                    account.DateLastDayBeforeReminderWasSent = now;
                    await AccountsManager.Save(account);
                }

                if (existing == null && fromForeground)
                {
                    return;
                }

                builder = CreateReminderBuilderForDayBefore(context, account.LocalAccountId);
                Bundle b = new Bundle();
                b.PutString(EXTRA_UNIQUE_ID, extraUniqueId);
                builder.SetExtras(b);
                // "Due tomorrow"
                builder.SetContentTitle(PowerPlannerResources.GetDueX(PowerPlannerResources.GetRelativeDateTomorrow().ToLower()));
                PopulateNotificationDayBeforeWithItems(builder, itemsDueTomorrow);
            }

            // Otherwise "due today"
            else
            {
                var itemsDueToday = agendaItems.Items.Where(i => i.Date.Date == now.Date).OrderBy(i => i).ToArray();

                // If nothing left today, we clear
                if (itemsDueToday.Length == 0)
                {
                    notificationManager.Cancel(tag, NotificationIds.DAY_BEFORE_NOTIFICATION);
                    return;
                }

                string extraUniqueId = "DueToday" + string.Join(";", itemsDueToday.Select(i => i.Name)).GetHashCode();

                // If already updated
                if (existing != null && existing.Notification.Extras.GetString(EXTRA_UNIQUE_ID).Equals(extraUniqueId))
                {
                    return;
                }

                // If the notification doesn't currently exist (user potentially dismissed it) and we've already sent either yesterday or today
                if (existing == null && account.DateLastDayBeforeReminderWasSent.Date == DateTime.Today.AddDays(-1) || account.DateLastDayBeforeReminderWasSent.Date == DateTime.Today)
                {
                    return;
                }

                // If all the items have been updated more recently than the reminder time, we won't show a new notification
                if (existing == null && itemsDueToday.All(i => i.Updated.ToLocalTime() > reminderTime))
                {
                    return;
                }

                // If we already sent the notification yesterday
                if (account.DateLastDayBeforeReminderWasSent.Date == now.Date.AddDays(-1))
                {
                    // If the notification has been dismissed, do nothing
                    if (existing == null)
                    {
                        return;
                    }
                }

                // Otherwise we need to update the date that it was sent
                else
                {
                    account.DateLastDayBeforeReminderWasSent = now.Date.AddDays(-1);
                    await AccountsManager.Save(account);
                }

                if (existing == null && fromForeground)
                {
                    return;
                }

                builder = CreateReminderBuilderForDayBefore(context, account.LocalAccountId);
                Bundle b = new Bundle();
                b.PutString(EXTRA_UNIQUE_ID, extraUniqueId);
                builder.SetExtras(b);
                // "Due today"
                builder.SetContentTitle(PowerPlannerResources.GetDueX(PowerPlannerResources.GetRelativeDateToday().ToLower()));
                PopulateNotificationDayBeforeWithItems(builder, itemsDueToday);
            }

            notificationManager.Notify(tag, NotificationIds.DAY_BEFORE_NOTIFICATION, BuildReminder(builder));
        }
Пример #41
0
        protected override void OnHandleIntent(Intent intent)
        {
            Log.Debug(TAG, "onHandleIntent(intent=" + intent.ToString() + ")");

            ResultReceiver receiver = (ResultReceiver)intent.GetParcelableExtra(EXTRA_STATUS_RECEIVER);

            if (receiver != null)
            {
                receiver.Send(StatusRunning, Bundle.Empty);
            }

            Context context      = this;
            var     prefs        = GetSharedPreferences(Prefs.IOSCHED_SYNC, FileCreationMode.Private);
            int     localVersion = prefs.GetInt(Prefs.LOCAL_VERSION, VERSION_NONE);

            try {
                // Bulk of sync work, performed by executing several fetches from
                // local and online sources.

                long startLocal = Java.Lang.JavaSystem.CurrentTimeMillis();
                bool localParse = localVersion < VERSION_CURRENT;
                Log.Debug(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT);
                if (localParse)
                {
                    // Load static local data
                    mLocalExecutor.Execute(Resource.Xml.blocks, new LocalBlocksHandler());
                    mLocalExecutor.Execute(Resource.Xml.rooms, new LocalRoomsHandler());
                    mLocalExecutor.Execute(Resource.Xml.tracks, new LocalTracksHandler());
                    mLocalExecutor.Execute(Resource.Xml.search_suggest, new LocalSearchSuggestHandler());
                    mLocalExecutor.Execute(Resource.Xml.sessions, new LocalSessionsHandler());

                    // Parse values from local cache first, since spreadsheet copy
                    // or network might be down.
//	                mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler());
//	                mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler());
//	                mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler());

                    // Save local parsed version
                    prefs.Edit().PutInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).Commit();
                }

                Log.Debug(TAG, "local sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startLocal) + "ms");

                // Always hit remote spreadsheet for any updates
                long startRemote = Java.Lang.JavaSystem.CurrentTimeMillis();
//		        mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor));
                Log.Debug(TAG, "remote sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startRemote) + "ms");
            } catch (Exception e) {
                Log.Error(TAG, "Problem while syncing", e);

                if (receiver != null)
                {
                    // Pass back error to surface listener
                    Bundle bundle = new Bundle();
                    bundle.PutString(Intent.ExtraText, e.ToString());
                    receiver.Send(StatusError, bundle);
                }
            }

            // Announce success to any surface listener
            Log.Debug(TAG, "sync finished");
            if (receiver != null)
            {
                receiver.Send(StatusFinished, Bundle.Empty);
            }
        }
Пример #42
0
 public override void OnSaveInstanceState(Bundle outState)
 {
     base.OnSaveInstanceState(outState);
     outState.PutString(KeyContent, _content);
 }
Пример #43
0
        protected override IEnumerable <Datum> Poll(CancellationToken cancellationToken)
        {
            List <Datum> data = new List <Datum>();

            if (HasValidAccessToken)
            {
                // prompt user for any missing permissions
                ICollection <string> missingPermissions = GetRequiredPermissionNames().Where(p => !AccessToken.CurrentAccessToken.Permissions.Contains(p)).ToArray();
                if (missingPermissions.Count > 0)
                {
                    _loginWait.Reset();

                    (AndroidSensusServiceHelper.Get() as AndroidSensusServiceHelper).GetMainActivityAsync(true, mainActivity =>
                    {
                        if (mainActivity == null)
                        {
                            _loginWait.Set();
                        }
                        else
                        {
                            mainActivity.RunOnUiThread(() =>
                            {
                                LoginManager.Instance.LogInWithReadPermissions(mainActivity, missingPermissions);
                            });
                        }
                    });

                    _loginWait.WaitOne();
                }

                GraphRequestBatch graphRequestBatch = new GraphRequestBatch();

                foreach (Tuple <string, List <string> > edgeFieldQuery in GetEdgeFieldQueries())
                {
                    Bundle parameters = new Bundle();

                    if (edgeFieldQuery.Item2.Count > 0)
                    {
                        parameters.PutString("fields", string.Concat(edgeFieldQuery.Item2.Select(field => field + ",")).Trim(','));
                    }

                    GraphRequest request = new GraphRequest(
                        AccessToken.CurrentAccessToken,
                        "/me" + (edgeFieldQuery.Item1 == null ? "" : "/" + edgeFieldQuery.Item1),
                        parameters,
                        HttpMethod.Get);

                    graphRequestBatch.Add(request);
                }

                if (graphRequestBatch.Size() == 0)
                {
                    SensusServiceHelper.Get().Logger.Log("Facebook request batch contained zero requests.", LoggingLevel.Normal, GetType());
                }
                else
                {
                    foreach (GraphResponse response in graphRequestBatch.ExecuteAndWait())
                    {
                        if (response.Error == null)
                        {
                            FacebookDatum datum = new FacebookDatum(DateTimeOffset.UtcNow);

                            JSONObject responseJSON = response.JSONObject;
                            JSONArray  jsonFields   = responseJSON.Names();
                            bool       valuesSet    = false;
                            for (int i = 0; i < jsonFields.Length(); ++i)
                            {
                                string jsonField = jsonFields.GetString(i);

                                PropertyInfo property;
                                if (FacebookDatum.TryGetProperty(jsonField, out property))
                                {
                                    object value = null;

                                    if (property.PropertyType == typeof(string))
                                    {
                                        value = responseJSON.GetString(jsonField);
                                    }
                                    else if (property.PropertyType == typeof(bool?))
                                    {
                                        value = responseJSON.GetBoolean(jsonField);
                                    }
                                    else if (property.PropertyType == typeof(DateTimeOffset?))
                                    {
                                        value = DateTimeOffset.Parse(responseJSON.GetString(jsonField));
                                    }
                                    else if (property.PropertyType == typeof(List <string>))
                                    {
                                        List <string> values     = new List <string>();
                                        JSONArray     jsonValues = responseJSON.GetJSONArray(jsonField);
                                        for (int j = 0; j < jsonValues.Length(); ++j)
                                        {
                                            values.Add(jsonValues.GetString(j));
                                        }

                                        value = values;
                                    }
                                    else
                                    {
                                        throw new SensusException("Unrecognized FacebookDatum property type:  " + property.PropertyType.ToString());
                                    }

                                    if (value != null)
                                    {
                                        property.SetValue(datum, value);
                                        valuesSet = true;
                                    }
                                }
                                else
                                {
                                    SensusServiceHelper.Get().Logger.Log("Unrecognized JSON field in Facebook query response:  " + jsonField, LoggingLevel.Verbose, GetType());
                                }
                            }

                            if (valuesSet)
                            {
                                data.Add(datum);
                            }
                        }
                        else
                        {
                            SensusServiceHelper.Get().Logger.Log("Error received while querying Facebook graph API:  " + response.Error.ErrorMessage, LoggingLevel.Normal, GetType());
                        }
                    }
                }
            }
            else
            {
                SensusServiceHelper.Get().Logger.Log("Attempted to poll Facebook probe without a valid access token.", LoggingLevel.Normal, GetType());
            }

            return(data);
        }
Пример #44
0
 public override void OnSaveInstanceState(Bundle outState)
 {
     base.OnSaveInstanceState(outState);
     outState.PutString("tState", tView.SaveState);
 }
 public override void OnSaveInstanceState(Bundle outState)
 {
     outState.PutString("projectName", _project.Name);
     base.OnSaveInstanceState(outState);
 }
Пример #46
0
 protected override void OnSaveInstanceState(Bundle outState)
 {
     base.OnSaveInstanceState(outState);
     outState.PutString("username", MainDatabase.Username);
     outState.PutString("selectedpharmacyuuid", SelectedPharmacyUUID);
 }
Пример #47
0
        private void setupViewPager()
        {
            mainPagerAdapter = new MainPagerAdapter(ChildFragmentManager);
            int             current    = 0;
            List <Property> properties = UserSettings.Current.SelectedProperties;

            if (properties.Count == 0)
            {
                properties.Add(StandardProperty.none);
            }
            var props = UserSettings.Current.SelectedProperties;

            if (props.Count == 1 &&
                props.FirstOrDefault().ID == "00")
            {
                var    prop     = props.FirstOrDefault();
                var    fragment = new JournalFragment();
                Bundle bundle   = new Bundle();
                bundle.PutString("date", Navigate.selectedDate.ToStorageStringDate());
                bundle.PutString("property", prop.ID);
                fragment.Arguments = bundle;
                current            = mainPagerAdapter.Count;
                mainPagerAdapter.addFragment(fragment, GetString(Resource.String.NoGoalsTitle));
            }
            else
            {
                foreach (var property in props.Where(a => a.ID != "00").ToList())
                {
                    var    fragment = new JournalFragment();
                    Bundle bundle   = new Bundle();
                    bundle.PutString("date", Navigate.selectedDate.ToStorageStringDate());
                    bundle.PutString("property", property.ID);

                    fragment.Arguments = bundle;
                    if (UserSettings.Current.CurrentProperty == property)
                    {
                        current = mainPagerAdapter.Count;
                    }
                    mainPagerAdapter.addFragment(fragment, property.TextOnly);
                }
            }

            try
            {
                if (viewPager.Adapter == null)
                {
                    viewPager.AddOnPageChangeListener(this);
                }
                viewPager.Adapter = mainPagerAdapter;
                tabLayout.SetupWithViewPager(viewPager);
                tabLayout.TabMode = TabLayout.ModeScrollable;
            }
            catch (Exception ex)
            {
                throw;
            }

            viewPager.SetCurrentItem(current, false);

            InputMethodManager imm = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService);

            imm.HideSoftInputFromWindow(viewPager.WindowToken, 0);

            SessionLog.EndPerformance("Navigate");
        }
 protected override void OnSaveInstanceState(Bundle savedInstanceState)
 {
     savedInstanceState.PutBoolean(AddressRequestedKey, mAddressRequested);
     savedInstanceState.PutString(LocationAddressKey, mAddressOutput);
     base.OnSaveInstanceState(savedInstanceState);
 }
Пример #49
0
        public static async void SendNotifications(List <CustomNotification> notificationList)
        {
            await Task.Run(() =>
            {
                try
                {
                    if (_notificationManager == null)
                    {
                        _notificationManager = Android.Support.V4.App.NotificationManagerCompat.From(Android.App.Application.Context);
                    }
                    if (notificationList.Count == 0)
                    {
                        return;
                    }
                    int notePos = 0;

                    foreach (var note in notificationList)
                    {
                        var resultIntent      = new Intent(Android.App.Application.Context, typeof(MainActivity));
                        var valuesForActivity = new Bundle();
                        valuesForActivity.PutInt(MainActivity.COUNT_KEY, _count);
                        valuesForActivity.PutString("URL", note.NoteLink);
                        resultIntent.SetAction(MainPlaybackSticky.ActionLoadUrl);
                        resultIntent.PutExtras(valuesForActivity);
                        var resultPendingIntent = PendingIntent.GetActivity(Android.App.Application.Context, MainActivity.NOTIFICATION_ID, resultIntent, PendingIntentFlags.UpdateCurrent);
                        resultIntent.AddFlags(ActivityFlags.SingleTop);
                        var alarmAttributes = new Android.Media.AudioAttributes.Builder()
                                              .SetContentType(Android.Media.AudioContentType.Sonification)
                                              .SetUsage(Android.Media.AudioUsageKind.Notification).Build();

                        if (!_sentNotificationList.Contains(note) && notePos == 0)
                        {
                            var builder = new Android.Support.V4.App.NotificationCompat.Builder(Android.App.Application.Context, MainActivity.CHANNEL_ID + 1)
                                          .SetAutoCancel(true)                   // Dismiss the notification from the notification area when the user clicks on it
                                          .SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
                                          .SetContentTitle(note.NoteText)
                                          .SetNumber(1)
                                          .SetSmallIcon(Resource.Drawable.bitchute_notification2)
                                          .SetContentText(note.NoteType)
                                          .SetPriority(Android.Support.V4.App.NotificationCompat.PriorityMin);

                            MainActivity.NOTIFICATION_ID++;
                            // publish the notification:
                            //var notificationManager = Android.Support.V4.App.NotificationManagerCompat.From(_ctx);
                            _notificationManager.Notify(MainActivity.NOTIFICATION_ID, builder.Build());
                            _sentNotificationList.Add(note);
                            notePos++;
                        }
                        else if (!_sentNotificationList.Contains(note))
                        {
                            var builder = new Android.Support.V4.App.NotificationCompat.Builder(Android.App.Application.Context, MainActivity.CHANNEL_ID)
                                          .SetAutoCancel(true)                   // Dismiss the notification from the notification area when the user clicks on it
                                          .SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
                                          .SetContentTitle(note.NoteText)        // Set the title
                                          .SetNumber(1)                          // Display the count in the Content Info
                                                                                 //.SetLargeIcon(_notificationBMP) // This is the icon to display
                                          .SetSmallIcon(Resource.Drawable.bitchute_notification2)
                                          .SetContentText(note.NoteType)
                                          .SetPriority(Android.Support.V4.App.NotificationCompat.PriorityLow);

                            MainActivity.NOTIFICATION_ID++;

                            // publish the notification:
                            //var notificationManager = Android.Support.V4.App.NotificationManagerCompat.From(_ctx);
                            _notificationManager.Notify(MainActivity.NOTIFICATION_ID, builder.Build());
                            _sentNotificationList.Add(note);
                            notePos++;
                        }
                        MainPlaybackSticky.NotificationsHaveBeenSent = true;
                    }
                }
                catch { }
            });
        }
Пример #50
0
        private static void UpdateDayOfNotification(Guid localAccountId, BaseViewItemHomeworkExam item, DateTime dayOfReminderTime, Context context, NotificationManager notificationManager, List <StatusBarNotification> existingNotifs, bool fromForeground)
        {
            ViewItemClass c = item.GetClassOrNull();

            if (c == null)
            {
                return;
            }

            string tag      = localAccountId.ToString() + ";" + item.Identifier.ToString();
            var    existing = existingNotifs.FirstOrDefault(i => i.Tag.Equals(tag));

            // If the reminder has already been sent and the notification doesn't exist,
            // that means the user dismissed it, so don't show it again
            if (item.HasSentReminder && existing == null)
            {
                return;
            }

            // If there's no existing notification, and the updated time is greater than the desired reminder time,
            // then it was edited after the notification should have been sent, so don't notify, since user was already
            // aware of this item (by the fact that they were editing it)
            if (existing == null && item.Updated.ToLocalTime() > dayOfReminderTime)
            {
                return;
            }

            if (existing == null && fromForeground)
            {
                return;
            }

            const string EXTRA_UNIQUE_ID = "UniqueId";
            string       extraUniqueId   = (item.Name + ";" + c.Name).GetHashCode().ToString();

            // If there's an existing, and it hasn't changed, do nothing
            if (existing != null && existing.Notification.Extras.GetString(EXTRA_UNIQUE_ID).Equals(extraUniqueId))
            {
                return;
            }

            BaseArguments launchArgs;

            if (item is ViewItemHomework)
            {
                launchArgs = new ViewHomeworkArguments()
                {
                    LocalAccountId = localAccountId,
                    ItemId         = item.Identifier,
                    LaunchSurface  = LaunchSurface.Toast
                };
            }
            else
            {
                launchArgs = new ViewExamArguments()
                {
                    LocalAccountId = localAccountId,
                    ItemId         = item.Identifier,
                    LaunchSurface  = LaunchSurface.Toast
                };
            }

            var    builder = CreateReminderBuilder(context, localAccountId, launchArgs);
            Bundle b       = new Bundle();

            b.PutString(EXTRA_UNIQUE_ID, extraUniqueId);
            builder.SetExtras(b);
            builder.SetContentTitle(item.Name);
            builder.SetChannelId(GetChannelIdForDayOf(localAccountId));
            string subtitle = item.GetSubtitleOrNull();

            if (subtitle != null)
            {
                builder.SetContentText(subtitle);
            }
            notificationManager.Notify(tag, NotificationIds.DAY_OF_NOTIFICATIONS, BuildReminder(builder));
        }
Пример #51
0
 public EditTimeEntryFragment(TimeEntryData timeEntry)
 {
     Arguments = new Bundle();
     Arguments.PutString(TimeEntryIdArgument, timeEntry.Id.ToString());
     viewModel = new EditTimeEntryView(timeEntry);
 }
Пример #52
0
        async void RequestData(Dictionary <string, object> pDictionary)
        {
            //string path,Bundle parameters = null,HttpMethod method = null,string version = null
            string path    = $"{pDictionary["path"]}";
            string version = $"{pDictionary["version"]}";
            Dictionary <string, string> parameters = pDictionary["parameters"] as Dictionary <string, string>;


            FacebookHttpMethod?method = pDictionary["method"] as FacebookHttpMethod?;
            var currentTcs            = _requestTcs;
            var _onEvent   = _onRequestData;
            var httpMethod = HttpMethod.Get;

            if (method != null)
            {
                switch (method)
                {
                case FacebookHttpMethod.Get:
                    httpMethod = HttpMethod.Get;
                    break;

                case FacebookHttpMethod.Post:
                    httpMethod = HttpMethod.Post;
                    _onEvent   = _onPostData;
                    currentTcs = _postTcs;
                    break;

                case FacebookHttpMethod.Delete:
                    httpMethod = HttpMethod.Delete;
                    _onEvent   = _onDeleteData;
                    currentTcs = _deleteTcs;
                    break;
                }
            }

            if (string.IsNullOrEmpty(path))
            {
                var fbResponse = new FBEventArgs <string>(null, FacebookActionStatus.Error, "Graph query path not specified");
                _onEvent?.Invoke(CrossFacebookClient.Current, fbResponse);
                currentTcs?.TrySetResult(new FacebookResponse <string>(fbResponse));
                return;
            }

            if (AccessToken.CurrentAccessToken != null)
            {
                GraphRequest request = new GraphRequest(AccessToken.CurrentAccessToken, path);

                request.Callback   = this;
                request.HttpMethod = httpMethod;

                if (parameters != null)
                {
                    Bundle bundle = new Bundle();
                    foreach (var p in parameters)
                    {
                        if (!string.IsNullOrEmpty(p.Key) && !string.IsNullOrEmpty(p.Value))
                        {
                            bundle.PutString($"{p.Key}", $"{p.Value}");
                        }
                    }
                    request.Parameters = bundle;
                }

                if (!string.IsNullOrEmpty(version))
                {
                    request.Version = version;
                }

                request.ExecuteAsync();
            }
            else
            {
                var fbResponse = new FBEventArgs <string>(null, FacebookActionStatus.Unauthorized, "Facebook operation not authorized, be sure you requested the right permissions");
                _onEvent?.Invoke(CrossFacebookClient.Current, fbResponse);
                currentTcs?.TrySetResult(new FacebookResponse <string>(fbResponse));
            }
        }
Пример #53
0
 protected override void OnSaveInstanceState(Bundle outState)
 {
     outState.PutString(BundledStatuses, JsonConvert.SerializeObject(_statuses));
     outState.PutString(BundledCustomerId, _currentCustomerId.ToString());
     base.OnSaveInstanceState(outState);
 }
 protected override void OnSaveInstanceState(Bundle outState)
 {
     outState?.PutString("communityID", CommunityID);
     base.OnSaveInstanceState(outState);
 }
Пример #55
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.layout_resetpin);

            var trans = GetFragmentManager().BeginTransaction();

            // TODO check why this exists
            alertinfo = new CustomDialogFragment(
                string.Empty,
                this.GetString(Resource.String.pin_reset_no_internet),
                this.GetString(Resource.String.go_back), null, null);

            string dealerSupportLine = Settings.Instance.DealerSupportLine;

            CustomInfoFragment.Info info = new CustomInfoFragment.Info
            {
                ActionBarTitle        = Resources.GetString(Resource.String.pin_reset_fail_title),
                Title                 = Resources.GetString(Resource.String.pin_reset_fail_title),
                Content               = string.Format(Resources.GetString(Resource.String.pin_reset_fail_msg), dealerSupportLine),
                PositiveButtonCaption = Resources.GetString(Resource.String.try_again),
                NegativeButtonCaption = Resources.GetString(Resource.String.cancel_reset)
            };

            resetPinFailedFragment = new CustomInfoFragment();
            resetPinFailedFragment.SetArgument(CustomInfoFragment.InfoKey, info);

            // set event handlers for failed pin
            resetPinFailedFragment.PositiveAction += new CustomInfoFragment.BtnClick(go);
            resetPinFailedFragment.NegativeAction += new CustomInfoFragment.BtnClick(GoBackToLogin);

            // register fragment
            trans.Add(Resource.Id.reset_pin_placeholder, resetPinFailedFragment, RESETPINFAILED_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(resetPinFailedFragment);

            CustomInfoFragment.Info infoSuccess = new CustomInfoFragment.Info()
            {
                ActionBarTitle        = Resources.GetString(Resource.String.pin_reset_done),
                Title                 = Resources.GetString(Resource.String.pin_reset_done),
                Content               = Resources.GetString(Resource.String.pin_reset_success_msg),
                PositiveButtonCaption = Resources.GetString(Resource.String.back_to_login)
            };

            resetPinResultInfoFragment = new CustomInfoFragment();
            resetPinResultInfoFragment.SetArgument(CustomInfoFragment.InfoKey, infoSuccess);

            resetPinResultInfoFragment.PositiveAction += new CustomInfoFragment.BtnClick(GoBackToLogin);

            trans.Add(Resource.Id.reset_pin_placeholder, resetPinResultInfoFragment, RESETPINRESULT_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(resetPinResultInfoFragment);

            fragmentResetPin = new ResetPinFragment();
            fragmentResetPin.ButtonNextClicked += fragmentResetPin_ButtonNextClicked;
            trans.Add(Resource.Id.reset_pin_placeholder, fragmentResetPin, RESETPIN_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(fragmentResetPin);

            progressFragment = new ProgressFragment();
            Bundle arguments = new Bundle();

            arguments.PutString(ProgressFragment.TitleKey, GetString(Resource.String.reset_pin_title));
            arguments.PutString(ProgressFragment.MessageKey, GetString(Resource.String.resetting_pin));
            progressFragment.Arguments = arguments;
            trans.Add(Resource.Id.reset_pin_placeholder, progressFragment, RESETPINPROGRESS_FRAGMENT_TAG);
            trans.AddToBackStack(null);

            trans.Commit();
            go();
            // TODO check why we are adding all the fragments to start with and not only when needed
        }
Пример #56
0
 public void onSaveInstanceState(Bundle outState)
 {
     outState.PutCharSequence("undo_message", mUndoMessage);
     outState.PutString("undo_token", JsonConvert.SerializeObject(mUndoToken));
 }
Пример #57
0
        private void SetProfileConfig(DWProfileSetConfigSettings settings)
        {
            // (Re)Configuration du profil via l'intent SET_PROFILE
            // NB : on peut envoyer cet intent sans soucis même si le profil est déjà configuré
            Bundle profileConfig = new Bundle();

            profileConfig.PutString("PROFILE_NAME", settings.ProfileName);
            profileConfig.PutString("PROFILE_ENABLED", "true");
            profileConfig.PutString("CONFIG_MODE", "UPDATE");

            // Configuration des applications du profil
            Bundle appConfig = new Bundle();

            appConfig.PutString("PACKAGE_NAME", mContext.PackageName);
            appConfig.PutStringArray("ACTIVITY_LIST", new String[] { "*" });
            profileConfig.PutParcelableArray("APP_LIST", new Bundle[] { appConfig });

            // Configuration des différents plugins
            List <IParcelable> pluginConfigs = new List <IParcelable>();

            // Configuration du plugin BARCODE
            Bundle barcodePluginConfig = new Bundle();

            barcodePluginConfig.PutString("PLUGIN_NAME", "BARCODE");
            barcodePluginConfig.PutString("RESET_CONFIG", "true");

            Bundle barcodeProps = new Bundle();

            barcodeProps.PutString("aim_mode", "on");
            barcodeProps.PutString("lcd_mode", "3");

            // Use this for Datawedge < 6.7
            //barcodeProps.putString("scanner_selection", "auto");

            // Use this for Datawedge >= 6.7
            barcodeProps.PutString("scanner_selection_by_identifier", "INTERNAL_IMAGER");

            if (settings.AggressiveMode)
            {
                // Super aggressive continuous mode without beam timer and no timeouts
                barcodeProps.PutString("aim_type", "5");
                barcodeProps.PutInt("beam_timer", 0);
                barcodeProps.PutString("different_barcode_timeout", "0");
                barcodeProps.PutString("same_barcode_timeout", "0");
            }
            else
            {
                // Standard mode with beam timer and same/different timeout
                barcodeProps.PutString("aim_type", "3");
                barcodeProps.PutInt("beam_timer", 5000);
                barcodeProps.PutString("different_barcode_timeout", "500");
                barcodeProps.PutString("same_barcode_timeout", "500");
            }
            barcodePluginConfig.PutBundle("PARAM_LIST", barcodeProps);
            pluginConfigs.Add(barcodePluginConfig);


            // Configuration du plugin KEYSTROKE
            Bundle keystrokePluginConfig = new Bundle();

            keystrokePluginConfig.PutString("PLUGIN_NAME", "KEYSTROKE");
            keystrokePluginConfig.PutString("RESET_CONFIG", "true");
            Bundle keystrokeProps = new Bundle();

            keystrokeProps.PutString("keystroke_output_enabled", "false");
            keystrokePluginConfig.PutBundle("PARAM_LIST", keystrokeProps);
            pluginConfigs.Add(keystrokePluginConfig);

            // Configuration du plugin INTENT
            Bundle intentPluginConfig = new Bundle();

            intentPluginConfig.PutString("PLUGIN_NAME", "INTENT");
            intentPluginConfig.PutString("RESET_CONFIG", "true");
            Bundle intentProps = new Bundle();

            intentProps.PutString("intent_output_enabled", "true");
            intentProps.PutString("intent_action", settings.IntentAction);
            intentProps.PutString("intent_category", settings.IntentCategory);
            intentProps.PutString("intent_delivery", "2");
            intentPluginConfig.PutBundle("PARAM_LIST", intentProps);
            pluginConfigs.Add(intentPluginConfig);

            // Envoi d'intent de configuration du profil
            profileConfig.PutParcelableArrayList("PLUGIN_CONFIG", pluginConfigs);

            SendDataWedgeIntentWithExtraRequestResult(DataWedgeConstants.ACTION_DATAWEDGE_FROM_6_2,
                                                      DataWedgeConstants.EXTRA_SET_CONFIG,
                                                      profileConfig);
        }
Пример #58
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.circuit_breaker_fragment, null);

            _circuitbreakerPanel6LinearLayout    = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel6LinearLayout);
            _circuitbreakerPanel61LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel61LinearLayout);
            _circuitbreakerPanel62LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel62LinearLayout);
            _circuitbreakerPanel63LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel63LinearLayout);
            _circuitbreakerPanel64LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel64LinearLayout);
            _circuitbreakerPanel611LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel611LinearLayout);
            _circuitbreakerPanel612LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel612LinearLayout);
            _circuitbreakerPanel180LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel180LinearLayout);
            _circuitbreakerPanel181LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel181LinearLayout);
            _circuitbreakerPanel182LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel182LinearLayout);
            _circuitbreakerPanel183LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel183LinearLayout);
            _circuitbreakerEECompartmentTextView = view.FindViewById <TextView>(Resource.Id.circuitbreakerEECompartmentTextView);
            _circuitbreakerSearchView            = view.FindViewById <Android.Widget.SearchView>(Resource.Id.circuitbreakerSearchView);
            _circuitBreakerRecyclerView          = view.FindViewById <RecyclerView>(Resource.Id.circuitBreakerRecyclerView);
            var layoutManager = new LinearLayoutManager(Context);
            var circuitBreakerItemDecorator = new CircuitBreakerItemDecorator(Context);

            _circuitBreakerRecyclerViewAdapter = new CircuitBreakerRecyclerViewAdapter(_circuitBreakers);
            _circuitBreakerRecyclerView.SetLayoutManager(layoutManager);
            _circuitBreakerRecyclerView.SetAdapter(_circuitBreakerRecyclerViewAdapter);
            _circuitBreakerRecyclerView.AddItemDecoration(circuitBreakerItemDecorator);
            _circuitbreakerSearchView.Click += (s, e) =>
            {
                (s as Android.Widget.SearchView).SetIconifiedByDefault(false);
                //InputMethodManager inputMethodManager = Activity.GetSystemService(Context.InputMethodService) as InputMethodManager;
                //inputMethodManager.ShowSoftInput(view, ShowFlags.Forced);
                //inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
            };
            _circuitbreakerSearchView.QueryTextChange += (s, e) =>
            {
                if (String.IsNullOrEmpty(e.NewText) || String.IsNullOrWhiteSpace(e.NewText))
                {
                    ResetHighLightedSelectedPanel();
                }
                _circuitBreakers.Clear();
                _circuitBreakerService.Search(e.NewText.Trim()).ForEach(x => _circuitBreakers.Add(x));
                _circuitBreakerRecyclerViewAdapter.NotifyDataSetChanged();
            };

            _circuitBreakerRecyclerViewAdapter.ItemClick += (s, e) =>
            {
                if (_previousItemId == -1 || _previousItemId == e.Item2)
                {
                    ((View)e.Item1).SetBackgroundColor(Color.ParseColor("#80388e3c"));
                }
                else
                {
                    _previousView.SetBackgroundColor(Color.Transparent);
                    ((View)e.Item1).SetBackgroundColor(Color.ParseColor("#80388e3c"));
                }
                var circuitBreaker = (CircuitBreaker)_circuitBreakerRecyclerViewAdapter.GetItem(e.Item2);
                ResetHighLightedSelectedPanel();
                if (circuitBreaker.Panel.Equals("P6"))
                {
                    _panel = Panel.P6;
                }
                if (circuitBreaker.Panel.Equals("P6-1"))
                {
                    _panel = Panel.P61;
                }
                if (circuitBreaker.Panel.Equals("P6-2"))
                {
                    _panel = Panel.P62;
                }
                if (circuitBreaker.Panel.Equals("P6-3"))
                {
                    _panel = Panel.P63;
                }
                if (circuitBreaker.Panel.Equals("P6-4"))
                {
                    _panel = Panel.P64;
                }
                if (circuitBreaker.Panel.Equals("P6-11"))
                {
                    _panel = Panel.P611;
                }
                if (circuitBreaker.Panel.Equals("P6-12"))
                {
                    _panel = Panel.P612;
                }
                if (circuitBreaker.Panel.Equals("P18-0"))
                {
                    _panel = Panel.P180;
                }
                if (circuitBreaker.Panel.Equals("P18-1"))
                {
                    _panel = Panel.P181;
                }
                if (circuitBreaker.Panel.Equals("P18-2"))
                {
                    _panel = Panel.P182;
                }
                if (circuitBreaker.Panel.Equals("P18-3"))
                {
                    _panel = Panel.P183;
                }
                if (circuitBreaker.Panel.Equals("P91") | circuitBreaker.Panel.Equals("P92"))
                {
                    _panel = Panel.P9X;
                }
                HighLightSelectedPanel();
                _previousView   = (View)e.Item1;
                _previousItemId = e.Item2;
            };

            /*_circuitbreakerPanel6LinearLayout.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P6)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel );
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            _circuitbreakerPanel61LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P61)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel62LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P62)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel63LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P63)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel64LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P64)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel611LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P611)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel612LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P612)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            /*_circuitbreakerPanel180LinearLayout.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P180)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel);
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            _circuitbreakerPanel181LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P181)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel182LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P182)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel183LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P183)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            /*_circuitbreakerEECompartmentTextView.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P9X)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel);
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            return(view);
        }
        public virtual void OnReceived(IDictionary <string, object> parameters)
        {
            System.Diagnostics.Debug.WriteLine($"{DomainTag} - OnReceived");

            if ((parameters.TryGetValue(SilentKey, out var silent) && (silent.ToString() == "true" || silent.ToString() == "1")) || (IsInForeground() && (!(!parameters.ContainsKey(ChannelIdKey) && parameters.TryGetValue(PriorityKey, out var imp) && ($"{imp}" == "high" || $"{imp}" == "max")) || (!parameters.ContainsKey(PriorityKey) && !parameters.ContainsKey(ChannelIdKey) && PushNotificationManager.DefaultNotificationChannelImportance != NotificationImportance.High && PushNotificationManager.DefaultNotificationChannelImportance != NotificationImportance.Max))))
            {
                return;
            }

            Context context = Application.Context;

            var notifyId           = 0;
            var title              = context.ApplicationInfo.LoadLabel(context.PackageManager);
            var message            = string.Empty;
            var tag                = string.Empty;
            var notificationNumber = 0;
            var showWhenVisible    = PushNotificationManager.ShouldShowWhen;
            var soundUri           = PushNotificationManager.SoundUri;
            var largeIconResource  = PushNotificationManager.LargeIconResource;
            var smallIconResource  = PushNotificationManager.IconResource;
            var notificationColor  = PushNotificationManager.Color;
            var chanId             = PushNotificationManager.DefaultNotificationChannelId;

            if (!string.IsNullOrEmpty(PushNotificationManager.NotificationContentTextKey) && parameters.TryGetValue(PushNotificationManager.NotificationContentTextKey, out var notificationContentText))
            {
                message = notificationContentText.ToString();
            }
            else if (parameters.TryGetValue(AlertKey, out var alert))
            {
                message = $"{alert}";
            }
            else if (parameters.TryGetValue(BodyKey, out var body))
            {
                message = $"{body}";
            }
            else if (parameters.TryGetValue(MessageKey, out var messageContent))
            {
                message = $"{messageContent}";
            }
            else if (parameters.TryGetValue(SubtitleKey, out var subtitle))
            {
                message = $"{subtitle}";
            }
            else if (parameters.TryGetValue(TextKey, out var text))
            {
                message = $"{text}";
            }

            if (!string.IsNullOrEmpty(PushNotificationManager.NotificationContentTitleKey) && parameters.TryGetValue(PushNotificationManager.NotificationContentTitleKey, out var notificationContentTitle))
            {
                title = notificationContentTitle.ToString();
            }
            else if (parameters.TryGetValue(TitleKey, out var titleContent))
            {
                if (!string.IsNullOrEmpty(message))
                {
                    title = $"{titleContent}";
                }
                else
                {
                    message = $"{titleContent}";
                }
            }

            if (parameters.TryGetValue(IdKey, out var id))
            {
                try
                {
                    notifyId = Convert.ToInt32(id);
                }
                catch (Exception ex)
                {
                    // Keep the default value of zero for the notify_id, but log the conversion problem.
                    System.Diagnostics.Debug.WriteLine($"Failed to convert {id} to an integer {ex}");
                }
            }

            if (parameters.TryGetValue(NumberKey, out var num))
            {
                try
                {
                    notificationNumber = Convert.ToInt32(num);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"Failed to convert {num} to an integer {ex}");
                }
            }

            if (parameters.TryGetValue(ShowWhenKey, out var shouldShowWhen))
            {
                showWhenVisible = $"{shouldShowWhen}".ToLower() == "true";
            }


            if (parameters.TryGetValue(TagKey, out var tagContent))
            {
                tag = tagContent.ToString();
            }

            try
            {
                if (parameters.TryGetValue(SoundKey, out var sound))
                {
                    var soundName  = sound.ToString();
                    var soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName);
                    if (soundResId == 0 && soundName.IndexOf('.') != -1)
                    {
                        soundName  = soundName.Substring(0, soundName.LastIndexOf('.'));
                        soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName);
                    }

                    soundUri = new Android.Net.Uri.Builder()
                               .Scheme(ContentResolver.SchemeAndroidResource)
                               .Path($"{context.PackageName}/{soundResId}")
                               .Build();
                }
            }
            catch (Resources.NotFoundException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            if (soundUri == null)
            {
                soundUri = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
            }
            try
            {
                if (parameters.TryGetValue(IconKey, out var icon) && icon != null)
                {
                    try
                    {
                        smallIconResource = context.Resources.GetIdentifier(icon.ToString(), "drawable", Application.Context.PackageName);
                        if (smallIconResource == 0)
                        {
                            smallIconResource = context.Resources.GetIdentifier($"{icon}", "mipmap", Application.Context.PackageName);
                        }
                    }
                    catch (Resources.NotFoundException ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.ToString());
                    }
                }

                if (smallIconResource == 0)
                {
                    smallIconResource = context.ApplicationInfo.Icon;
                }
                else
                {
                    var name = context.Resources.GetResourceName(smallIconResource);
                    if (name == null)
                    {
                        smallIconResource = context.ApplicationInfo.Icon;
                    }
                }
            }
            catch (Resources.NotFoundException ex)
            {
                smallIconResource = context.ApplicationInfo.Icon;
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }


            try
            {
                if (parameters.TryGetValue(LargeIconKey, out object largeIcon) && largeIcon != null)
                {
                    largeIconResource = context.Resources.GetIdentifier($"{largeIcon}", "drawable", Application.Context.PackageName);
                    if (largeIconResource == 0)
                    {
                        largeIconResource = context.Resources.GetIdentifier($"{largeIcon}", "mipmap", Application.Context.PackageName);
                    }
                }

                if (largeIconResource > 0)
                {
                    string name = context.Resources.GetResourceName(largeIconResource);
                    if (name == null)
                    {
                        largeIconResource = 0;
                    }
                }
            }
            catch (Resources.NotFoundException ex)
            {
                largeIconResource = 0;
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            if (parameters.TryGetValue(ColorKey, out var color) && color != null)
            {
                try
                {
                    notificationColor = Color.ParseColor(color.ToString());
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to parse color {ex}");
                }
            }

            Intent resultIntent = typeof(Activity).IsAssignableFrom(PushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, PushNotificationManager.NotificationActivityType) : (PushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, PushNotificationManager.DefaultNotificationActivityType));

            var extras = new Bundle();

            foreach (var p in parameters)
            {
                extras.PutString(p.Key, p.Value.ToString());
            }

            if (extras != null)
            {
                extras.PutInt(ActionNotificationIdKey, notifyId);
                extras.PutString(ActionNotificationTagKey, tag);
                resultIntent.PutExtras(extras);
            }

            if (PushNotificationManager.NotificationActivityFlags != null)
            {
                resultIntent.SetFlags(PushNotificationManager.NotificationActivityFlags.Value);
            }
            var requestCode   = new Java.Util.Random().NextInt();
            var pendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent);

            if (parameters.TryGetValue(ChannelIdKey, out var channelId) && channelId != null)
            {
                chanId = $"{channelId}";
            }

            var notificationBuilder = new NotificationCompat.Builder(context, chanId)
                                      .SetSmallIcon(smallIconResource)
                                      .SetContentTitle(title)
                                      .SetContentText(message)
                                      .SetAutoCancel(true)
                                      .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                                      .SetContentIntent(pendingIntent);

            if (notificationNumber > 0)
            {
                notificationBuilder.SetNumber(notificationNumber);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1)
            {
                notificationBuilder.SetShowWhen(showWhenVisible);
            }

            if (largeIconResource > 0)
            {
                Bitmap largeIconBitmap = BitmapFactory.DecodeResource(context.Resources, largeIconResource);
                notificationBuilder.SetLargeIcon(largeIconBitmap);
            }

            if (parameters.TryGetValue(FullScreenIntentKey, out var fullScreenIntent) && ($"{fullScreenIntent}" == "true" || $"{fullScreenIntent}" == "1"))
            {
                var fullScreenPendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent);
                notificationBuilder.SetFullScreenIntent(fullScreenPendingIntent, true);
                notificationBuilder.SetCategory(NotificationCompat.CategoryCall);
                parameters[PriorityKey] = "high";
            }

            var deleteIntent = new Intent(context, typeof(PushNotificationDeletedReceiver));

            deleteIntent.PutExtras(extras);
            var pendingDeleteIntent = PendingIntent.GetBroadcast(context, requestCode, deleteIntent, PendingIntentFlags.UpdateCurrent);

            notificationBuilder.SetDeleteIntent(pendingDeleteIntent);

            if (Build.VERSION.SdkInt < BuildVersionCodes.O)
            {
                if (parameters.TryGetValue(PriorityKey, out var priority) && priority != null)
                {
                    var priorityValue = $"{priority}";
                    if (!string.IsNullOrEmpty(priorityValue))
                    {
                        switch (priorityValue.ToLower())
                        {
                        case "max":
                            notificationBuilder.SetPriority(NotificationCompat.PriorityMax);
                            notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                            break;

                        case "high":
                            notificationBuilder.SetPriority(NotificationCompat.PriorityHigh);
                            notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                            break;

                        case "default":
                            notificationBuilder.SetPriority(NotificationCompat.PriorityDefault);
                            notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                            break;

                        case "low":
                            notificationBuilder.SetPriority(NotificationCompat.PriorityLow);
                            break;

                        case "min":
                            notificationBuilder.SetPriority(NotificationCompat.PriorityMin);
                            break;

                        default:
                            notificationBuilder.SetPriority(NotificationCompat.PriorityDefault);
                            notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                            break;
                        }
                    }
                    else
                    {
                        notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                    }
                }
                else
                {
                    notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
                }

                try
                {
                    notificationBuilder.SetSound(soundUri);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to set sound {ex}");
                }
            }

            // Try to resolve (and apply) localized parameters
            ResolveLocalizedParameters(notificationBuilder, parameters);

            if (notificationColor != null)
            {
                notificationBuilder.SetColor(notificationColor.Value);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
            {
                // Using BigText notification style to support long message
                var style = new NotificationCompat.BigTextStyle();
                style.BigText(message);
                notificationBuilder.SetStyle(style);
            }

            var category = string.Empty;

            if (parameters.TryGetValue(CategoryKey, out var categoryContent))
            {
                category = categoryContent.ToString();
            }

            if (parameters.TryGetValue(ActionKey, out var actionContent))
            {
                category = actionContent.ToString();
            }

            var notificationCategories = CrossPushNotification.Current?.GetUserNotificationCategories();

            if (notificationCategories != null && notificationCategories.Length > 0)
            {
                foreach (var userCat in notificationCategories)
                {
                    if (userCat != null && userCat.Actions != null && userCat.Actions.Count > 0)
                    {
                        foreach (var action in userCat.Actions)
                        {
                            var aRequestCode = Guid.NewGuid().GetHashCode();
                            if (userCat.Category.Equals(category, StringComparison.CurrentCultureIgnoreCase))
                            {
                                Intent                    actionIntent        = null;
                                PendingIntent             pendingActionIntent = null;
                                NotificationCompat.Action nAction             = null;
                                if (action.Type == NotificationActionType.Foreground)
                                {
                                    actionIntent = typeof(Activity).IsAssignableFrom(PushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, PushNotificationManager.NotificationActivityType) : (PushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, PushNotificationManager.DefaultNotificationActivityType));

                                    if (PushNotificationManager.NotificationActivityFlags != null)
                                    {
                                        actionIntent.SetFlags(PushNotificationManager.NotificationActivityFlags.Value);
                                    }

                                    extras.PutString(ActionIdentifierKey, action.Id);
                                    actionIntent.PutExtras(extras);
                                    pendingActionIntent = PendingIntent.GetActivity(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent);
                                    nAction             = new NotificationCompat.Action.Builder(context.Resources.GetIdentifier(action.Icon, "drawable", Application.Context.PackageName), action.Title, pendingActionIntent).Build();
                                }
                                else if (action.Type == NotificationActionType.Reply)
                                {
                                    var input = new RemoteInput.Builder("Result").SetLabel(action.Title).Build();

                                    actionIntent = new Intent(context, typeof(PushNotificationReplyReceiver));
                                    extras.PutString(ActionIdentifierKey, action.Id);
                                    actionIntent.PutExtras(extras);

                                    pendingActionIntent = PendingIntent.GetBroadcast(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent);

                                    nAction = new NotificationCompat.Action.Builder(context.Resources.GetIdentifier(action.Icon, "drawable", Application.Context.PackageName), action.Title, pendingActionIntent)
                                              .SetAllowGeneratedReplies(true)
                                              .AddRemoteInput(input)
                                              .Build();
                                }
                                else
                                {
                                    actionIntent = new Intent(context, typeof(PushNotificationActionReceiver));
                                    extras.PutString(ActionIdentifierKey, action.Id);
                                    actionIntent.PutExtras(extras);
                                    pendingActionIntent = PendingIntent.GetBroadcast(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent);
                                    nAction             = new NotificationCompat.Action.Builder(context.Resources.GetIdentifier(action.Icon, "drawable", Application.Context.PackageName), action.Title, pendingActionIntent).Build();
                                }

                                notificationBuilder.AddAction(nAction);
                            }
                        }
                    }
                }
            }

            OnBuildNotification(notificationBuilder, parameters);

            var notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);

            notificationManager.Notify(tag, notifyId, notificationBuilder.Build());
        }