Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ArExperienceGroup restoredArExperienceGroup = ArExperienceManager.OpenFromFile(persitentArExperienceGroupFilePath);

            if (restoredArExperienceGroup != null)
            {
                arExperienceGroup = restoredArExperienceGroup;
            }
        }
        public ExperienceSelectionViewController(IntPtr handle) : base(handle)
        {
            NSUrl exampleDefinitionsFileURL = NSBundle.MainBundle.GetUrlForResource("samples", "json", "ARchitectExamples");

            if (exampleDefinitionsFileURL != null)
            {
                NSData   exampleExperienceData        = NSData.FromUrl(exampleDefinitionsFileURL);
                NSString exampleExperienceDefinitions = NSString.FromData(exampleExperienceData, NSStringEncoding.UTF8);
                experienceGroups = ArExperienceManager.ParseExampleDefintion(exampleExperienceDefinitions);
            }
        }
Example #3
0
        public override UITableViewRowAction[] EditActionsForRow(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewRowAction deleteRowAction = UITableViewRowAction.Create(UITableViewRowActionStyle.Destructive, "Delete", (UITableViewRowAction rowAction, NSIndexPath actionIndexPath) =>
            {
                arExperienceGroup.ArExperiences.RemoveAt(actionIndexPath.Row);
                tableView.DeleteRows(new NSIndexPath[] { actionIndexPath }, UITableViewRowAnimation.Right);
                ArExperienceManager.WriteToFile(persitentArExperienceGroupFilePath, arExperienceGroup);
            });

            UITableViewRowAction editRowAction = UITableViewRowAction.Create(UITableViewRowActionStyle.Default, "Edit", (UITableViewRowAction rowAction, NSIndexPath actionIndexPath) =>
            {
                PerformSegue("add_url_view_controller_segue", actionIndexPath);
            });

            editRowAction.BackgroundColor = UIColor.FromRGB(0.060f, 0.502f, 0.998f);

            return(new UITableViewRowAction [] { deleteRowAction, editRowAction });
        }
Example #4
0
        public void ComeBackFromAddURLViewController(UIStoryboardSegue segue)
        {
            if (segue.SourceViewController.GetType() == typeof(AddURLViewController))
            {
                AddURLViewController addURLViewController = (AddURLViewController)segue.SourceViewController;
                if (addURLViewController.GetState() == AddURLViewController.State.Created)
                {
                    ArExperience arExperience = addURLViewController.CreatedArExperience();
                    arExperienceGroup.ArExperiences.Insert(0, arExperience);

                    TableView.InsertRows(new NSIndexPath[] { NSIndexPath.Create(new int[] { 0, 0 }) }, UITableViewRowAnimation.Top);
                }
                else if (addURLViewController.GetState() == AddURLViewController.State.Edited)
                {
                    ArExperience updatedArExperience = addURLViewController.UpdatedArExperience();
                    int          index = arExperienceGroup.ArExperiences.FindIndex(x => x == updatedArExperience);
                    arExperienceGroup.ArExperiences[index] = addURLViewController.CreatedArExperience();
                    TableView.ReloadRows(new NSIndexPath[] { NSIndexPath.Create(new int[] { 0, index }) }, UITableViewRowAnimation.Automatic);
                }
                ArExperienceManager.WriteToFile(persitentArExperienceGroupFilePath, arExperienceGroup);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Activity_Main);

            /*
             * Loads the experience definiton file from the assets and parses the content to
             * ArExperienceGroups.
             */
            var          stream = Assets.Open("samples/samples.json");
            StreamReader sr     = new StreamReader(stream);

            experienceGroups = ArExperienceManager.ParseExampleDefintion(sr.ReadToEnd());
            sr.Close();

            /*
             * Removes all ArExperiences that are not supported on the current device because
             * of missing hardware requirements like sensors.
             */
            int removedExperiences = FilterUnsupportedArExperiences(this, experienceGroups);

            if (removedExperiences > 0)
            {
                string message = GetString(Resource.String.error_loading_ar_experience_unsupported, removedExperiences);
                Toast.MakeText(this, message, ToastLength.Long).Show();
            }

            /*
             * Fills the ExpandableListView with all remaining ArExperiences.
             */
            var adapter = new Util.adapters.ArExpandableListAdapter(this, experienceGroups);

            listView = FindViewById(Resource.Id.listView) as ExpandableListView;
            MoveExpandableIndicatorToRight();
            listView.ChildClick += ExperienceListChildClick;
            listView.SetAdapter(adapter);

            /*
             * Sets the title and the menu of the Toolbar. The menu contains two items
             * one for laoding a custom ArExperience from a URL and one for showing informations about
             * the Version of the Wikitude SDK.
             */
            var toolbar = FindViewById(Resource.Id.toolbar) as Android.Support.V7.Widget.Toolbar;

            toolbar.InflateMenu(Resource.Menu.main_menu);
            toolbar.MenuItemClick += (sender, args) => {
                switch (args.Item.ItemId)
                {
                case Resource.Id.menu_main_load_url:
                    var intent = new Intent(this, typeof(UrlLauncherStorageActivity));
                    StartActivity(intent);
                    args.Handled = true;
                    break;

                case Resource.Id.menu_main_info:
                    var sdkBuildInformation = ArchitectView.SDKBuildInformation;
                    new Android.Support.V7.App.AlertDialog.Builder(this)
                    .SetTitle(Resource.String.build_information_title)
                    .SetMessage(
                        GetString(Resource.String.build_information_config) + sdkBuildInformation.BuildConfiguration + "\n" +
                        GetString(Resource.String.build_information_date) + sdkBuildInformation.BuildDate + "\n" +
                        GetString(Resource.String.build_information_number) + sdkBuildInformation.BuildNumber + "\n" +
                        GetString(Resource.String.build_information_version) + ArchitectView.SDKVersion)
                    .Show();
                    args.Handled = true;
                    break;

                default:
                    args.Handled = false;
                    break;
                }
            };
            toolbar.SetTitle(Resource.String.app_name);
        }