Пример #1
0
            public override void OnReceive(Context context, Intent intent)
            {
                Log.Info(TAG, "Receiving broadcast " + intent);

                Bundle extra = GetResultExtras(false);

                if (ResultCode != Result.Ok)
                {
                    self.mHandler.Post(() => {
                        Toast.MakeText(self, "Error code:" + ResultCode, ToastLength.Short).Show();
                    });
                }

                if (extra == null)
                {
                    self.mHandler.Post(() => {
                        Toast.MakeText(self, "No extra", ToastLength.Short).Show();
                    });
                }

                else if (extra.ContainsKey(RecognizerIntent.ExtraSupportedLanguages))
                {
                    self.mHandler.Post(() => {
                        self.UpdateSupportedLanguages(extra.GetStringArrayList(RecognizerIntent.ExtraSupportedLanguages));
                    });
                }

                else if (extra.ContainsKey(RecognizerIntent.ExtraLanguagePreference))
                {
                    self.mHandler.Post(() => {
                        self.UpdateLanguagePreference(extra.GetString(RecognizerIntent.ExtraLanguagePreference));
                    });
                }
            }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            //clsock.Connect();
            SetContentView(Resource.Layout.activity_main);

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



            Android.Support.V4.App.FragmentManager fm       = SupportFragmentManager;
            Android.Support.V4.App.Fragment        fragment = fm.FindFragmentById(Resource.Id.main_act_fragment);

            if (fragment == null)
            {
                fragment = new MainActivityFragmentHolder();
                fm.BeginTransaction()
                .Add(Resource.Id.main_act_fragment, fragment)
                .Commit();
            }



            if (savedInstanceState == null ||
                !savedInstanceState.ContainsKey("message") || !savedInstanceState.ContainsKey("reply"))
            {
                return;
            }
            //textbox_send.Text = savedInstanceState.GetString("message");
            //textbox_server.Text = savedInstanceState.GetString("server");
            //textbox_receive.Text = savedInstanceState.GetString("reply");
        }
Пример #3
0
        protected override void OnNewIntent(Intent intent)
        {
            if (intent == null)
            {
                return;
            }

            Bundle bundle = intent.Extras;

            string use_protocol = Preferences.Get("protocol", "http").ToLower();

            if (use_protocol == "mqtt")
            {
                if ((bundle != null && bundle.ContainsKey(Constants.SERVICE_STARTED_KEY)) || (ForegroundServiceMqtt.ForegroundServiceManager != null && ForegroundServiceMqtt.ForegroundServiceManager.isStartedForegroundService))
                {
                    isStarted = true;
                }
            }
            else
            {
                if ((bundle != null && bundle.ContainsKey(Constants.SERVICE_STARTED_KEY)) || (ForegroundServiceHttp.ForegroundServiceManager != null && ForegroundServiceHttp.ForegroundServiceManager.isStartedForegroundService))
                {
                    isStarted = true;
                }
            }
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //SetContentView(Resource.Layout.activity_token);

            _authService = new AuthorizationService(this);

            if (savedInstanceState != null)
            {
                if (savedInstanceState.ContainsKey(KEY_AUTH_STATE))
                {
                    try
                    {
                        _authState = AuthState.JsonDeserialize(savedInstanceState.GetString(KEY_AUTH_STATE));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Malformed authorization JSON saved: " + ex);
                    }
                }

                if (savedInstanceState.ContainsKey(KEY_USER_INFO))
                {
                    try
                    {
                        _userInfoJson = new JSONObject(savedInstanceState.GetString(KEY_USER_INFO));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to parse saved user info JSON: " + ex);
                    }
                }
            }

            if (_authState == null)
            {
                _authState = GetAuthStateFromIntent(Intent);
                var response = AuthorizationResponse.FromIntent(Intent);
                var ex       = AuthorizationException.FromIntent(Intent);
                _authState.Update(response, ex);

                if (response != null)
                {
                    Console.WriteLine("Received AuthorizationResponse");
                    PerformTokenRequest(response.CreateTokenExchangeRequest());
                }
                else
                {
                    Console.WriteLine("Authorization failed: " + ex);
                }
            }

            //RefreshUi();

            //var contactsViewController = App.GetContactsPage().CreateViewController();
            //NavigationController.PresentViewController(contactsViewController, true, null);
            Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_token);

            if (savedInstanceState != null)
            {
                if (savedInstanceState.ContainsKey(KEY_AUTH_STATE))
                {
                    authState = AuthState.JsonDeserialize(savedInstanceState.GetString(KEY_AUTH_STATE));
                }

                if (savedInstanceState.ContainsKey(KEY_USER_INFO))
                {
                    userInfoJson = new JSONObject(savedInstanceState.GetString(KEY_USER_INFO));
                }
            }

            if (authState == null)
            {
                authState = GetAuthStateFromIntent(Intent);
                AuthorizationResponse  response = AuthorizationResponse.FromIntent(Intent);
                AuthorizationException ex       = AuthorizationException.FromIntent(Intent);
                authState.Update(response, ex);
                if (response != null)
                {
                    PerformTokenRequest(response.CreateTokenExchangeRequest());
                }
            }
        }
