Exemple #1
0
        /// <summary>
        /// Creates the horizontal loading dialog
        /// </summary>
        /// <param name="title">Dialog title</param>
        /// <param name="message">Dialog message</param>
        /// <param name="maxValue">Maximum value of the progress bar</param>
        /// <param name="theme">Theme of the dialog.</param>
        /// <returns></returns>
        public static AGProgressDialog CreateHorizontalDialog(string title, string message, int maxValue,
                                                              AGDialogTheme theme = AGDialogTheme.Default)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(null);
            }

            return(new AGProgressDialog(Style.Horizontal, title, message, theme, maxValue));
        }
Exemple #2
0
        /// <summary>
        /// Saves the image to android gallery.
        /// </summary>
        /// <returns>The image to save to the gallery.</returns>
        /// <param name="texture2D">Texture2D to save.</param>
        /// <param name="title">Title.</param>
        /// <param name="folder">Inner folder in Pictures directory. Must be a valid folder name</param>
        /// <param name="imageFormat">Image format.</param>
        public static void SaveImageToGallery(Texture2D texture2D, string title, string folder = null,
                                              ImageFormat imageFormat = ImageFormat.PNG)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            AGFileUtils.SaveImageToGallery(texture2D, title, folder, imageFormat);
        }
Exemple #3
0
        /// <summary>
        /// Creates the spinner dialog.
        /// Call <see cref="Show"/> to show the spinner dialog.
        /// Call <see cref="Dismiss"/> to hide the spinner dialog.
        /// </summary>
        /// <returns>The spinner dialog.</returns>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="theme">Theme of the dialog.</param>
        public static AGProgressDialog CreateSpinnerDialog(string title, string message,
                                                           AGDialogTheme theme = AGDialogTheme.Default)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(null);
            }

            return(new AGProgressDialog(Style.Spinner, title, message, theme));
        }
        // API 1

        /// <summary>
        /// Check if the current device can open the specified settings screen.
        /// </summary>
        /// <returns><c>true</c> if the current device can open the specified settings screen; otherwise, <c>false</c>.</returns>
        /// <param name="action">Action.</param>
        public static bool CanOpenSettingsScreen(string action)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }

            var intent = new AndroidIntent(action);

            return(intent.ResolveActivity());
        }
        /// <summary>
        /// Opens the activity to modify system settings activity.
        /// </summary>
        /// <param name="onFailure">Invoked if activity could not be started.</param>
        public static void OpenModifySystemSettingsActivity(Action onFailure)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = new AndroidIntent(AndroidSettings.ACTION_MANAGE_WRITE_SETTINGS).AJO;

            AGUtils.StartActivity(intent, onFailure);
        }
        /// <summary>
        /// Gets the system screen brightness. The value is between 0 and 1
        /// </summary>
        /// <returns>The system screen brightness.</returns>
        public static float GetSystemScreenBrightness()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(0);
            }

            var brightnessInt = AndroidSettings.System.GetInt(AndroidSettings.System.SCREEN_BRIGHTNESS, 1);

            return(brightnessInt / 255f);
        }
Exemple #7
0
        /// <summary>
        /// Gets the wifi signal level out of 100.
        /// </summary>
        /// <returns>The wifi signal level out of 100.</returns>
        public static int GetWifiSignalLevel()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(0);
            }

            var wifiInfo = GetWifiConnectionInfo();

            return(wifiInfo == null ? 0 : AGSystemService.WifiService.CallStatic <int>("calculateSignalLevel", wifiInfo.Rssi, 100));
        }
Exemple #8
0
        /// <summary>
        /// Opens the facebook profile in the app. Falls back to browser if facebook app is not installed.
        /// </summary>
        /// <param name="profileId">Profile id.</param>
        public static void OpenFacebookProfile(string profileId)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsStrNotNullOrEmpty(profileId, "profileId");

            OpenProfileInternal(null, "fb://profile/{0}", profileId, "https://www.facebook.com/{0}");
        }
