예제 #1
0
        public void OnIsWallpaperSupportedAndAllowed()
        {
            var isSupported = AGWallpaperManager.IsWallpaperSupported();
            var isAllowed   = AGWallpaperManager.IsSetWallpaperAllowed();

            AGUIMisc.ShowToast(string.Format("Wallpaper supported? - {0}, set allowed? - {1}", isSupported, isAllowed));
        }
예제 #2
0
 public void OnMessageTwoButtonDialog()
 {
     AGAlertDialog.ShowMessageDialog("Two Buttons", "This dialog has positive and negative button",
                                     "Ok", () => AGUIMisc.ShowToast("Positive button Click"),
                                     "No!", () => AGUIMisc.ShowToast("Negative button Click"),
                                     () => AGUIMisc.ShowToast("Dismissed"), AGDialogTheme.Dark);
 }
예제 #3
0
    public void OpenCamera()
    {
        AGUIMisc.ShowToast("Opening Camera");
        var shouldGenerateThumbnails = false;

        // if image is larger it will be downscaled to the max size proportionally
        var imageResultSize = ImageResultSize.Max1024;

        AGCamera.TakePhoto(
            selectedImage =>
        {
            // Load received image into Texture2D
            var imageTexture2D  = selectedImage.LoadTexture2D();
            this.imageToGallery = imageTexture2D;
            string msg          = string.Format("{0} was taken from camera with size {1}x{2}",
                                                selectedImage.DisplayName, imageTexture2D.width, imageTexture2D.height);
            AGUIMisc.ShowToast(msg);
            Debug.Log(msg);
            image = SpriteFromTex2D(imageTexture2D);                     //TODO remove
            spriteRenderer.sprite = SpriteFromTex2D(imageTexture2D);

            // Clean up
            Resources.UnloadUnusedAssets();
        },
            error => AGUIMisc.ShowToast("Cancelled taking photo from camera: " + error), imageResultSize, shouldGenerateThumbnails);
    }
        public void OnPickContactFromAddressBook()
        {
            AGContacts.PickContact(
                pickedContact =>
            {
                var msg = string.Format("Picked contact: {0}, photo URI: {1}, emails: {2}, phones: {3}",
                                        pickedContact.DisplayName,
                                        pickedContact.PhotoUri,
                                        string.Join(",", pickedContact.Emails.ToArray()),
                                        string.Join(",", pickedContact.Phones.ToArray())
                                        );

                Debug.Log(msg);
                AGUIMisc.ShowToast(msg);

                if (!string.IsNullOrEmpty(pickedContact.PhotoUri))     // Not all contacts have image
                {
                    var contactPicture = AGFileUtils.ImageUriToTexture2D(pickedContact.PhotoUri);
                    image.sprite       = SpriteFromTex2D(contactPicture);
                }
            },
                failureReason =>
            {
                AGUIMisc.ShowToast("Picking contact failed: " + failureReason);
            });
        }
        public void OnPickGalleryImage()
        {
            // Whether to generate thumbnails
            var shouldGenerateThumbnails = true;

            // if image is larger it will be downscaled to the max size proportionally
            var imageResultSize = ImageResultSize.Max512;

            AGGallery.PickImageFromGallery(
                selectedImage =>
            {
                var imageTexture2D = selectedImage.LoadTexture2D();

                string msg = string.Format("{0} was loaded from gallery with size {1}x{2}",
                                           selectedImage.OriginalPath, imageTexture2D.width, imageTexture2D.height);
                AGUIMisc.ShowToast(msg);
                Debug.Log(msg);
                image.sprite = SpriteFromTex2D(imageTexture2D);

                // Clean up
                Resources.UnloadUnusedAssets();
            },
                errorMessage => AGUIMisc.ShowToast("Cancelled picking image from gallery: " + errorMessage),
                imageResultSize, shouldGenerateThumbnails);
        }
예제 #6
0
        public void OnSetTimer()
        {
            AGUIMisc.ShowToast("Timer running in background...");
            const bool skipUI = true; // skip the UI and start the timer immediately

            AGAlarmClock.SetTimer(5, "My awesome timer", skipUI);
        }