Пример #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AssignmentsTabsLayout);

            tabHost = FindViewById <TabHost> (Resource.Id.assingmentTabHost);
            //In order to use tabs outside of a TabActivity I have to use this local activity manager and dispatch create the savedInstanceState
            localManger = new LocalActivityManager(this, true);
            localManger.DispatchCreate(savedInstanceState);
            tabHost.Setup(localManger);

            TabHost.TabSpec assignmentsSpec  = tabHost.NewTabSpec("list");
            Intent          assignmentIntent = new Intent(this, typeof(AssignmentsActivity));

            assignmentsSpec.SetContent(assignmentIntent);
            assignmentsSpec.SetIndicator("list");

            TabHost.TabSpec mapViewSpec   = tabHost.NewTabSpec("map");
            Intent          mapViewIntent = new Intent(this, typeof(MapViewActivity));

            mapViewSpec.SetContent(mapViewIntent);
            mapViewSpec.SetIndicator("map");

            tabHost.AddTab(assignmentsSpec);
            tabHost.AddTab(mapViewSpec);

            tabHost.TabChanged += (sender, e) => {
                if (tabHost.CurrentTab == 0)
                {
                    MapData = null;
                }
            };

            try {
                if (savedInstanceState != null)
                {
                    if (savedInstanceState.ContainsKey(Constants.CurrentTab))
                    {
                        var currentTab = savedInstanceState.GetInt(Constants.CurrentTab, 0);
                        tabHost.CurrentTab = currentTab;
                    }
                    else
                    {
                        tabHost.CurrentTab = 0;
                    }

                    MapData = savedInstanceState.ContainsKey("mapData") ?
                              (MapDataWrapper)savedInstanceState.GetSerializable("mapData") : null;
                }
                else
                {
                    MapData            = null;
                    tabHost.CurrentTab = 0;
                }
            } catch (Exception) {
                tabHost.CurrentTab = 0;
            }
        }
        protected override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            SetContentView (Resource.Layout.AssignmentsTabsLayout);

            tabHost = FindViewById<TabHost> (Resource.Id.assingmentTabHost);
            //In order to use tabs outside of a TabActivity I have to use this local activity manager and dispatch create the savedInstanceState
            localManger = new LocalActivityManager (this, true);
            localManger.DispatchCreate (savedInstanceState);
            tabHost.Setup (localManger);

            TabHost.TabSpec assignmentsSpec = tabHost.NewTabSpec ("list");
            Intent assignmentIntent = new Intent (this, typeof (AssignmentsActivity));
            assignmentsSpec.SetContent (assignmentIntent);
            assignmentsSpec.SetIndicator ("list");

            TabHost.TabSpec mapViewSpec = tabHost.NewTabSpec ("map");
            Intent mapViewIntent = new Intent (this, typeof (MapViewActivity));
            mapViewSpec.SetContent (mapViewIntent);
            mapViewSpec.SetIndicator ("map");

            tabHost.AddTab (assignmentsSpec);
            tabHost.AddTab (mapViewSpec);

            tabHost.TabChanged += (sender, e) => {
                if (tabHost.CurrentTab == 0) {
                    MapData = null;
                }
            };

            try {
                if (savedInstanceState != null) {
                    if (savedInstanceState.ContainsKey (Constants.CurrentTab)) {
                        var currentTab = savedInstanceState.GetInt (Constants.CurrentTab, 0);
                        tabHost.CurrentTab = currentTab;
                    } else {
                        tabHost.CurrentTab = 0;
                    }
                    if (savedInstanceState.ContainsKey ("mapData")) {
                        MapData = (MapDataWrapper)savedInstanceState.GetSerializable ("mapData");
                    } else {
                        MapData = null;
                    }
                } else {
                    MapData = null;
                    tabHost.CurrentTab = 0;
                }
            } catch (Exception) {
                tabHost.CurrentTab = 0;
            }            
        }
        protected override void OnResume()
        {
            base.OnResume();

            // If app restrictions are set for this package, when launched from a restricted profile,
            // the settings are available in the returned Bundle as key/value pairs.
            mRestrictionsBundle = ((UserManager)GetSystemService(Context.UserService))
                                  .GetApplicationRestrictions(PackageName);

            if (mRestrictionsBundle == null)
            {
                mRestrictionsBundle = new Bundle();
            }

            // Reads and displays values from a boolean type restriction entry, if available.
            // An app can utilize these settings to restrict its content under a restricted profile.
            String booleanRestrictionValue =
                mRestrictionsBundle.ContainsKey(GetRestrictionsReceiver.KEY_BOOLEAN) ?
                mRestrictionsBundle.GetBoolean(GetRestrictionsReceiver.KEY_BOOLEAN) + "":
                GetString(Resource.String.na);

            mBooleanEntryValue.Text = booleanRestrictionValue;

            // Reads and displays values from a single choice restriction entry, if available.
            String singleChoiceRestrictionValue =
                mRestrictionsBundle.ContainsKey(GetRestrictionsReceiver.KEY_CHOICE) ?
                mRestrictionsBundle.GetString(GetRestrictionsReceiver.KEY_CHOICE) :
                GetString(Resource.String.na);

            mChoiceEntryValue.Text = singleChoiceRestrictionValue;

            // Reads and displays values from a multi-select restriction entry, if available.
            String[] multiSelectValues =
                mRestrictionsBundle.GetStringArray(GetRestrictionsReceiver.KEY_MULTI_SELECT);

            if (multiSelectValues == null || multiSelectValues.Length == 0)
            {
                mMultiEntryValue.Text = GetString(Resource.String.na);
            }
            else
            {
                String tempValue = "";
                foreach (String value in multiSelectValues)
                {
                    tempValue = tempValue + value + " ";
                }
                mMultiEntryValue.Text = tempValue;
            }
        }
Пример #9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (savedInstanceState?.ContainsKey("Line") == true)
            {
                int lineId = savedInstanceState.GetInt("Line");
                line = TramUrWayApplication.GetLine(lineId);
            }
            if (savedInstanceState?.ContainsKey("Color") == true)
            {
                int argb = savedInstanceState.GetInt("Color");
                color = new Color(argb);
            }

            return(inflater.Inflate(Resource.Layout.LineMapFragment, container, false));
        }
Пример #10
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            _boardViewModel      = ServiceProvider.GetService <ScoreBoardViewModel>();
            _vm                  = ServiceProvider.GetService <OmlViewModel>();
            _vm.PropertyChanged += VmOnPropertyChanged;

            if (savedInstanceState != null && savedInstanceState.ContainsKey(SelectedItem))
            {
                _selectedItem = savedInstanceState.GetInt(SelectedItem);
            }

            var editFragment =
                (OmlItemEditFragment)Activity.SupportFragmentManager.FindFragmentByTag(OmlItemEditFragment
                                                                                       .FragmentTag);

            if (editFragment != null)
            {
                editFragment.SetItemData(_vm.Teams[_selectedItem]);
                editFragment.ItemEdited += OnItemEdited;
            }

            var confirmationFragment =
                (OmlSendingConfirmationFragment)Activity.SupportFragmentManager.FindFragmentByTag(
                    OmlSendingConfirmationFragment.FragmentTag);

            if (confirmationFragment != null)
            {
                confirmationFragment.SetViewModelData(_vm.Teams[_selectedItem]);
                confirmationFragment.Confirmed += ConfirmationDialogOnConfirmed;
            }
        }