Exemple #9
0
        /// <summary>
        /// Launch an activity for the user to pick the current global live wallpaper.
        /// </summary>
        public static void ShowLiveWallpaperChooser()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = new AndroidIntent(ACTION_LIVE_WALLPAPER_CHOOSER);

            AGUtils.StartActivity(intent.AJO);
        }
Exemple #10
0
        public static void RefreshFile([NotNull] string filePath)
        {
            Check.Argument.IsStrNotNullOrEmpty(filePath, "path");

            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            AndroidPersistanceUtilsInternal.RefreshGallery(filePath);
        }
Exemple #11
0
        /// <summary>
        /// Opens the twitter profile in the app. Falls back to browser if twitter app is not installed.
        /// </summary>
        /// <param name="profileId">Profile id.</param>
        public static void OpenTwitterProfile(string profileId)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsStrNotNullOrEmpty(profileId, "profileId");

            OpenProfileInternal(null, "twitter://user?screen_name={0}", profileId, "https://twitter.com/{0}");
        }
Exemple #12
0
        public static Texture2D ImageUriToTexture2D(string imageUri)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(null);
            }

            Check.Argument.IsStrNotNullOrEmpty(imageUri, "imageUri");

            return(AGUtils.TextureFromUriInternal(imageUri));
        }
Exemple #13
0
        public static void ShowAllAlarms()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            using (var intent = new AndroidIntent(ACTION_SHOW_ALARMS))
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #14
0
        public static bool CanShowListOfAlarms()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }

            using (var intent = new AndroidIntent(ACTION_SHOW_ALARMS))
            {
                return(intent.ResolveActivity());
            }
        }
Exemple #15
0
        /// <summary>
        /// Indicates whether the device has the app installed which can place phone calls
        /// </summary>
        /// <returns><c>true</c>, if user has any phone app installed, <c>false</c> otherwise.</returns>
        public static bool UserHasPhoneApp()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }

            using (var i = new AndroidIntent(AndroidIntent.ACTION_DIAL))
            {
                return(i.ResolveActivity());
            }
        }
Exemple #16
0
        public static void CancelNotification(int notificationId)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            using (var c = new AndroidJavaClass(GoodiesNotificationManagerClass))
            {
                c.CallStatic("cancelNotification", AGUtils.Activity, notificationId);
            }
        }
Exemple #17
0
        public static bool CanSetTimer()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }

            using (var intent = new AndroidIntent(ACTION_SET_TIMER))
            {
                return(intent.ResolveActivity());
            }
        }
Exemple #18
0
        /// <summary>
        /// Checks if user has any maps apps installed.
        /// </summary>
        /// <returns><c>true</c>, if user has any maps apps installed., <c>false</c> otherwise.</returns>
        public static bool UserHasMapsApp()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }
            // Dummy intent just to check if any apps can handle the intent
            var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW);
            var uri    = AndroidUri.Parse(string.Format(MapUriFormat, 0, 0, DefaultMapZoomLevel));

            return(intent.SetData(uri).ResolveActivity());
        }
Exemple #19
0
        /// <summary>
        /// Opens the instagram profile in the app. Falls back to browser if instagram app is not installed.
        /// </summary>
        /// <param name="profileId">Profile id.</param>
        public static void OpenInstagramProfile(string profileId)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsStrNotNullOrEmpty(profileId, "profileId");

            var formatUri = "http://instagram.com/_u/{0}";

            OpenProfileInternal("com.instagram.android", formatUri, profileId, formatUri);
        }
Exemple #20
0
        /// <summary>
        /// Dismisses the dialog.
        /// </summary>
        public void Dismiss()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            AGUtils.RunOnUiThread(() =>
            {
                _dialog.Call("dismiss");
                _dialog.Dispose();
            });
        }
