private void Accessory_Click(object sender, EventArgs e) { if (!Pair.RaiseEvent(nameof(AccessorySelected), EventArgs.Empty)) { DroidFactory.Navigate(AccessoryLink, Parent); } }
public static void Stop() { _recordingDialog?.Dismiss(); _recordingDialog = null; // stop recording try { _mic.Stop(); } catch (Exception e) { Device.Log.Warn(e); } // prepare object for GC by calling dispose _mic.Release(); _mic.Dispose(); _mic = null; if (_callback != null) { DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string> { { CallbackParam, _callbackId }, })); } }
public void OnSensorChanged(SensorEvent e) { for (int i = 0; i < 3; i++) { data[i] += e.Values[i]; } if (mCount++ <= 10) { return; } mCount = 0; ((SensorManager)DroidFactory.MainActivity.GetSystemService(Context.SensorService)). UnregisterListener(this); if (locationGetter != null) { locationGetter.Dismiss(); locationGetter = null; } if (_accel.CallbackUrl != null) { DroidFactory.Navigate(_accel, new Dictionary <string, string> { { "X", (data[0] / 10).ToString(CultureInfo.InvariantCulture) }, { "Y", (data[1] / 10).ToString(CultureInfo.InvariantCulture) }, { "Z", (data[2] / 10).ToString(CultureInfo.InvariantCulture) }, }); } _accel = null; }
public static void Start(string audioFilePath) { if (audioFilePath == null) { return; } // first stop any active audio on MediaPlayer instance if (_player != null) { Stop(); } _player = new MediaPlayer(); if (_player == null) { throw new Exception("Could not load MediaPlayer"); } _player.SetDataSource(new Java.IO.FileInputStream(audioFilePath).FD); _player.Prepare(); _player.Completion += (sender, args) => { Stop(); if (_callback == null) { return; } DroidFactory.Navigate(_callback); _callback = null; }; _player.Start(); }
private void Alert_DismissEvent(object sender, EventArgs e) { if (Buttons == AlertButtons.YesNo) { _result += 2; } var handler = Dismissed; if (handler != null) { handler(this, new AlertResultEventArgs(_result)); } else { switch (_result) { case AlertResult.OK: case AlertResult.Yes: DroidFactory.Navigate(OKLink); break; case AlertResult.Cancel: case AlertResult.No: DroidFactory.Navigate(CancelLink); break; } } Instance = null; _result = AlertResult.Cancel; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { var view = inflater.Inflate(Resource.Layout.popover, null); view.FindViewById <Button>(Resource.Id.action).Click += (o, e) => { var menu = GetMenu(); if (menu == null || menu.ButtonCount <= 0) { return; } var button = menu.GetButton(0); if (!button.RaiseEvent(nameof(button.Clicked), EventArgs.Empty)) { DroidFactory.Navigate(button.NavigationLink, _stack.CurrentView); } }; view.FindViewById <ImageButton>(Resource.Id.options).Click += Menu.Activated; var homeAction = view.FindViewById <ImageButton>(Resource.Id.home); homeAction.SetImageDrawable(Resources.GetDrawable(Activity.ApplicationInfo.Icon)); homeAction.Click += (o, e) => Activity.OnBackPressed(); UpdateTitle(view); return(view); }
private void OnClick(object o, EventArgs e) { if (this.RaiseEvent(nameof(Clicked), EventArgs.Empty)) { return; } DroidFactory.Navigate(NavigationLink, Parent); }
public static void OnVideoResult(Uri result, bool deleteFile = false) { var loader = ProgressDialog.Show(DroidFactory.MainActivity, string.Empty, iApp.Factory.GetResourceString("SaveVideo") ?? "Saving video...", true); iApp.Thread.QueueWorker(o => { string extension = null; var uriString = result?.ToString().ToLowerInvariant() ?? string.Empty; if (uriString.StartsWith("content:")) { extension = MimeTypeMap.Singleton.GetExtensionFromMimeType(DroidFactory.MainActivity.ContentResolver.GetType(result)); } else if (uriString.StartsWith("file://")) { extension = uriString.Substring(uriString.LastIndexOf('.') + 1); } if (extension == null) { Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("InvalidFile") ?? "Invalid file", ToastLength.Short).Show(); return; } var mime = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension); if (mime == null || !mime.StartsWith("video")) { Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("InvalidFile") ?? "Invalid file", ToastLength.Short).Show(); return; } string videoId = null; try { videoId = DroidFactory.Instance.StoreImage(result, extension); if (deleteFile) { DroidFactory.MainActivity.ContentResolver.Delete(result, null, null); } } catch (IOException e) { iApp.Log.Error(e); Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("VideoError") ?? "There was a problem saving the video. Please check your disk usage.", ToastLength.Long).Show(); } DroidFactory.MainActivity.RunOnUiThread(loader.Dismiss); if (_callback == null) { return; } DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string> { { CallbackParam, videoId } })); _callback = null; }); }
public static void OnVideoPlaybackResult() { if (_callback == null) { return; } DroidFactory.Navigate(_callback); _callback = null; }
private void OnClick(object o, EventArgs e) { TextBase.CurrentFocus?.Blur(true); if (this.RaiseEvent(nameof(Clicked), EventArgs.Empty)) { return; } var view = Parent as GridBase; DroidFactory.Navigate(NavigationLink, view?.Parent); }
private void OnClick(object sender, EventArgs e) { if (this.RaiseEvent("Clicked", EventArgs.Empty)) { return; } var toolContainer = Parent as LinearLayout; var view = toolContainer?.Parent as Toolbar; DroidFactory.Navigate(NavigationLink, view?.Parent); }
public void Select() { if (Parent is ListViewFragment listViewFragment) { listViewFragment.SelectedIndex = Metadata.Get <int>("Index"); } if (!this.RaiseEvent(nameof(Selected), EventArgs.Empty)) { DroidFactory.Navigate(NavigationLink, Parent); } }
public static void OnClick(IMenu menu, int index, IMXView view) { if (menu.ButtonCount <= 0) { return; } var button = menu.GetButton(index); if (!button.RaiseEvent("Clicked", EventArgs.Empty) && (button.Pair == null || !button.Pair.RaiseEvent("Clicked", EventArgs.Empty))) { DroidFactory.Navigate(button.NavigationLink, view); } Device.Log.Platform($"Clicked menu item \"{button.Title}\""); }
public static void OnGalleryResult(Uri uri) { var extension = "jpg"; var uriString = uri?.ToString().ToLowerInvariant() ?? string.Empty; if (uriString.StartsWith("content:")) { extension = MimeTypeMap.Singleton.GetExtensionFromMimeType(DroidFactory.MainActivity.ContentResolver.GetType(uri)); } else if (uriString.StartsWith("file://")) { extension = uriString.Substring(uriString.LastIndexOf('.') + 1); } if (extension == null) { Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("InvalidFile") ?? "Invalid file", ToastLength.Short).Show(); return; } var mime = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension); if (mime == null || !mime.StartsWith("image")) { Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("InvalidFile") ?? "Invalid file", ToastLength.Short).Show(); return; } var imageId = DroidFactory.Instance.StoreImage(uri, extension); if (_callback == null) { return; } DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string> { { CallbackParam, imageId }, })); _callback = null; }
public void Submit(Link link) { if (link.Parameters == null) { link.Parameters = new Dictionary <string, string>(); } var layer = _model as iLayer; var submitValues = layer != null?layer.GetFieldValues() : GetSubmissionValues(); var submissionHandler = Submitting; if (submissionHandler == null) { if (Validate()) { link.Parameters.AddRange(submitValues); DroidFactory.Navigate(link, this); } else { Invalidate(); new Alert(iApp.Factory.GetResourceString("ValidationFailure"), string.Empty, AlertButtons.OK).Show(); } return; } var args = new SubmissionEventArgs(link, ValidationErrors); submissionHandler(Pair ?? this, args); if (args.Cancel) { return; } link.Parameters.AddRange(submitValues); DroidFactory.Navigate(link, this); }
/// <summary> /// This hook is called whenever an item in the options menu is selected. The default implementation /// simply returns false to have the normal processing happen (calling the item's Runnable or sending /// a message to its Handler as appropriate). You can use this method for any items for which you would /// like to do processing without those other facilities.<br/> /// Derived classes should call through to the base class for it to perform the default menu handling. /// </summary> /// <param name="item">The menu item that was selected.</param> /// <returns><c>false</c> to allow normal menu processing to proceed, <c>true</c> to consume it here.</returns> public override bool OnOptionsItemSelected(IMenuItem item) { if (item == null || item.ItemId != Android.Resource.Id.Home) { return(base.OnOptionsItemSelected(item)); } var masterStack = PaneManager.Instance.FromNavContext(Pane.Master, PaneManager.Instance.CurrentTab); var masterView = masterStack?.CurrentView as IHistoryEntry; var back = masterView?.BackLink; if (back != null && back.Action == ActionType.None) { return(false); } Link currentTabLink; if ((ActionBar?.DisplayOptions & ActionBarDisplayOptions.HomeAsUp) == ActionBarDisplayOptions.HomeAsUp) { DroidFactory.HideKeyboard(false); masterStack?.HandleBackLink(back, Pane.Master); } else if ((currentTabLink = DroidFactory.Tabs?.TabItems?.ElementAtOrDefault(PaneManager.Instance.CurrentTab)?.NavigationLink) == null) { if (masterView != null) { masterView.OutputPane = Pane.Tabs; } DroidFactory.Navigate(new Link(iApp.Instance.NavigateOnLoad)); } else { DroidFactory.Navigate(currentTabLink, DroidFactory.Tabs); } return(true); }
public static void OnCameraResult() { // Some versions of Android save to the MediaStore as well as the ExtraOutput. // Not sure why! We don't know what name Android will give either, so we get // to search for this manually and remove it. string[] projection = { MediaStore.Images.ImageColumns.Size, MediaStore.Images.ImageColumns.DisplayName, MediaStore.Images.ImageColumns.Data, BaseColumns.Id }; // intialize the Uri and the Cursor, and the current expected size. ICursor c = null; var u = MediaStore.Images.Media.ExternalContentUri; if (_currentFile == null) { return; } // Query the Uri to get the data path. Only if the Uri is valid, // and we had a valid size to be searching for. if ((u != null) && (_currentFile.Length() > 0)) { c = DroidFactory.MainActivity.ManagedQuery(u, projection, null, null, null); } // If we found the cursor and found a record in it (we also have the size). if ((c != null) && c.MoveToFirst()) { do { // Check each previously-built area in the gallery. if (GalleryList.Any(sGallery => string.Equals(sGallery, c.GetString(1), StringComparison.InvariantCultureIgnoreCase))) { continue; } // This is the NEW image. If the size is bigger, copy it. // Then delete it! var f = new File(c.GetString(2)); // Ensure it's there, check size, and delete! if (f.Exists() && (_currentFile.Length() < c.GetLong(0)) && _currentFile.Delete()) { // Finally we can stop the copy. try { FileInputStream source = null; try { source = new FileInputStream(f); var fileContent = new byte[f.Length()]; source.Read(fileContent); iApp.File.Save(_currentFile.AbsolutePath, fileContent, EncryptionMode.NoEncryption); } finally { source?.Close(); } } catch (IOException) { // Could not copy the file over. Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("ErrorText") ?? "An error occurred. Please try again.", ToastLength.Short).Show(); } } DroidFactory.MainActivity.ContentResolver.Delete(MediaStore.Images.Media.ExternalContentUri, BaseColumns.Id + "=" + c.GetString(3), null); break; }while (c.MoveToNext()); } var id = _currentFile.Name.Remove(_currentFile.Name.LastIndexOf('.')); DroidFactory.Instance.StoreImage(Uri.FromFile(_currentFile), "jpg", id); iApp.File.Delete(_currentFile.Path); if (_callback == null) { return; } DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string> { { CallbackParam, id }, })); _callback = null; }