Пример #11
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            mGridView = (GridView)view.FindViewById(Resource.Id.asset_grid);
            mGridView.OnItemClickListener = this;

            /*
             * Currently set in the XML layout, but this is how you would do it in
             * your code.
             */
            // mGridView.setColumnWidth((int) calculatePixelsFromDips(100));
            // mGridView.setNumColumns(StickyGridHeadersGridView.AUTO_FIT);
            mGridView.Adapter = new StickyGridHeadersSimpleArrayAdapter <string>(Activity.ApplicationContext, Resources.GetStringArray(Resource.Array.countries), Resource.Layout.header, Resource.Layout.item);

            if (savedInstanceState != null)
            {
                mFirstVisible = savedInstanceState.GetInt(KEY_LIST_POSITION);
            }

            mGridView.SetSelection(mFirstVisible);

            // Restore the previously serialized activated item position.
            if (savedInstanceState != null && savedInstanceState.ContainsKey(STATE_ACTIVATED_POSITION))
            {
                ActivatedPosition = savedInstanceState.GetInt(STATE_ACTIVATED_POSITION);
            }

            ((StickyGridHeadersGridView)mGridView).OnHeaderClickListener     = this;
            ((StickyGridHeadersGridView)mGridView).OnHeaderLongClickListener = this;

            HasOptionsMenu = true;
        }
Пример #12
0
 protected override void OnCreate(Bundle bundle)
 {
     RequestWindowFeature(WindowFeatures.NoTitle);
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.Viewer);
     // associate the views
     MainImage = FindViewById<ZoomImageView>(Resource.Id.MainImage);
     Zoom = FindViewById<ZoomControls>(Resource.Id.ZoomButtons);
     OpenButton = FindViewById<ImageButton>(Resource.Id.OpenButton);
     LeftButton = FindViewById<ImageButton>(Resource.Id.LeftButton);
     RightButton = FindViewById<ImageButton>(Resource.Id.RightButton);
     // wire the views
     Zoom.ZoomInClick += (src, args) => MainImage.ZoomIn();
     Zoom.ZoomOutClick += (src, args) => MainImage.ZoomOut();
     OpenButton.Click += (src, args) => OnOpenButtonClick(args);
     LeftButton.Click += (src, args) => OnLeftButtonClick(args);
     RightButton.Click += (src, args) => OnRightButtonClick(args);
     // get preferences
     var prefs = GetSharedPreferences("Global", FileCreationMode.Private);
     // check bundles and prefs
     if (Intent.Extras != null && Intent.Extras.ContainsKey("ComicsPath"))
         Controller = new ViewerController(this, Intent.Extras.GetString("ComicsPath"));
     else if (bundle != null && bundle.ContainsKey("ComicsPath"))
         Controller = new ViewerController(this, bundle.GetString("ComicsPath"));
     else
         Controller = new ViewerController(this, prefs.GetString("ComicsPath", null));
 }
Пример #13
0
        /// <summary>
        /// Initialises the activity.
        /// </summary>
        /// <param name="savedInstanceState">The incoming bundle</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Bundle currentBundle = savedInstanceState ?? this.Intent.Extras;

            if (currentBundle != null)
            {
                if (currentBundle.ContainsKey(TaskIdBundleKey))
                {
                    this._taskId = currentBundle.GetInt(TaskIdBundleKey, 0);
                }
            }

            // set our layout to be the home screen
            this.SetContentView(Resource.Layout.TaskActivityView);

            Toolbar toolBar = this.FindViewById <Toolbar>(Resource.Id.applicationToolbar);

            this.SetSupportActionBar(toolBar);
            this.SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            // find all our controls
            this._notesEditText      = this.FindViewById <EditText>(Resource.Id.notesEditText);
            this._nameEditText       = this.FindViewById <EditText>(Resource.Id.nameEditText);
            this._saveButton         = this.FindViewById <Button>(Resource.Id.saveButton);
            this._doneSwitch         = this.FindViewById <SwitchCompat>(Resource.Id.doneSwitch);
            this._cancelDeleteButton = this.FindViewById <Button>(Resource.Id.cancelDeleteButton);

            // button clicks
            this._cancelDeleteButton.Click += (sender, e) => { this.CancelDelete(); };
            this._saveButton.Click         += (sender, e) => { this.Save(); };
        }
Пример #14
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
            builder.SetPositiveButton(Android.Resource.String.Ok, (IDialogInterfaceOnClickListener)null);
            Bundle args = Arguments;

            if (args.ContainsKey(ArgMessageInt))
            {
                builder.SetMessage(args.GetInt(ArgMessageInt));
            }
            else if (args.ContainsKey(ArgMessageString))
            {
                builder.SetMessage(args.GetString(ArgMessageString));
            }
            return(builder.Create());
        }
Пример #15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            this.View = inflater.Inflate(Resource.Layout.fragment_unified_basic_info, container, false);

            this.CreateView();

            if (savedInstanceState != null)
            {
                this._fragmentInfo = this.Activity.SupportFragmentManager.GetFragment(savedInstanceState, OverLayFragmentBundleKey) as FragmentInfo;

                if (this._fragmentInfo != null)
                {
                    this.WizardActivity.ShowOverlay(this._fragmentInfo, false);
                }

                if (savedInstanceState.ContainsKey(ProspectBeingConvertedBundleKey))
                {
                    this._prospectBeingConverted =
                        JsonConvert.DeserializeObject <ProspectSearchResult>(
                            savedInstanceState.GetString(ProspectBeingConvertedBundleKey));
                }
            }

            return(this.View);
        }
