//Set the extension to the dropdown and set MIME type to the list from the specified extensions. //指定された拡張子から、ドロップダウンに拡張子をセットし、リストに MIME type をセットする。 private void CreateExtAndMimeListToDropdown(Dropdown dropdown, ref List <string[]> mimeList, string[] extArray, bool addTextAll = true) { if (dropdown == null || extArray == null || extArray.Length == 0) { return; } List <string> extList = new List <string>(); mimeList = new List <string[]>(); if (addTextAll) { extList.Add("*"); mimeList.Add(new string[] { AndroidMimeType.File.TextAll }); } foreach (var ext in extArray) { extList.Add(ext); var mime = AndroidMimeType.GetMimeType(ext); if (mime != null) { mimeList.Add(mime); } else { mimeList.Add(new string[] { AndroidMimeType.File.All }); } } dropdown.ClearOptions(); dropdown.AddOptions(extList); }
//Dynamically generate file name to be saved and open system storage application. //保存するファイル名を動的に生成し、システムストレージアプリを開く。 public void SaveText() { if (storageSaveTextControl != null && displayText != null && !string.IsNullOrEmpty(displayText.text)) { if (autoSaveFileName) { string file = filePrefix; if (appendDateTimeString) { file += "_" + DateTime.Now.ToString("yyMMdd_HHmmss"); } if (string.IsNullOrEmpty(file)) { file = "NewDocumet"; } if (!file.EndsWith(".txt")) { file += ".txt"; } if (storageSaveTextControl.syncExtension) { var ext = AndroidMimeType.GetExtension(storageSaveTextControl.MimeType); if (ext != null) { file = Path.ChangeExtension(file, ext[0]); } } storageSaveTextControl.CurrentValue = file; } storageSaveTextControl.Show(displayText.text); } }
//Set the extension to the dropdown and set MIME type to the list from MIME type constant values. //MIME type 定数から、ドロップダウンに拡張子をセットし、リストに MIME type をセットする。 private void CreateExtAndMimeListToDropdown(Dropdown dropdown, ref List <string[]> mimeList, AndroidMimeType.MediaType mediaType, bool addAll = true) { if (dropdown == null) { return; } List <string> extList = new List <string>(); mimeList = new List <string[]>(); if (addAll) { switch (mediaType) { case AndroidMimeType.MediaType.File: extList.Add("*"); mimeList.Add(new string[] { AndroidMimeType.File.All }); break; case AndroidMimeType.MediaType.Image: extList.Add("*"); mimeList.Add(new string[] { AndroidMimeType.Image.All }); break; case AndroidMimeType.MediaType.Audio: extList.Add("*"); mimeList.Add(new string[] { AndroidMimeType.Audio.All }); break; case AndroidMimeType.MediaType.Video: extList.Add("*"); mimeList.Add(new string[] { AndroidMimeType.Video.All }); break; default: break; } } List <string> ext; List <string[]> mime; AndroidMimeType.GetExtToMimeList(mediaType, out ext, out mime); extList.AddRange(ext); mimeList.AddRange(mime); dropdown.ClearOptions(); dropdown.AddOptions(extList); }