Exemple #21
0
        /// <summary>
        /// Places the phone call immediately.
        ///
        /// You need <uses-permission android:name="android.permission.CALL_PHONE" /> to use this method!
        /// </summary>
        /// <param name="phoneNumber">Phone number.</param>
        public static void PlacePhoneCall(string phoneNumber)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            using (var i = new AndroidIntent(AndroidIntent.ACTION_CALL))
            {
                i.SetData(ParsePhoneNumber(phoneNumber));
                AGUtils.StartActivity(i.AJO);
            }
        }
Exemple #22
0
        /// <summary>
        /// Returns whether the calling package is allowed to set the wallpaper for the calling user.
        /// If this function returns <code>false</code>, any attempts to change the wallpaper will have no effect.
        /// Always returns true for device owner and profile owner.
        /// </summary>
        /// <returns>Whether the calling package is allowed to set the wallpaper.</returns>
        public static bool IsSetWallpaperAllowed()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(false);
            }

            if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.N)
            {
                return(WallpaperManager.CallBool("isSetWallpaperAllowed"));
            }

            return(true);
        }
Exemple #23
0
        public static void RemoveUpdates()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (_currentListener == null)
            {
                return;
            }

            AGUtils.RunOnUiThread(() => { AGSystemService.LocationService.Call("removeUpdates", _currentListener); });
        }
Exemple #24
0
        /// <summary>
        /// Take the video file using the device camera
        /// </summary>
        /// <param name="onSuccess">Video file was successfully picked by the user. Result is received in a callback.</param>
        /// <param name="onError">Picking video file failed.</param>
        public static void RecordVideo(Action <VideoPickResult> onSuccess, Action <string> onError, bool generatePreviewImages = true)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsNotNull(onSuccess, "onSuccess");
            Check.Argument.IsNotNull(onError, "onError");
            _onVideoSuccessAction = onSuccess;
            _onVideoCancelAction  = onError;

            AGActivityUtils.PickVideoCamera(generatePreviewImages);
        }
Exemple #25
0
        /// <summary>
        /// Picks the contact from the phone contacts book.
        /// </summary>
        /// <param name="onSuccess">On success callback. Picked contact is passed as parameter</param>
        /// <param name="onError">On failure callback. Failure reason is passed as parameter</param>
        public static void PickContact(Action <ContactPickResult> onSuccess, Action <string> onError)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsNotNull(onSuccess, "onSuccess");
            Check.Argument.IsNotNull(onError, "onError");
            _onSuccessAction = onSuccess;
            _onCancelAction  = onError;

            AGActivityUtils.PickContact();
        }
Exemple #26
0
        public static void SendFacebookMessageImage(Texture2D image)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (image == null)
            {
                throw new ArgumentNullException("image", "Image must not be null");
            }

            SendImageGeneric(image, IsFacebookMessengerInstalled, FbMessengerPackage);
        }
Exemple #27
0
        public static void ShareInstagramPhoto(Texture2D image)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (image == null)
            {
                throw new ArgumentNullException("image", "Image must not be null");
            }

            SendImageGeneric(image, IsInstagramInstalled, InstagramPackage);
        }
Exemple #28
0
        public static void SendSnapChatImageMessage(Texture2D image)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (image == null)
            {
                throw new ArgumentNullException("image", "Image must not be null");
            }

            SendImageGeneric(image, IsSnapChatInstalled, SnapChatPackage);
        }
        public static void PickFile(Action <FilePickerResult> onSuccess, Action <string> onError, string mimeType)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            Check.Argument.IsNotNull(onSuccess, "onSuccess");
            Check.Argument.IsNotNull(onError, "onError");
            _onFileSuccessAction = onSuccess;
            _onFileCancelAction  = onError;

            AGActivityUtils.PickFile(mimeType);
        }
Exemple #30
0
        public static void SetTimer(int lengthInSeconds, string message, bool skipUi = false)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            using (var intent = new AndroidIntent(ACTION_SET_TIMER))
            {
                intent.PutExtra(EXTRA_LENGTH, lengthInSeconds);
                intent.PutExtra(EXTRA_MESSAGE, message);
                intent.PutExtra(EXTRA_SKIP_UI, skipUi);
                AGUtils.StartActivity(intent.AJO);
            }
        }