예제 #7
0
    public void Save()
    {
        // Initialise List of Dictionary
        List <Dictionary <string, object> > data = CSVReader.Read("data");

        counter++;

        Debug.Log("Step 0");

        // CANNOT DO THIS STEP TWICE SINCE DICTIONARY DOES NOT ALLOW DUPLICATE KEYS

        // Add values to Dictionary
        entry.Add("bssid", bssid.text);
        entry.Add("room", room.text);
        entry.Add("lat", lat.text);
        entry.Add("lon", lon.text);

        Debug.Log("Step 1");

        //Maybe add a blank data.Add("") to account for index mismatch

        // Add dictionary entry to csv
        data.Add(entry);

        Debug.Log("Step 2");

        // Output to log what we just saved
        var lines = data[data.Count - 1].Select(kvp => kvp.Key + ": " + kvp.Value.ToString());

        Debug.Log(string.Join(Environment.NewLine, lines));

        Debug.Log("Step 3");

        // Confirm
        AGUIMisc.ShowToast("Saved.");

        // Clear fields
        bssid.text = "";
        room.text  = "";
        lat.text   = "";
        lon.text   = "";

        //populate viewer with csv contents
        colBSSID.text += Convert.ToString(entry["bssid"]) + Environment.NewLine;
        colROOM.text  += Convert.ToString(entry["room"]) + Environment.NewLine;
        colLAT.text   += Convert.ToString(entry["lat"]) + Environment.NewLine;
        colLON.text   += Convert.ToString(entry["lon"]) + Environment.NewLine;

        // Build a string for sharing
        string str = string.Empty;

        for (int i = 0; i < data.Count; i++)
        {
            str += data[i]["bssid"] + ", " + data[i]["room"] + ", " + data[i]["lat"] + ", " + data[i]["lon"] + Environment.NewLine;
        }

        // Fill string with the updated values
        outputData = str;
    }
예제 #8
0
 public void OnShowDialogMultiChooseItem()
 {
     bool[] initiallyCheckedItems = { false, true, false }; // second item is selected when dialog is shown
     AGAlertDialog.ShowMultiItemChoiceDialog("Choose color", Colors,
                                             initiallyCheckedItems,
                                             (colorIndex, isChecked) => AGUIMisc.ShowToast(Colors[colorIndex] + " selected? " + isChecked), "OK",
                                             () => AGUIMisc.ShowToast("OK!"), AGDialogTheme.Light);
 }
예제 #9
0
 public static void ShowMessage(string message)
 {
     #if UNITY_EDITOR
     Debug.Log(message);
     #elif UNITY_ANDROID
     AGUIMisc.ShowToast(message);
     #endif
 }
예제 #10
0
        static void StartRecording()
        {
            var downloadsDir = Path.Combine(AGEnvironment.ExternalStorageDirectoryPath, AGEnvironment.DirectoryDownloads);
            var fullFilePath = Path.Combine(downloadsDir, "my_voice_recording.3gp");

            AGMediaRecorder.StartRecording(fullFilePath);
            AGUIMisc.ShowToast("Start recording to file: " + fullFilePath);
        }
예제 #11
0
    public void Screenshot()
    {
        var          imageTitle = "Screenshot-" + System.DateTime.Now.ToString("yy-MM-dd-hh-mm-ss");
        const string folderName = "com.javifont.camera";

        AGGallery.SaveImageToGallery(imageToGallery, imageTitle, folderName, ImageFormat.JPEG);
        AGUIMisc.ShowToast("Image saved in the gallery", AGUIMisc.ToastLength.Long);
    }
예제 #12
0
        public void OnShowDialogSingleChooseItem()
        {
            const int defaultSelectedItemIndex = 1;

            AGAlertDialog.ShowSingleItemChoiceDialog("Choose color", Colors, defaultSelectedItemIndex,
                                                     colorIndex => AGUIMisc.ShowToast(Colors[colorIndex] + " selected"),
                                                     "OK", () => AGUIMisc.ShowToast("OK!"), AGDialogTheme.Dark);
        }
예제 #13
0
 public void OnMessageThreeButtonDialog()
 {
     AGAlertDialog.ShowMessageDialog("Three Buttons",
                                     "This dialog has positive, negative and neutral buttons button",
                                     "Ok", () => AGUIMisc.ShowToast("Positive button Click"),
                                     "No!", () => AGUIMisc.ShowToast("Negative button Click"),
                                     "Maybe!", () => AGUIMisc.ShowToast("Neutral button Click"),
                                     () => AGUIMisc.ShowToast("Dismissed"), AGDialogTheme.Light);
 }
예제 #14
0
 public void OnPickAudioFile()
 {
     AGFilePicker.PickAudio(audioFile =>
     {
         var msg = "Audio file was picked: " + audioFile;
         Debug.Log(msg);
         AGUIMisc.ShowToast(msg);
     },
                            error => AGUIMisc.ShowToast("Cancelled picking audio file"));
 }
