private UIViewController GetViewControllerForArExperience(ArExperience arExperience) { switch (arExperience.Extension) { case "Screenshot": CaptureScreenshotViewController captureGestureExampleScreenshotViewController = new CaptureScreenshotViewController(arExperience); return(captureGestureExampleScreenshotViewController); case "SaveAndLoadInstantTarget": SaveAndLoadInstantTargetViewController saveAndLoadInstantTargetViewController = new SaveAndLoadInstantTargetViewController(arExperience); return(saveAndLoadInstantTargetViewController); case "ObtainPoiDataFromApplicationModel": ObtainPoiDataFromApplicationModelViewController obtainPoiDataFromApplicationModelViewController = new ObtainPoiDataFromApplicationModelViewController(arExperience); return(obtainPoiDataFromApplicationModelViewController); case "NativeDetailScreen": NativeDetailsViewController nativeDetailsViewController = new NativeDetailsViewController(arExperience); return(nativeDetailsViewController); case "PoisCaptureScreen": CaptureScreenshotViewController capturePoiScreenshotViewController = new CaptureScreenshotViewController(arExperience); return(capturePoiScreenshotViewController); default: ArExperienceViewController arExperienceViewController = new ArExperienceViewController(arExperience); return(arExperienceViewController); } }
private Type GetActivityForExperience(ArExperience experience) { Type experienceActivity; switch (experience.Extension) { case "Screenshot": experienceActivity = typeof(ScreenshotActivity); break; case "SaveAndLoadInstantTarget": experienceActivity = typeof(SaveAndLoadInstantTargetActivity); break; case "ObtainPoiDataFromApplicationModel": experienceActivity = typeof(ObtainPoiDataFromApplicationModelActivity); break; case "NativeDetailScreen": experienceActivity = typeof(NativeDetailScreenActivity); break; case "PoisCaptureScreen": experienceActivity = typeof(PoisCaptureScreenActivity); break; default: experienceActivity = (experience.FeaturesMask & Features.Geo) == Features.Geo ? typeof(SimpleGeoArActivity) : typeof(SimpleArActivity); break; } return(experienceActivity); }
public void PermissionsGranted(int responseCode) { var intent = new Intent(this, typeof(UrlLauncherActivity)); intent.PutExtra(SimpleArFragment.IntentExtrasKeyExperienceData, ArExperience.Serialize(lastExperience)); StartActivity(intent); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell("example_experience_cell_identifier"); ArExperience exampleExperience = experienceGroups[indexPath.Section].ArExperiences[indexPath.Row]; cell.TextLabel.Text = exampleExperience.Name; return(cell); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { ArExperience arExperience = arExperienceGroup.ArExperiences[indexPath.Row]; UITableViewCell cell = tableView.DequeueReusableCell("custom_experience_cell_identifier"); cell.TextLabel.Text = arExperience.Path; cell.DetailTextLabel.Text = arExperience.Name; return(cell); }
public void ExperienceListChildClick(object sender, ExpandableListView.ChildClickEventArgs args) { lastExperience = experienceGroups[args.GroupPosition].ArExperiences[args.ChildPosition]; string[] permissions = (lastExperience.FeaturesMask & Features.Geo) == Features.Geo ? new string[] { Manifest.Permission.Camera, Manifest.Permission.AccessFineLocation } : new string[] { Manifest.Permission.Camera }; ArchitectView.PermissionManager.CheckPermissions(this, permissions, PermissionManager.WikitudePermissionRequest, this); args.Handled = true; }
public SaveAndLoadInstantTargetViewController(ArExperience arExperience) : base(arExperience) { var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (!Directory.Exists(documents)) { Directory.CreateDirectory(documents); } instantTargetFilePath = Path.Combine(documents, "current_instant_target.wto"); augmentationsDefinitionFilePath = Path.Combine(documents, "current_augmentations.json"); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { ArExperience selectedArExperience = arExperienceGroup.ArExperiences[indexPath.Row]; WTFeatures requiredFeatures = iOSArExperienceConverter.ConvertFeatures(selectedArExperience.FeaturesMask); ArExperienceAuthorizationController.AuthorizeRestricedAPIAccess(authorizationRequestManager, requiredFeatures, () => { ArExperienceViewController arExperienceViewController = new ArExperienceViewController(selectedArExperience); NavigationController.PushViewController(arExperienceViewController, true); }, (UIAlertController alertController) => { tableView.DeselectRow(indexPath, true); PresentViewController(alertController, true, null); }); }
public override bool ShouldPerformSegue(string segueIdentifier, NSObject sender) { bool performSegue = true; if (segueIdentifier == "WTSegueIdentifier_SaveURL") { if (existedArExperience != null) { ArExperience arExperience = ArExperienceFromCurrentInput(); if (arExperience != null) { createdArExperience = arExperience; state = State.Edited; } else { UIAlertController invalidArExperienceAlertController = UIAlertController.Create("Invalid Information Given", "The given experience URL is not ATS compliant", UIAlertControllerStyle.Alert); invalidArExperienceAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(invalidArExperienceAlertController, true, null); state = State.Error; performSegue = false; } } else { ArExperience arExperience = ArExperienceFromCurrentInput(); if (arExperience != null) { createdArExperience = arExperience; state = State.Created; } else { UIAlertController invalidArExperienceAlertController = UIAlertController.Create("Invalid Information Given", "The given experience URL is not ATS compliant", UIAlertControllerStyle.Alert); invalidArExperienceAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(invalidArExperienceAlertController, true, null); state = State.Error; performSegue = false; } } } else if (segueIdentifier == "WTSegueIdentifier_CancelURLCreation") { state = State.Cancelled; } return(performSegue); }
private void UpdateFromExistingArExperience(ArExperience arExperience) { URLTextField.Text = arExperience.Path; titleTextField.Text = arExperience.Name; ImageTrackingFeatureSwitch.On = (arExperience.FeaturesMask & Features.ImageTracking) == Features.ImageTracking ? true : false; InstantTrackingFeatureSwitch.On = (arExperience.FeaturesMask & Features.InstantTracking) == Features.InstantTracking ? true : false; ObjectTrackingFeatureSwitch.On = (arExperience.FeaturesMask & Features.ObjectTracking) == Features.ObjectTracking ? true : false; GeoARFeatureSwitch.On = (arExperience.FeaturesMask & Features.Geo) == Features.Geo ? true : false; cameraSettings[0].SelectData(CameraResolutionToString(arExperience.CameraResolution)); cameraSettings[1].SelectData(CameraPositionToString(arExperience.CameraPosition)); cameraSettings[2].SelectData(CameraFocusModeToString(arExperience.CameraFocusMode)); }
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { if (segue.DestinationViewController.GetType() == typeof(UINavigationController)) { if (sender != null && sender.GetType() == typeof(NSIndexPath)) { UINavigationController navigationController = (UINavigationController)segue.DestinationViewController; AddURLViewController addURLViewController = (AddURLViewController)navigationController.TopViewController; ArExperience selectedArExperience = arExperienceGroup.ArExperiences[((NSIndexPath)sender).Row]; addURLViewController.EditExistingArExperience(selectedArExperience); } } }
public void PermissionsGranted(int responseCode) { /* * For ArExperiences that require an interaction of JS and Native code more * advanced Activities will be loaded. * For ArExperiences that don't require any interactions either the SimpleArActivity * or the SimpleGeoArActivity are loaded. Those activites contain the least amount of * code required to use the Wikitude SDK with the addition of loading the configuarion * form Intent extras. */ var activity = GetActivityForExperience(lastExperience); var intent = new Intent(this, activity); intent.PutExtra(SimpleArActivity.IntentExtrasKeyExperienceData, ArExperience.Serialize(lastExperience)); StartActivity(intent); }
private ArExperience ArExperienceFromCurrentInput() { string title = titleTextField.Text; string URL = URLTextField.Text; Features features = FeaturesFromSwitchInputs(); CameraResolution resolution = CameraResolutionFromPickerInput(); CameraPosition position = CameraPositionFromPickerInput(); CameraFocusMode focusMode = CameraFocusModeFromPickerInput(); if (URL.Contains("https")) { ArExperience arExperience = new ArExperience(title, URL, features, position, resolution, focusMode); return(arExperience); } else { return(null); } }
protected override void OnResume() { base.OnResume(); startingAr = false; if (Intent.HasExtra(UrlLauncherExperienceGroup)) { experienceGroup = ArExperienceGroup.Deserialize(Intent.GetByteArrayExtra(UrlLauncherExperienceGroup)); } else { try { using (var stream = OpenFileInput(StorageFile)) { var formatter = new BinaryFormatter(); experienceGroup = formatter.Deserialize(stream) as ArExperienceGroup; } } catch (Java.IO.FileNotFoundException) { } } var listView = FindViewById(Resource.Id.url_list_storage_view) as ListView; listView.ItemClick += (sender, e) => { if (!startingAr) { startingAr = true; lastExperience = experienceGroup.ArExperiences[e.Position]; string[] permissions = (lastExperience.FeaturesMask & Features.Geo) == Features.Geo ? new string[] { Manifest.Permission.Camera, Manifest.Permission.AccessFineLocation } : new string[] { Manifest.Permission.Camera }; ArchitectView.PermissionManager.CheckPermissions(this, permissions, PermissionManager.WikitudePermissionRequest, this); } }; adapter = new UrlLauncherStorageListAdapter(this, experienceGroup); listView.Adapter = adapter; }
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); } }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); var experience = ArExperience.Deserialize(Arguments.GetByteArray(IntentExtrasKeyExperienceData)); var arExperiencePath = experience.Path; var config = new ArchitectStartupConfiguration { LicenseKey = GetString(Resource.String.wikitude_license_key), CameraPosition = Util.PlatformConverter.ConvertSharedToPlatformPosition(experience.CameraPosition), CameraResolution = Util.PlatformConverter.ConvertSharedToPlatformResolution(experience.CameraResolution), CameraFocusMode = Util.PlatformConverter.ConvertSharedToPlatformFocusMode(experience.CameraFocusMode), Camera2Enabled = experience.Camera2Enabled, ArFeatures = (int)experience.FeaturesMask }; architectView.OnCreate(config); architectView.OnPostCreate(); architectView.Load(arExperiencePath); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Activity_url_launcher); var experienceBytes = Intent.GetByteArrayExtra(SimpleArFragment.IntentExtrasKeyExperienceData); var experience = ArExperience.Deserialize(experienceBytes); fragment = (experience.FeaturesMask & Features.Geo) == Features.Geo ? new SimpleGeoFragment() : new SimpleArFragment(); var args = new Bundle(); args.PutByteArray(SimpleArFragment.IntentExtrasKeyExperienceData, experienceBytes); fragment.Arguments = args; var fragmentTransaction = SupportFragmentManager.BeginTransaction(); fragmentTransaction.Replace(Resource.Id.mainFragement, fragment); fragmentTransaction.Commit(); // Prevent device from sleeping Window.AddFlags(flags: WindowManagerFlags.KeepScreenOn); }
public CaptureScreenshotViewController(ArExperience arExperience) : base(arExperience) { }
public ArExperienceViewController(ArExperience arExperience) : base("ArExperienceViewController", null) { currentArExperience = arExperience; currentCaptureDevicePosition = AVCaptureDevicePosition.Unspecified; }
public NativeDetailsViewController(ArExperience arExperience) : base(arExperience) { }
private void StoreSettings() { history.Add(urlView.Text); UpdateAutocompleteSource(); var preferences = GetSharedPreferences(AutocompletePrefs, 0); var editor = preferences.Edit().PutStringSet(AutocompletePrefsHistory, history); editor.Apply(); Features features = 0; if (geoSwitch.Checked) { features |= Features.Geo; } if (imageSwitch.Checked) { features |= Features.ImageTracking; } if (instantSwitch.Checked) { features |= Features.InstantTracking; } if (objectSwitch.Checked) { features |= Features.ObjectTracking; } CameraPosition cameraPosition; var position = positionSpinner.SelectedItemId; switch (position) { case 1: cameraPosition = CameraPosition.Front; break; default: cameraPosition = CameraPosition.Back; break; } CameraResolution cameraResolution; var resolution = resolutionSpinner.SelectedItemId; switch (resolution) { case 1: cameraResolution = CameraResolution.HD_1280x720; break; case 2: cameraResolution = CameraResolution.Full_HD_1920x1080; break; case 3: cameraResolution = CameraResolution.Auto; break; default: cameraResolution = CameraResolution.SD_640x480; break; } CameraFocusMode cameraFocusMode; switch (focusSpinner.SelectedItemId) { case 1: cameraFocusMode = CameraFocusMode.AutofocusOnce; break; case 2: cameraFocusMode = CameraFocusMode.AutofocusOff; break; default: cameraFocusMode = CameraFocusMode.AutofocusContinuous; break; } var experience = new ArExperience(nameView.Text, urlView.Text, features, cameraPosition, cameraResolution, cameraFocusMode, camera2Enabled: camera2Switch.Checked); if (editPosition >= 0) { experienceGroup.ArExperiences[editPosition] = experience; } else { experienceGroup.ArExperiences.Add(experience); } var intent = new Intent(this, typeof(UrlLauncherStorageActivity)); intent.PutExtra(UrlLauncherStorageActivity.UrlLauncherExperienceGroup, ArExperienceGroup.Serialize(experienceGroup)); intent.AddFlags(ActivityFlags.ReorderToFront); StartActivity(intent); }
public ObtainPoiDataFromApplicationModelViewController(ArExperience arExperience) : base(arExperience) { locationManager = new CLLocationManager(); locationManager.LocationsUpdated += LocationsUpdated; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); /* * Used to enabled remote debugging of the ArExperience with * google chrome https://developers.google.com/web/tools/chrome-devtools/remote-debugging */ WebView.SetWebContentsDebuggingEnabled(true); if (!Intent.HasExtra(IntentExtrasKeyExperienceData)) { var message = GetString(Resource.String.error_loading_ar_experience_invalid_intent, Class.SimpleName, IntentExtrasKeyExperienceData); throw new System.Exception(message); } /* * The following code is used to run different configurations of the SimpleArActivity. * It is not required to use the ArchitectView but is used to simplify the example app. * * Because of this the Activity has to be startet with correct intent extras. * e.g.: * var experience = new ArExperience( * "ExperienceName", * "ExperiencePath", * Features.ImageTracking | Features.Geo, * CameraPosition.Back, * CameraResolution.Auto, * CameraFocusMode.Continuous, * camera2Enabled: true * ); * * var intent = new Intent(this, typeof(SimpleArActivity)); * intent.PutExtra(SimpleArActivity.IntentExtrasKeyExperienceData, ArExperience.Serialize(lastExperience)); * StartActivity(intent); */ var experience = ArExperience.Deserialize(Intent.GetByteArrayExtra(IntentExtrasKeyExperienceData)); arExperiencePath = experience.Path; /* * The ArchitectStartupConfiguration is a required parameter for architectView.OnCreate. * It controls the startup of the ArchitectView which includes camera settings, * the required device features to run the ArchitectView and the LicenseKey which * has to be set to enable an AR-Experience. */ var config = new ArchitectStartupConfiguration // Creates a config with its default values. { LicenseKey = GetString(Resource.String.wikitude_license_key), // Has to be set, to get a trial license key visit http://www.wikitude.com/developer/licenses. CameraPosition = Util.PlatformConverter.ConvertSharedToPlatformPosition(experience.CameraPosition), // The default camera is the first camera available for the system. CameraResolution = Util.PlatformConverter.ConvertSharedToPlatformResolution(experience.CameraResolution), // The default resolution is 640x480. CameraFocusMode = Util.PlatformConverter.ConvertSharedToPlatformFocusMode(experience.CameraFocusMode), // The default focus mode is continuous auto focus. Camera2Enabled = experience.Camera2Enabled, // The camera2 api is enabled by default on devices that support it. ArFeatures = (int)experience.FeaturesMask // This tells the ArchitectView which AR-features it is going to use, the default is all of them. }; architectView = new ArchitectView(this); architectView.OnCreate(config); // Mandatory ArchitectView lifecycle call SetContentView(architectView); // Adds the architectView to the activity. // Prevent device from sleeping Window.AddFlags(flags: WindowManagerFlags.KeepScreenOn); }
public void EditExistingArExperience(ArExperience arExperience) { existedArExperience = arExperience; }