Exemple #1
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            if (savedInstanceState != null)
            {
                e = ExhibitManager.GetExhibit(savedInstanceState.GetString(Data));
            }


            var alert = new AlertDialog.Builder(Activity);

            alert.SetTitle(Resources.GetString(Resource.String.exhibit_is__near_title));
            alert.SetMessage($"{Activity.Resources.GetString (Resource.String.exhibit_is_near1)} \"{e.Name}\" {Activity.Resources.GetString (Resource.String.exhibit_is_near2)}");
            alert.SetPositiveButton(Resource.String.exhibit_open_yes, (senderAlert, args) => {
                var intent   = new Intent(Activity, typeof(ExhibitDetailsActivity));
                var pageList = e.Pages;
                if ((pageList == null) || !pageList.Any())
                {
                    Toast.MakeText(Activity,
                                   Activity.GetString(Resource.String.currently_no_further_info),
                                   ToastLength.Short).Show();
                }
                else
                {
                    intent.PutExtra(ExhibitDetailsActivity.INTENT_EXTRA_EXHIBIT_ID, e.Id);
                    Activity.StartActivity(intent);
                }
            });

            alert.SetNegativeButton(Resource.String.exhibit_open_no, (senderAlert, args) => { ExtendedLocationListener.GetInstance().EnableCheckForExhibits(); });

            return(alert.Create());
        }
Exemple #2
0
 public DummyViewModel()
 {
     Color       = Color.Blue;
     Title       = "Dummy";
     TestCommand = new Command(() => {
         var exhibits = ExhibitManager.GetExhibits();
         var ex       = exhibits.FirstOrDefault();
         Navigation.PushAsync(new ExhibitDetailsViewModel(ex.Id));
     });
 }
        private List <ExhibitCellViewModel> LoadExhibitsData()
        {
            List <ExhibitCellViewModel> exhibits     = new List <ExhibitCellViewModel>();
            IEnumerable <Exhibit>       exhibitsData = ExhibitManager.GetExhibits();

            foreach (Exhibit exhibit in exhibitsData)
            {
                ExhibitCellViewModel exhibitCellModel = new ExhibitCellViewModel(exhibit.Id, exhibit.Image, exhibit.Name);
                exhibits.Add(exhibitCellModel);
            }

            return(exhibits);
        }
