Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
        // 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());
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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}");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
        public static void RefreshFile([NotNull] string filePath)
        {
            Check.Argument.IsStrNotNullOrEmpty(filePath, "path");

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

            AndroidPersistanceUtilsInternal.RefreshGallery(filePath);
        }
Ejemplo n.º 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}");
        }
Ejemplo n.º 12
0
        public static Texture2D ImageUriToTexture2D(string imageUri)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return(null);
            }

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

            return(AGUtils.TextureFromUriInternal(imageUri));
        }
Ejemplo n.º 13
0
        public static void ShowAllAlarms()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

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

            using (var intent = new AndroidIntent(ACTION_SHOW_ALARMS))
            {
                return(intent.ResolveActivity());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 16
0
        public static void CancelNotification(int notificationId)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

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

            using (var intent = new AndroidIntent(ACTION_SET_TIMER))
            {
                return(intent.ResolveActivity());
            }
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Dismisses the dialog.
        /// </summary>
        public void Dismiss()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            AGUtils.RunOnUiThread(() =>
            {
                _dialog.Call("dismiss");
                _dialog.Dispose();
            });
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 23
0
        public static void RemoveUpdates()
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (_currentListener == null)
            {
                return;
            }

            AGUtils.RunOnUiThread(() => { AGSystemService.LocationService.Call("removeUpdates", _currentListener); });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 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);
            }
        }