Пример #16
0
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Viewer);
            // associate the views
            MainImage   = FindViewById <ZoomImageView>(Resource.Id.MainImage);
            Zoom        = FindViewById <ZoomControls>(Resource.Id.ZoomButtons);
            OpenButton  = FindViewById <ImageButton>(Resource.Id.OpenButton);
            LeftButton  = FindViewById <ImageButton>(Resource.Id.LeftButton);
            RightButton = FindViewById <ImageButton>(Resource.Id.RightButton);
            // wire the views
            Zoom.ZoomInClick  += (src, args) => MainImage.ZoomIn();
            Zoom.ZoomOutClick += (src, args) => MainImage.ZoomOut();
            OpenButton.Click  += (src, args) => OnOpenButtonClick(args);
            LeftButton.Click  += (src, args) => OnLeftButtonClick(args);
            RightButton.Click += (src, args) => OnRightButtonClick(args);
            // get preferences
            var prefs = GetSharedPreferences("Global", FileCreationMode.Private);

            // check bundles and prefs
            if (Intent.Extras != null && Intent.Extras.ContainsKey("ComicsPath"))
            {
                Controller = new ViewerController(this, Intent.Extras.GetString("ComicsPath"));
            }
            else if (bundle != null && bundle.ContainsKey("ComicsPath"))
            {
                Controller = new ViewerController(this, bundle.GetString("ComicsPath"));
            }
            else
            {
                Controller = new ViewerController(this, prefs.GetString("ComicsPath", null));
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Instance = this;

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main_activity);

            mPaymentMethod            = FindViewById <CardView>(Resource.Id.payment_method);
            mPaymentMethodIcon        = FindViewById <ImageView>(Resource.Id.payment_method_icon);
            mPaymentMethodTitle       = FindViewById <TextView>(Resource.Id.payment_method_title);
            mPaymentMethodDescription = FindViewById <TextView>(Resource.Id.payment_method_description);
            mNonceString  = FindViewById <TextView>(Resource.Id.nonce);
            mNonceDetails = FindViewById <TextView>(Resource.Id.nonce_details);
            mDeviceData   = FindViewById <TextView>(Resource.Id.device_data);

            mAddPaymentMethodButton        = FindViewById <Button>(Resource.Id.add_payment_method);
            mAddPaymentMethodButton.Click += MAddPaymentMethodButton_Click;

            mPurchaseButton = FindViewById <Button>(Resource.Id.purchase);

            mCustomerId = "test_1299654099_biz_api1.kevinchows.com";

            if (savedInstanceState != null)
            {
                if (savedInstanceState.ContainsKey(KEY_NONCE))
                {
                    mNonce = (PaymentMethodNonce)savedInstanceState.GetParcelable(KEY_NONCE);
                }
            }
        }
Пример #18
0
        public virtual void OnCreate(Bundle savedInstanceState, Action <Bundle> baseOnCreate)
        {
            if (Tracer.TraceInformation)
            {
                Tracer.Info("OnCreate fragment({0})", Target);
            }
            OnCreate(savedInstanceState);
            baseOnCreate(savedInstanceState);

            var viewModel = DataContext as IViewModel;

            if (viewModel != null)
            {
                viewModel.Settings.Metadata.AddOrUpdate(AndroidToolkitExtensions.FragmentConstant, Target);
            }
            else if (DataContext == null)
            {
                if (savedInstanceState != null && savedInstanceState.ContainsKey(IgnoreStateKey))
                {
                    //prevent child fragments restore
                    savedInstanceState.RemoveFragmentsState();
                    _removed = true;
                    Target.FragmentManager
                    .BeginTransaction()
                    .Remove(Target)
                    .CommitAllowingStateLoss();
                }
            }
        }
Пример #19
0
 /// <summary>
 /// Restore current states from savedInstanceState.
 /// </summary>
 /// <param name="savedInstanceState">Saved instance state.</param>
 /// <param name="key">Key.</param>
 public void RestoreStatesFromKey(Bundle savedInstanceState, string key)
 {
     if (savedInstanceState != null && savedInstanceState.ContainsKey(key))
     {
         Arguments = savedInstanceState.GetBundle(key);
     }
 }
Пример #20
0
        /**
         * Only if you need to restore open/close state when the orientation is changed.
         * Call this method in {@link android.app.Activity#onRestoreInstanceState(Bundle)}
         */
        public void restoreStates(Bundle inState)
        {
            if (inState == null)
            {
                return;
            }

            if (inState.ContainsKey(BUNDLE_MAP_KEY))
            {
                ConcurrentDictionary <string, int> restoredMap = new ConcurrentDictionary <string, int>();

                Bundle statesBundle         = inState.GetBundle(BUNDLE_MAP_KEY);
                ICollection <String> keySet = statesBundle.KeySet();

                if (keySet != null)
                {
                    foreach (var key in keySet)
                    {
                        restoredMap.put(key, statesBundle.GetInt(key));
                    }
                }

                mapStates = restoredMap;
            }
        }
Пример #21
0
 protected override void OnRestoreInstanceState(Bundle savedInstanceState)
 {
     if (savedInstanceState.ContainsKey("selected"))
     {
         ActionBar.SetSelectedNavigationItem(savedInstanceState.GetInt("selected"));
     }
 }
Пример #22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            if (bundle != null && bundle.ContainsKey("PlayerNames"))
            {
                var savedNameList = bundle.GetStringArrayList("PlayerNames");
                if (savedNameList.Count == 5)
                {
                    for (int i = 0; i < savedNameList.Count; i++)
                    {
                        _playerNameEditTexts[i].Text = savedNameList[i];
                    }
                }
            }
            if (_playMenuItem != null)
            {
                _playMenuItem.SetVisible(true);
            }
        }