예제 #15
0
        public void OnPickPdfFile()
        {
            const string mimeType = "application/pdf";             // pick only pdfs

            AGFilePicker.PickFile(file =>
            {
                var msg = "Picked file: " + file;
                Debug.Log(msg);
                AGUIMisc.ShowToast(msg);
            }, error => AGUIMisc.ShowToast("Picking file: " + error), mimeType);
        }
예제 #16
0
 void RecordVideo()
 {
     AGCamera.RecordVideo(videoFile =>
     {
         var msg = "Video file was recorded: " + videoFile;
         Debug.Log(msg);
         AGUIMisc.ShowToast(msg);
         image.sprite = SpriteFromTex2D(videoFile.LoadPreviewImage());
     },
                          error => AGUIMisc.ShowToast("Cancelled recording video file: " + error), true);
 }
예제 #17
0
 public void OnTakeThumbnailPhoto()
 {
     AGCamera.TakeSmallPhoto(
         selectedImage =>
     {
         AGUIMisc.ShowToast(string.Format("Thumbnail photo was taken from camera with size {0}x{1}",
                                          selectedImage.Image.width, selectedImage.Image.height));
         image.sprite = SpriteFromTex2D(selectedImage.Image);
     },
         () => AGUIMisc.ShowToast("Cancelled taking photo from camera"));
 }
예제 #18
0
 public void OnTakePhoto()
 {
     AGCamera.TakePhoto(
         selectedImage =>
     {
         AGUIMisc.ShowToast(string.Format("{0} was taken from camera with size {1}x{2}",
                                          selectedImage.FileName, selectedImage.Image.width, selectedImage.Image.height));
         image.sprite = SpriteFromTex2D(selectedImage.Image);
     },
         () => AGUIMisc.ShowToast("Cancelled taking photo from camera"), ImageResultSize.Max256, "MyAwesomeAlbum");
 }
예제 #19
0
 public void OnPrintHtmlFromUrl()
 {
     if (AGPrintHelper.SystemSupportsPrint)
     {
         AGPrintHelper.PrintHtmlPageFromUrl("https://ninevastudios.com/", PrintJobName);
     }
     else
     {
         AGUIMisc.ShowToast("Printing is not supported");
     }
 }
예제 #20
0
 public void OnPickGalleryImage()
 {
     AGGallery.PickImageFromGallery(
         selectedImage =>
     {
         AGUIMisc.ShowToast(string.Format("{0} was loaded from gallery with size {1}x{2}",
                                          selectedImage.FileName, selectedImage.Image.width, selectedImage.Image.height));
         image.sprite = SpriteFromTex2D(selectedImage.Image);
     },
         () => AGUIMisc.ShowToast("Cancelled picking image from gallery"), ImageFormat.JPEG,
         ImageResultSize.Max1024);
 }
예제 #21
0
 public void OnPickAudioFile()
 {
     AGFilePicker.PickAudio(audioFile =>
     {
         StartCoroutine(LoadAudioFile(audioFile));
         _demoController.audioPanel.SetActive(true);
         var msg = "Audio file was picked: " + audioFile;
         Debug.Log(msg);
         AGUIMisc.ShowToast(msg);
     },
                            error => AGUIMisc.ShowToast("Cancelled picking audio file"));
 }
예제 #22
0
 public void OnPrintHtmlText()
 {
     if (AGPrintHelper.SystemSupportsPrint)
     {
         const string htmlDocument = "<html><body><h1>Test Content</h1><p>Testing, testing, testing...</p></body></html>";
         AGPrintHelper.PrintHtmlPage(htmlDocument, PrintJobName);
     }
     else
     {
         AGUIMisc.ShowToast("Printing is not supported");
     }
 }
예제 #23
0
 public void OnPrintImage()
 {
     if (AGPrintHelper.SystemSupportsPrint)
     {
         AGPrintHelper.PrintImage(image, PrintJobName, () => { AGUIMisc.ShowToast("Printing success"); },
                                  AGPrintHelper.ColorModes.Monochrome, AGPrintHelper.Orientations.Landscape, AGPrintHelper.ScaleModes.Fill);
     }
     else
     {
         AGUIMisc.ShowToast("Printing is not supported");
     }
 }
 void InitModifyScreenBrightness()
 {
     slider.onValueChanged.AddListener(newBrightness =>
     {
         if (!AGSettings.CanWriteSystemSettings())
         {
             AGUIMisc.ShowToast("Can't modify system settings because user did not allow it!");
             return;
         }
         AGSettings.SetSystemScreenBrightness(newBrightness);
     });
 }