Exemple #4
0
        public ViaPointInfoWindow(int layoutResId, MapView mapView, Context context) : base(layoutResId, mapView)
        {
            Button infoButton = this.View.FindViewById <Button> (Resource.Id.bubble_info);

            infoButton.Click += (sender, e) => {
                if (markerID != null)
                {
                    var intent  = new Intent(context, typeof(ExhibitDetailsActivity));
                    var exhibit = ExhibitManager.GetExhibit(markerID);
                    if (exhibit.Id != null)
                    {
                        intent.PutExtra(ExhibitDetailsActivity.INTENT_EXTRA_EXHIBIT_ID, markerID);
                    }
                    context.StartActivity(intent);
                }
            };
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.RetainInstance = true;
            if (savedInstanceState != null)
            {
                var latitude  = savedInstanceState.GetDouble(KeyGeoLocationLatitude);
                var longitude = savedInstanceState.GetDouble(KeyGeoLocationLongitude);
                GeoLocation = new GeoLocation
                {
                    Latitude  = latitude,
                    Longitude = longitude
                };

                var exhibitId = savedInstanceState.GetString(KeyExhibitSetId);
                ExhibitSet = ExhibitManager.GetExhibitSet(exhibitId);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Exhibit          = ExhibitManager.GetExhibit(ExhibitID);
            ExhibitAppetizer = Exhibit.Pages[0].AppetizerPage; // each exhibit page list should have for first element an appetizer page
            if (ExhibitAppetizer != null)
            {
                NavigationItem.Title = ExhibitTitle;
                NSData imageData = NSData.FromArray(ExhibitAppetizer.Image.Data);
                appetizerImageView.Image = new UIImage(imageData);

                var titleAttributes = new UIStringAttributes
                {
                    Font = UIFont.BoldSystemFontOfSize(13)
                };

                NSMutableAttributedString attributedString = new NSMutableAttributedString(ExhibitTitle + "\n\n" + ExhibitAppetizer.Text);
                attributedString.SetAttributes(titleAttributes, new NSRange(0, ExhibitTitle.Length));
                appetizerTextView.AttributedText = attributedString;
            }
            NavigationItem.BackBarButtonItem = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);
        }
        public void Load()
        {
            Task.Factory.StartNew(async() => {
                IoCManager.RegisterType <IDataAccess, RealmDataAccess>();
                IoCManager.RegisterType <IDataLoader, EmbeddedResourceDataLoader>();
                IoCManager.RegisterInstance(typeof(ApplicationResourcesProvider), new ApplicationResourcesProvider(Application.Current.Resources));

                IoCManager.RegisterInstance(typeof(INearbyExhibitManager), new NearbyExhibitManager());
                IoCManager.RegisterInstance(typeof(INearbyRouteManager), new NearbyRouteManager());

                // show text, progress bar and image when db is initialized, otherwise just the indicator is shown
                if (!DbManager.IsDatabaseUpToDate())
                {
                    IsExtendedViewsVisible = true;
                }
                DbManager.UpdateDatabase(this);

                // force the db to load the exhibitset into cache
                ExhibitManager.GetExhibitSets();
                LoadingProgress = 0.9;
                await Task.Delay(100);

                // if the app is not sleeping open the main menu, otherwise wait for it to wake up
                startupAction = async() => {
                    var vm          = new MainPageViewModel();
                    LoadingProgress = 1;
                    await Task.Delay(100);

                    MessagingCenter.Unsubscribe <App> (this, AppSharedData.WillSleepMessage);
                    MessagingCenter.Unsubscribe <App> (this, AppSharedData.WillWakeUpMessage);
                    Navigation.StartNewNavigationStack(vm);
                };
                if (!isSleeping)
                {
                    Device.BeginInvokeOnMainThread(startupAction);
                }
            });
        }
 public MainPageViewModel() : this(ExhibitManager.GetExhibitSets().FirstOrDefault())
 {
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //initialize media player
            mediaPlayerConnection = new CustomServiceConnection(this);
            DoBindService();

            SetContentView(Resource.Layout.activity_exhibit_details);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            }

            var toolbar = (Toolbar)FindViewById(Resource.Id.toolbar);

            toolbar.SetNavigationIcon(Resource.Drawable.ic_clear_white_24dp);
            SetSupportActionBar(toolbar);
            audioSeekbar = FindViewById <SeekBar> (Resource.Id.audio_progress_bar);
            audioSeekbar.ProgressChanged += (sender, args) => {
                if (mediaPlayerService != null && args.FromUser)
                {
                    mediaPlayerService.SeekTo(args.Progress);
                }
            };

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);

            if (savedInstanceState != null)
            {
                // activity re-creation because of device rotation, instant run, ...
                exhibitId        = savedInstanceState.GetString(KEY_EXHIBIT_ID);
                exhibit          = ExhibitManager.GetExhibit(exhibitId);
                currentPageIndex = savedInstanceState.GetInt(KEY_CURRENT_PAGE_INDEX, 0);
                isAudioPlaying   = savedInstanceState.GetBoolean(KEY_AUDIO_PLAYING, false);
                if (!isAudioPlaying)
                {
                    pauseAudioPlaybackFlag = true;
                }
                isAudioToolbarHidden = savedInstanceState.GetBoolean(KEY_AUDIO_TOOLBAR_HIDDEN, true);
                if (!isAudioToolbarHidden)
                {
                    showAudioToolbarFlag = true;
                }
                extras         = savedInstanceState.GetBundle(KEY_EXTRAS);
                isCaptionShown = savedInstanceState.GetBoolean(KEY_CAPTION_SHOWN);

                var selectedTab   = savedInstanceState.GetInt(KEY_CURRENT_CAPTION_TAB);
                var currentSource = savedInstanceState.GetInt(KEY_CURRENT_SOURCE);

                if (isCaptionShown)
                {
                    ShowCaptions(selectedTab, currentSource);
                }

                isHelpDialogShown = savedInstanceState.GetBoolean(KEY__HELP_DIALOG_SHOWN, false);
                isSwitchToNextPageAutomatically = savedInstanceState.GetBoolean(KEY_PAGE_SWITCH_BASED_ON_SETTINGS, false);
            }
            else
            {
                // activity creation because of intent
                var intent = Intent;
                extras    = intent.Extras;
                exhibitId = intent.GetStringExtra(INTENT_EXTRA_EXHIBIT_ID);
                exhibit   = ExhibitManager.GetExhibit(exhibitId);
            }
            Title = exhibit.Name;

            if (exhibit.Pages.Count == 0)
            {
                throw new NullPointerException("Cannot display exhibit with no pages.");
            }

            // set up bottom sheet behavior
            bottomSheet         = FindViewById(Resource.Id.bottom_sheet);
            bottomSheetBehavior = BottomSheetBehavior.From(bottomSheet);
            bottomSheetBehavior.SetBottomSheetCallback(new CustomBottomSheetCallback(this));

            // audio toolbar
            revealView            = (LinearLayout)FindViewById(Resource.Id.reveal_items);
            revealView.Visibility = ViewStates.Invisible;

            // Does not work with animations:
            // see also: http://stackoverflow.com/questions/7289827/how-to-start-animation-immediately-after-oncreate

            // set up play / pause toggle
            btnPlayPause        = (ImageButton)FindViewById(Resource.Id.btnPlayPause);
            btnPlayPause.Click += (sender, args) => {
                if (isAudioPlaying)
                {
                    PauseAudioPlayback();
                    isAudioPlaying = false;
                }
                else
                {
                    StartAudioPlayback();
                    isAudioPlaying = true;
                    btnPlayPause.SetImageResource(Android.Resource.Color.Transparent);
                }
                UpdatePlayPauseButtonIcon();
            };

            // set up CC button
            var btnCaptions = (ImageButton)FindViewById(Resource.Id.btnCaptions);

            btnCaptions.Click += (sender, args) => { ShowCaptions(); };

            // set up previous / next button
            btnPreviousPage        = (ImageButton)FindViewById(Resource.Id.buttonPrevious);
            btnPreviousPage.Click += (sender, args) => { DisplayPreviousExhibitPage(); };

            btnNextPage        = (ImageButton)FindViewById(Resource.Id.buttonNext);
            btnNextPage.Click += (sender, args) => { DisplayNextExhibitPage(); };

            fab        = (FloatingActionButton)FindViewById(Resource.Id.fab);
            fab.Click += (sender, args) => {
                switch (fabAction)
                {
                case BottomSheetConfig.FabAction.Next:
                    DisplayNextExhibitPage();
                    break;

                case BottomSheetConfig.FabAction.Collapse:
                    SetFabAction(BottomSheetConfig.FabAction.Expand);
                    break;

                case BottomSheetConfig.FabAction.Expand:
                    SetFabAction(BottomSheetConfig.FabAction.Collapse);
                    break;

                default:
                    throw new IllegalArgumentException("Unsupported FAB action!");
                }
            };
        }
 public ExhibitDetailsViewModel(string exhibitId) : this(ExhibitManager.GetExhibit(exhibitId).Pages, ExhibitManager.GetExhibit(exhibitId).Name)
 {
 }
 public ExhibitsOverviewViewModel(string exhibitSetId) : this(ExhibitManager.GetExhibitSet(exhibitSetId))
 {
 }