Пример #23
0
        protected void OnCreate(Bundle bundle)
        {
            if (_id == Guid.Empty)
            {
                _id = Guid.NewGuid();
            }
            var oldId = bundle?.GetString(IdKey);

            if (string.IsNullOrEmpty(oldId))
            {
                return;
            }
            var cacheDataContext = GetFromCache(Guid.Parse(oldId));
            var vmTypeName       = bundle.GetString(ViewModelTypeNameKey);

            if (vmTypeName == null)
            {
                return;
            }
            bundle.Remove(ViewModelTypeNameKey);
            var vmType = Type.GetType(vmTypeName, false);

            if (vmType != null && (cacheDataContext == null || !cacheDataContext.GetType().Equals(vmType)))
            {
                if (!bundle.ContainsKey(IgnoreStateKey))
                {
                    cacheDataContext = RestoreViewModel(vmType, bundle);
                }
            }
            if (!ReferenceEquals(DataContext, cacheDataContext))
            {
                RestoreContext(Target, cacheDataContext);
            }
        }
Пример #24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            if (savedInstanceState != null)
            {
                contiene = savedInstanceState.ContainsKey("horizontal-first");
            }

            FrameLayout contenedor = FindViewById <FrameLayout>(Resource.Id.contenedorFragment);

            if (contenedor != null)
            {
                Android.Support.V4.App.Fragment estados = SupportFragmentManager.FindFragmentById(Resource.Id.estados);

                if (savedInstanceState == null || estados == null || savedInstanceState.GetBoolean("horizontal-first"))
                {
                    estados = new EstadosFragment();
                    SupportFragmentManager.BeginTransaction().Add(Resource.Id.contenedorFragment, estados).Commit();
                }
            }

            SupportFragmentManager.BackStackChanged += delegate {
                OnBackStackChanged();
            };
            OnBackStackChanged();
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            _density = (int)Math.Ceiling(Resources.DisplayMetrics.Density);
            Instance = this;

            Bundle args = Arguments;

            if (args != null && args.ContainsKey(ArgItemId))
            {
                string key = args.GetString(ArgItemId);

                if (_item != null && key != null && !key.Equals(_item.Id))
                {
                    _barcodeImage     = null;
                    _details          = "";
                    _showResultsLabel = false;
                }

                // Load the item content specified by the fragment
                // arguments. In a real-world scenario, use a Loader
                // to load content from a content provider.
                _item = ItemListActivity._content[key];
            }
        }
Пример #26
0
		public override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KeyContent))
				_content = savedInstanceState.GetString(KeyContent);
		}
Пример #27
0
        public override void OnReceive(Context context, Intent intent)
        {
            Bundle bundle = intent.Extras;

            if (bundle != null)
            {
                Status status = (Status)bundle.GetParcelable(ReadSmsConstant.ExtraStatus);
                if (status.StatusCode == (int)CommonStatusCodes.Timeout)
                {
                    // Service has timed out and no SMS message that meets the requirement is read. Service ended.

                    //DoSomethingWhenTimeOut();
                }
                else if (status.StatusCode == CommonStatusCodes.Success)
                {
                    if (bundle.ContainsKey(ReadSmsConstant.ExtraSmsMessage))
                    {
                        // An SMS message that meets the requirement is read. Service ended.

                        //doSomethingWhenGetMessage(bundle.GetString(ReadSmsConstant.ExtraSmsMessage));

                        var smsMessage = (string)bundle.GetString(ReadSmsConstant.ExtraSmsMessage);
                        Log.Info(HuaweiIdActivity.TAG, smsMessage);
                    }
                }
            }
        }
Пример #28
0
        Task <Product> GetProductInfoAsync(string productSku, string itemType)
        {
            var getSkuDetailsTask = Task.Factory.StartNew <Product>(() =>
            {
                var querySku = new Bundle();
                querySku.PutStringArrayList(SKU_ITEM_ID_LIST, new string[] { productSku });


                Bundle skuDetails = serviceConnection.Service.GetSkuDetails(3, Context.PackageName, itemType, querySku);

                if (!skuDetails.ContainsKey(SKU_DETAILS_LIST))
                {
                    return(null);
                }

                var products = skuDetails.GetStringArrayList(SKU_DETAILS_LIST);

                if (products == null || !products.Any())
                {
                    return(null);
                }

                return(JsonConvert.DeserializeObject <Product>(products.FirstOrDefault()));
            });

            return(getSkuDetailsTask);
        }
Пример #29
0
 public void RestoreFromBundle(string key, Bundle bundle)
 {
     if (bundle.ContainsKey("Items"))
     {
         SetItems(JsonConvert.DeserializeObject <IList <KeyValuePair <string, bool> > >(bundle.GetString(key)));
     }
 }
Пример #30
0
        public String GetAuthToken()
        {
            IAccountManagerFuture future = mAccountManager.GetAuthToken(mAccount,
                                                                        mAuthTokenType, mNotifyAuthFailure, null, null);
            Bundle result = null;

            try
            {
                result = future.Result as Bundle;
            }
            catch (Java.Lang.Exception e)
            {
                throw new AuthFailureError("Error while retrieving auth token", e);
            }
            String authToken = null;

            if (future.IsDone && !future.IsCancelled)
            {
                if (result.ContainsKey(AccountManager.KeyIntent))
                {
                    Intent intent = result.GetParcelable(AccountManager.KeyIntent) as Intent;
                    throw new AuthFailureError(intent);
                }
                authToken = result.GetString(AccountManager.KeyAuthtoken);
            }
            if (authToken == null)
            {
                throw new AuthFailureError("Got null auth token for type: " + mAuthTokenType);
            }
            return(authToken);
        }
        Task<IEnumerable<Product>> GetProductInfoAsync(string[] productIds, string itemType)
        {
            var getSkuDetailsTask = Task.Factory.StartNew<IEnumerable<Product>>(() =>
            {

                var querySku = new Bundle();
                querySku.PutStringArrayList(SKU_ITEM_ID_LIST, productIds);


                Bundle skuDetails = serviceConnection.Service.GetSkuDetails(3, Context.PackageName, itemType, querySku);

                if (!skuDetails.ContainsKey(SKU_DETAILS_LIST))
                {
                    return null;
                }

                var products = skuDetails.GetStringArrayList(SKU_DETAILS_LIST);

                if (products == null || !products.Any())
                    return null;

                var items = new List<Product>(products.Count);
                foreach (var item in products)
                {
                    items.Add(JsonConvert.DeserializeObject<Product>(item));
                }
                return items;
            });

            return getSkuDetailsTask;
        }