예제 #25
0
        /// <summary>
        /// Example how to request for runtime permissions
        /// </summary>
        public void OnRequestPermissions()
        {
            // Don't forget to also add the permissions you need to manifest!
            var permissions = new[]
            {
                AGPermissions.WRITE_CONTACTS,
                AGPermissions.CALL_PHONE,
                AGPermissions.ACCESS_FINE_LOCATION,
                AGPermissions.READ_CALENDAR
            };

            // Filter permissions so we don't request already granted permissions,
            // otherwise if the user denies already granted permission the app will be killed
            var nonGrantedPermissions = permissions.ToList()
                                        .Where(x => !AGPermissions.IsPermissionGranted(x))
                                        .ToArray();

            if (nonGrantedPermissions.Length == 0)
            {
                var message = "User already granted all these permissions: " + string.Join(",", permissions);
                Debug.Log(message);
                AGUIMisc.ShowToast(message);
                return;
            }

            // Finally request permissions user has not granted yet and log the results
            AGPermissions.RequestPermissions(permissions, results =>
            {
                // Process results of requested permissions
                foreach (var result in results)
                {
                    string msg = string.Format("Permission [{0}] is [{1}], should show explanation?: {2}",
                                               result.Permission, result.Status, result.ShouldShowRequestPermissionRationale);
                    Debug.Log(msg);
                    AGUIMisc.ShowToast(msg);
                    if (result.Status == AGPermissions.PermissionStatus.Denied)
                    {
                        // User denied permission, now we need to find out if he clicked "Do not show again" checkbox
                        if (result.ShouldShowRequestPermissionRationale)
                        {
                            // User just denied permission, we can show explanation here and request permissions again
                            // or send user to settings to do so
                        }
                        else
                        {
                            // User checked "Do not show again" checkbox or permission can't be granted.
                            // We should continue with this permission denied
                        }
                    }
                }
            });
        }
예제 #26
0
        public void OnPickVideoFileDevice()
        {
            var generatePreviewImages = true;

            AGFilePicker.PickVideo(videoFile =>
            {
                var msg = "Video file was picked: " + videoFile;
                Debug.Log(msg);
                AGUIMisc.ShowToast(msg);
                image.sprite = SpriteFromTex2D(videoFile.LoadPreviewImage());
            },
                                   error => AGUIMisc.ShowToast("Cancelled picking video file: " + error), generatePreviewImages);
        }
예제 #27
0
        public void OnPickVideoFileCamera()
        {
            var generatePreviewImages = true;

            AGCamera.RecordVideo(videoFile =>
            {
                var msg = "Video file was recorded: " + videoFile;
                Debug.Log(msg);
                AGUIMisc.ShowToast(msg);
                image.sprite = SpriteFromTex2D(videoFile.LoadPreviewImage());
            },
                                 error => AGUIMisc.ShowToast("Cancelled recording video file: " + error), generatePreviewImages);
        }
        public void PickSoundForNotificationChannel()
        {
            if (NotificationChannelsApiCheck())
            {
                return;
            }

            AGFilePicker.PickAudio(audioFile =>
            {
                _soundFilePath = AndroidUri.FromFile(audioFile.OriginalPath).CallStr("getPath");
                Debug.Log(_soundFilePath);
                AGUIMisc.ShowToast(_soundFilePath);
            },
                                   error => AGUIMisc.ShowToast("Cancelled picking audio file"));
        }
예제 #29
0
        public IEnumerator TakeScreenshot(int width, int height)
        {
            yield return(new WaitForEndOfFrame());

            var texture = new Texture2D(width, height, TextureFormat.RGB24, true);

            texture.ReadPixels(new Rect(0, 0, width, height), 0, 0);
            texture.Apply();
            _lastTakenScreenshot = texture;
            var          imageTitle = "Screenshot-" + System.DateTime.Now.ToString("yy-MM-dd-hh-mm-ss");
            const string folderName = "Goodies";

            AGFileUtils.SaveImageToGallery(_lastTakenScreenshot, imageTitle, folderName, ImageFormat.JPEG);
            AGUIMisc.ShowToast(imageTitle + " saved to gallery");
        }
예제 #30
0
 public void OnGetImageExifTags()
 {
     if (_imageFilePath == null)
     {
         AGGallery.PickImageFromGallery(
             selectedImage =>
         {
             GetImageTags(selectedImage.OriginalPath);
             Resources.UnloadUnusedAssets();
         },
             errorMessage => AGUIMisc.ShowToast("Cancelled picking image from gallery: " + errorMessage));
     }
     else
     {
         GetImageTags(_imageFilePath);
     }
 }