Exemple #12
0
 /// <summary>
 ///     Since the ExtendedLocationListener will be created as a singleton from a static context,
 ///     it can't get any attributes during creation and neither during getting an instance of it.
 ///     Thus, the programmer has to make sure to give the ExtendedLocationListener a context
 ///     right after callinge getInstance(), otherwise the class is useless.
 /// </summary>
 private ExtendedLocationListener()
 {
     exhibitSet      = ExhibitManager.GetExhibitSet();
     checkedExhibits = new List <string> ();
 }
Exemple #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            //it crashes on versions below 21
            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            }

            // Check if we have the necessary permissions and request them if we don't
            // Note that the app will still fail on first launch and needs to be restarted
            SetUpPermissions();

            InitializeExtendedLocationListener();


            geoLocation = new GeoLocation
            {
                Latitude  = extendedLocationListener.Latitude,
                Longitude = extendedLocationListener.Longitude
            };

            exhibitSet = ExhibitManager.GetExhibitSets().First();

            //Permissions
            SetUpPermissions();

            // Navigation Drawer
            SetUpNavigationDrawer();

            //FeedbackManager.Register(this);
            FeedbackManager.Register(this, KeyManager.Instance.GetKey("hockeyapp.android"), new HipFeedbackListener());

            if (savedInstanceState == null)
            {
                // Set overview fragment
                exhibitsOverviewFragment = new ExhibitsOverviewFragment
                {
                    ExhibitSet  = exhibitSet,
                    GeoLocation = geoLocation
                };

                if (FindViewById(Resource.Id.main_fragment_container) != null)
                {
                    var transaction = SupportFragmentManager.BeginTransaction();
                    transaction.Replace(Resource.Id.main_fragment_container, exhibitsOverviewFragment);
                    transaction.Commit();
                }
            }
            else
            {
                askForUpdates            = savedInstanceState.GetBoolean(UpdateKey);
                exhibitsOverviewFragment = (ExhibitsOverviewFragment)SupportFragmentManager.GetFragment(savedInstanceState, ExhibitsOverviewFragString);
            }


            // hockeyapp code
            if (askForUpdates)
            {
                CheckForUpdates();
            }
        }