Пример #32
0
        protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
            currentBaseUrl = "file://android_asset/";
            currentUrl = "file:///android_asset/index.html";

            if (bundle != null)
            {
                if (bundle.ContainsKey(UrlKey))
                    currentUrl = bundle.GetString(UrlKey);
                if (bundle.ContainsKey(ConfigKey))
                    inputConfiguration = JsonSerializer.Deserialize<InputConfiguration>(bundle.GetString(ConfigKey));
            }

            CheckFirstRun();
            LoadUrl();
		}
Пример #33
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KEY_CONTENT))
     {
         mContent = savedInstanceState.GetString(KEY_CONTENT);
     }
 }
        public override void OnReceive(Context context, Intent intent)
        {
            //Don't show a notification on boot
            if (intent.Action == Intent.ActionBootCompleted)
            {
                return;
            }

            // Get notification content
            Bundle extras  = intent.Extras;
            string message = "";

            Android.Net.Uri conversationId = null;
            if (extras.ContainsKey("layer-push-message"))
            {
                message = extras.GetString("layer-push-message");
            }
            if (extras.ContainsKey("layer-conversation-id"))
            {
                conversationId = extras.GetParcelable("layer-conversation-id") as Android.Net.Uri;
            }

            // Build the notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetSmallIcon(Resource.Drawable.ic_launcher)
                                                 .SetContentTitle(context.Resources.GetString(Resource.String.app_name))
                                                 .SetContentText(message)
                                                 .SetAutoCancel(true)
                                                 .SetPriority(NotificationCompat.PriorityDefault)
                                                 .SetDefaults(NotificationCompat.DefaultSound | NotificationCompat.DefaultVibrate);

            // Set the action to take when a user taps the notification
            Intent resultIntent = new Intent(context, typeof(MainActivity));

            resultIntent.SetFlags(ActivityFlags.ClearTop);
            resultIntent.PutExtra("layer-conversation-id", conversationId);
            PendingIntent resultPendingIntent = PendingIntent.GetActivity(context, 0, resultIntent, PendingIntentFlags.CancelCurrent);

            builder.SetContentIntent(resultPendingIntent);

            // Show the notification
            NotificationManager notifyMgr = (NotificationManager)context.GetSystemService(Context.NotificationService);

            notifyMgr.Notify(1, builder.Build());
        }
        //@Override
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KEY_CONTENT))
            {
                mContent = savedInstanceState.GetString(KEY_CONTENT);
            }
        }
Пример #36
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Main);

            // extract authInProgress from bundle if it's in there
            if (bundle != null && bundle.ContainsKey ("authInProgress")) {
                authInProgress = bundle.GetBoolean ("authInProgress");
            }

            BuildApiClient ();
        }
        void UpdateCanSayHello(RestrictionEntry entry, Bundle restrictions)
        {
            bool canSayHello;
            if (restrictions == null || !restrictions.ContainsKey (KEY_CAN_SAY_HELLO))
                canSayHello = entry.SelectedState;
            else
                canSayHello = restrictions.GetBoolean (KEY_CAN_SAY_HELLO);

            textSayHello.SetText (canSayHello ? Resource.String.explanation_can_say_hello_true :
                Resource.String.explanation_can_say_hello_false);
            buttonSayHello.Enabled = canSayHello;
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            Console.WriteLine("OnCreateView from Fragment");

            // Why?
            base.OnCreateView(inflater, container, savedInstanceState);

            // Title saved?
            if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KeyContent))
            {
                Title = savedInstanceState.GetString(KeyContent);
            }

            // Content
            return this.BindingInflate(_resourceId, null);
        }
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			if ((savedInstanceState != null) && savedInstanceState.ContainsKey (KEY_CONTENT)) {
				mContent = savedInstanceState.GetString (KEY_CONTENT);
			}
	
			TextView text = new TextView (Activity);
			text.Gravity = GravityFlags.Center;
			text.Text = mContent;
			text.TextSize = (20 * Resources.DisplayMetrics.Density);
			text.SetPadding (20, 20, 20, 20);
	
			LinearLayout layout = new LinearLayout (Activity);
			layout.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
			layout.SetGravity (GravityFlags.Center);
			layout.AddView (text);
	
			return layout;
		}
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.main_activity);

			mRequestActivityUpdatesButton = FindViewById<Button> (Resource.Id.request_activity_updates_button);
			mRemoveActivityUpdatesButton = FindViewById<Button> (Resource.Id.remove_activity_updates_button);
			mDetectedActivitiesListView = FindViewById<ListView> (Resource.Id.detected_activities_listview);

			mRequestActivityUpdatesButton.Click += RequestActivityUpdatesButtonHandler;
			mRemoveActivityUpdatesButton.Click += RemoveActivityUpdatesButtonHandler;

			mBroadcastReceiver = new ActivityDetectionBroadcastReceiver ();
			mBroadcastReceiver.OnReceiveImpl = (context, intent) => {
				var updatedActivities = intent.GetParcelableArrayExtra (Constants.ActivityExtra).Cast<DetectedActivity>().ToList();
				UpdateDetectedActivitiesList (updatedActivities);
			};

			SetButtonsEnabledState ();

			if (savedInstanceState != null && savedInstanceState.ContainsKey (
				    Constants.DetectedActivities)) {
				mDetectedActivities = JsonConvert.DeserializeObject<List<DetectedActivity>>(savedInstanceState.GetString (Constants.DetectedActivities));
			} else {
				mDetectedActivities = new List<DetectedActivity> ();

				for (int i = 0; i < Constants.MonitoredActivities.Length; i++) {
					mDetectedActivities.Add (new DetectedActivity (Constants.MonitoredActivities [i], 0));
				}
			}

			mAdapter = new DetectedActivitiesAdapter (this, mDetectedActivities);
			mDetectedActivitiesListView.Adapter = mAdapter;

			buildGoogleApiClient ();
		}
Пример #41
0
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			forecastAdapter = new ForecastAdapter (Activity, null, 0);
			forecastAdapter.setUseTodayLayout (_useTodayLayout);
			LoaderManager.InitLoader (URL_LOADER, null, this);
			var view = inflater.Inflate (Resource.Layout.fragment_main, container, false);
			listView = view.FindViewById<ListView> (Resource.Id.listview_forecast);
			listView.Adapter = forecastAdapter;
			listView.ItemClick += (sender, e) => {
				position = e.Position;
				ICursor cursor = (ICursor)listView.Adapter.GetItem (e.Position);
				if (cursor != null) {
					string locationSetting = Utility.getPreferredLocation (Activity);
					((Callback)Activity).OnItemSelected (WeatherContractOpen.WeatherEntryOpen.buildWeatherLocationWithDate (locationSetting, cursor.GetLong (COL_WEATHER_DATE)));

				}

			};

			if (savedInstanceState != null && savedInstanceState.ContainsKey ("position")) {
				position = savedInstanceState.GetInt ("position");
			}

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

            if (bundle != null && bundle.ContainsKey(ImagePathKey))
            {
                _imagePath = bundle.GetString(ImagePathKey);
            }

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

            var captureImageButton = FindViewById<ImageButton>(Resource.Id.image_button);
            captureImageButton.Click += (x, y) =>
                {
                    CaptureImage();
                };

            DateButton.Text = DateTime.Today.ToShortDateString();
            DateButton.Click += (x, y) =>
                {
                    var today = DateTime.Today.Date;
                    // Create a new instance of DatePickerDialog and return it
                    var dialog = new DatePickerDialog(this, OnDatePicked, today.Year, today.Month, today.Day);
                    dialog.Show();
                };

            var submitButton = FindViewById<Button>(Resource.Id.submit_button);
            submitButton.Click += (x, y) =>
            {
                var progress = ProgressDialog.Show(this, "Processing", "Please Wait...", false);
                Task.Factory.StartNew(
                    () =>
                    {
                        var answers = new CustomerComponent().Submit(GetCaptureEntity());
                        return answers;
                    })
                    .ContinueWith(result => OnCompleteAsnycSubmit(result, progress));
                progress.Show();
            };
        }
Пример #43
0
 public override void OnActivityCreated(Bundle savedInstanceState)
 {
     base.OnActivityCreated(savedInstanceState);
     if (savedInstanceState != null)
     {
         if (savedInstanceState.ContainsKey(MONITOR_KEY))
             startMonitor = savedInstanceState.GetBoolean(MONITOR_KEY);
         if (savedInstanceState.ContainsKey(VOICE_KEY))
             switchVoice.Checked = savedInstanceState.GetBoolean(VOICE_KEY);
     }
 }
Пример #44
0
 protected override void OnRestoreInstanceState(Bundle savedInstanceState)
 {
     if (savedInstanceState.ContainsKey("selected"))
     {
         ActionBar.SetSelectedNavigationItem(savedInstanceState.GetInt("selected"));
     }
 }
Пример #45
0
 static bool ValidOwnedItems(Bundle purchased)
 {
     return	purchased.ContainsKey (Response.InAppPurchaseItemList)
         && purchased.ContainsKey (Response.InAppPurchaseDataList)
         && purchased.ContainsKey (Response.InAppDataSignatureList);
 }
Пример #46
0
		public override void OnViewStateRestored (Bundle savedInstanceState)
		{
			base.OnViewStateRestored (savedInstanceState);
			if (savedInstanceState != null && savedInstanceState.ContainsKey ("previousPosition")) {
				var pos = savedInstanceState.GetParcelable ("previousPosition") as CameraPosition;
				if (pos != null) {
					var update = CameraUpdateFactory.NewCameraPosition (pos);
					mapFragment.Map.MoveCamera (update);
				}
			}
		}
		private void CreateRestrictions (Context context, PendingResult result, Bundle existingRestrictions) 
		{
			// The incoming restrictions bundle contains key/value pairs representing existing app
			// restrictions for this package. In order to retain existing app restrictions, you need to
			// construct new restriction entries and then copy in any existing values for the new keys.
			List <IParcelable> newEntries = InitRestrictions (context);

			// If app restrictions were not previously configured for the package, create the default
			// restrictions entries and return them.
			if (existingRestrictions == null) {
				var extras = new Bundle ();
				extras.PutParcelableArrayList (Intent.ExtraRestrictionsList, newEntries);
				result.SetResult (Result.Ok, null, extras);
				result.Finish ();
				return;
			}

			// Retains current restriction settings by transferring existing restriction entries to
			// new ones.
			foreach (RestrictionEntry entry in newEntries) {
				String key = entry.Key;

				if (KEY_BOOLEAN.Equals (key)) {
					entry.SelectedState = existingRestrictions.GetBoolean (KEY_BOOLEAN);

				} else if (KEY_CHOICE.Equals (key)) {
					if (existingRestrictions.ContainsKey (KEY_CHOICE)) {
						entry.SelectedString = existingRestrictions.GetString (KEY_CHOICE);
					}
			
				} else if (KEY_MULTI_SELECT.Equals (key)) {
					if (existingRestrictions.ContainsKey (KEY_MULTI_SELECT)) {
						entry.SetAllSelectedStrings(existingRestrictions.GetStringArray (key));
					}
				}
			}

			var extra = new Bundle();

			// This path demonstrates the use of a custom app restriction activity instead of standard
			// types.  When a custom activity is set, the standard types will not be available under
			// app restriction settings.
			//
			// If your app has an existing activity for app restriction configuration, you can set it
			// up with the intent here.
			if (PreferenceManager.GetDefaultSharedPreferences (context)
			    .GetBoolean (MainActivity.CUSTOM_CONFIG_KEY, false)) {
				var customIntent = new Intent();
				customIntent.SetClass (context, typeof (CustomRestrictionsActivity));
				extra.PutParcelable (Intent.ExtraRestrictionsIntent, customIntent);
			}

			extra.PutParcelableArrayList (Intent.ExtraRestrictionsList, newEntries);
			result.SetResult (Result.Ok, null, extra);
			result.Finish ();
		}
Пример #48
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.profile_edit_activity);
            mToolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);       
            SetSupportActionBar(mToolbar);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            svProfile = FindViewById<ScrollView>(Resource.Id.svProfile);
            txtName = FindViewById<EditText>(Resource.Id.edit_profile_name);
            txtAddress = FindViewById<EditText>(Resource.Id.edit_profile_address);
            txtUsername = FindViewById<EditText>(Resource.Id.edit_profile_username);
            txtPassword = FindViewById<EditText>(Resource.Id.edit_profile_password);
            txtPort = FindViewById<EditText>(Resource.Id.edit_profile_port);
            radioEnigma1 = FindViewById<RadioButton>(Resource.Id.rbEnigma1);
            radioEnigma2 = FindViewById<RadioButton>(Resource.Id.rbEnigma2);
            switchStreaming = FindViewById<SwitchCompat>(Resource.Id.switch_streaming);
            txtStreamingPort = FindViewById<EditText>(Resource.Id.edit_streaming_port);
            switchTranscoding = FindViewById<SwitchCompat>(Resource.Id.switch_transcoding);
            txtTranscodingPort = FindViewById<EditText>(Resource.Id.edit_transcoding_port);
            cbUseSsl = FindViewById<CheckBox>(Resource.Id.cbUseSsl);
            layoutStreaming = FindViewById<LinearLayout>(Resource.Id.layout_Streaming);
            layoutTranscoding = FindViewById<LinearLayout>(Resource.Id.layout_Transcoding);

            //update controls content
            if (bundle != null && bundle.ContainsKey(profileNameKey))
            {
                //restore state
                editProfileName = bundle.GetString(profileOriginalNameKey);
                txtName.Text = bundle.GetString(profileNameKey);
                txtAddress.Text = bundle.GetString(profileAddressKey);
                txtUsername.Text = bundle.GetString(profileUsernameKey);
                txtPassword.Text = bundle.GetString(profilePasswordKey);
                txtPort.Text = bundle.GetString(profilePortKey);
                radioEnigma1.Checked = bundle.GetBoolean(profileEnigma1Key);
                radioEnigma2.Checked = bundle.GetBoolean(profileEnigma2Key);
                switchStreaming.Checked = bundle.GetBoolean(profileStreamingKey);
                txtStreamingPort.Text = bundle.GetString(profileStreamingPortKey);
                switchTranscoding.Checked = bundle.GetBoolean(profileTranscodingKey);
                txtTranscodingPort.Text = bundle.GetString(profileTranscodingPortKey);
                cbUseSsl.Checked = bundle.GetBoolean(profileUseSslKey);
                isDirty = bundle.GetBoolean(isDirtyKey);
            }
            else if (Intent != null && Intent.HasExtra(ProfilesFragment.profileNameKey))
            {
                //edit existing profile   
                SignalMeterProfile profile = null;
                editProfileName = Intent.GetStringExtra(ProfilesFragment.profileNameKey);
            
                if (ConnectionManager.Profiles != null)
                {
                    profile = ConnectionManager.Profiles.FirstOrDefault(x => x.Name == editProfileName);
                    if (profile == null)
                        profile = new SignalMeterProfile();
                }
                else
                    profile = new SignalMeterProfile();

                txtName.Text = profile.Name;
                txtAddress.Text = profile.Address;
                txtUsername.Text = profile.Username;
                txtPassword.Text = profile.Password;
                txtPort.Text = profile.HttpPort.ToString();
                radioEnigma1.Checked = profile.Enigma == global::Krkadoni.Enigma.Enums.EnigmaType.Enigma1;
                radioEnigma2.Checked = profile.Enigma == global::Krkadoni.Enigma.Enums.EnigmaType.Enigma2;
                switchStreaming.Checked = profile.Streaming;
                txtStreamingPort.Text = profile.StreamingPort == 0 ? string.Empty : profile.StreamingPort.ToString();
                switchTranscoding.Checked = profile.Transcoding;
                txtTranscodingPort.Text = profile.TranscodingPort == 0 ? string.Empty : profile.TranscodingPort.ToString();
                cbUseSsl.Checked = profile.UseSsl;

            }
            else
            {
                //create new profile

            }

            //add event handlers
            txtName.TextChanged += (sender, e) => isDirty = true;
            txtAddress.TextChanged += (sender, e) => isDirty = true;
            txtUsername.TextChanged += (sender, e) => isDirty = true;
            txtPassword.TextChanged += (sender, e) => isDirty = true;
            txtPort.TextChanged += (sender, e) => isDirty = true;
            radioEnigma1.CheckedChange += (sender, e) => isDirty = true;
            radioEnigma2.CheckedChange += (sender, e) => isDirty = true;
            txtStreamingPort.TextChanged += (sender, e) => isDirty = true;
            txtTranscodingPort.TextChanged += (sender, e) => isDirty = true;
            cbUseSsl.CheckedChange += (sender, e) => isDirty = true;
            switchStreaming.CheckedChange += (sender, e) =>
            {
                isDirty = true;
                layoutStreaming.Visibility = switchStreaming.Checked ? ViewStates.Visible : ViewStates.Gone;
                if (switchStreaming.Checked)
                    svProfile.Post(() => svProfile.ScrollTo(0, svProfile.Bottom));
            };
            switchTranscoding.CheckedChange += (sender, e) =>
            {
                isDirty = true;
                layoutTranscoding.Visibility = switchTranscoding.Checked ? ViewStates.Visible : ViewStates.Gone;
                if (switchTranscoding.Checked)
                    svProfile.Post(() => svProfile.ScrollTo(0, svProfile.Bottom));
            };

            SupportActionBar.Title = string.IsNullOrEmpty(editProfileName) ? 
                GetString(Resource.String.action_add_profile) : 
                editProfileName;
            layoutStreaming.Visibility = switchStreaming.Checked ? ViewStates.Visible : ViewStates.Gone;
            layoutTranscoding.Visibility = switchTranscoding.Checked ? ViewStates.Visible : ViewStates.Gone;

        }