/// <summary> /// Go through each of the Expansion APK files defined in the project /// and determine if the files are present and match the required size. /// </summary> /// <remarks> /// Free applications should definitely consider doing this, as this /// allows the application to be launched for the first time without /// having a network connection present. /// Paid applications that use LVL should probably do at least one LVL /// check that requires the network to be present, so this is not as /// necessary. /// </remarks> /// <returns> /// True if they are present, otherwise False; /// </returns> private bool AreExpansionFilesDelivered() { // flag to indicate if all downloads are complete var downloadComplete = true; // get a list of all the downloaded expansion files var downloads = DownloadsDB.GetDB().GetDownloads(); if (downloads == null || !downloads.Any()) { // start the download as nothing is here downloadComplete = false; } if (downloads != null) { foreach (var file in downloads) { if (!Helpers.DoesFileExist(this, file.FileName, file.TotalBytes, false)) { // start the download as this file is incomplete downloadComplete = false; break; } } } return(downloadComplete); }
/// <summary> /// The get expansion files. /// </summary> /// <returns> /// The get expansion files. /// </returns> private bool GetExpansionFiles() { bool result = false; try { // Build the intent that launches this activity. Intent launchIntent = Intent; var intent = new Intent(this, typeof(ExpansionDownloaderActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); intent.SetAction(launchIntent.Action); if (launchIntent.Categories != null) { foreach (string category in launchIntent.Categories) { intent.AddCategory(category); } } // Build PendingIntent used to open this activity when user // taps the notification. Android.App.PendingIntent pendingIntent = Android.App.PendingIntent.GetActivity( this, 0, intent, Android.App.PendingIntentFlags.UpdateCurrent); // Always force download of LVL DownloadsDB.GetDB(this).UpdateMetadata(0, 0); // Request to start the download DownloaderServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired( this, pendingIntent, typeof(ExpansionDownloaderService)); // The DownloaderService has started downloading the files, // show progress otherwise, the download is not needed so we // fall through to starting the actual app. if (startResult != DownloaderServiceRequirement.NoDownloadRequired) { InitializeDownloadUi(); result = true; } } catch (PackageManager.NameNotFoundException e) { #if DEBUG Android.Util.Log.Debug(Tag, "Cannot find own package!"); #endif e.PrintStackTrace(); } #pragma warning disable 168 catch (Exception ex) #pragma warning restore 168 { // ignored #if DEBUG Android.Util.Log.Debug(Tag, "Exception: ", EdiabasLib.EdiabasNet.GetExceptionText(ex)); #endif } return(result); }
/// <summary> /// The do validate zip files. /// </summary> /// <param name="state"> /// The state. /// </param> private void DoValidateZipFiles(object state) { var downloadInfos = DownloadsDB.GetDB().GetDownloads() ?? new DownloadInfo[0]; var downloads = downloadInfos.Select(x => Helpers.GenerateSaveFileName(this, x.FileName)).ToArray(); var result = downloads.Any(); var progress = downloads.Length; foreach (var file in downloads) { progress--; result = result && IsValidZipFile(file); RunOnUiThread( delegate { OnDownloadProgress(new DownloadProgressInfo(downloads.Length, downloads.Length - progress, 0, 0)); }); } RunOnUiThread( delegate { pauseButton.Click += delegate { Finish(); StartActivity(typeof(ZipTestActivity)); }; dashboardView.Visibility = ViewStates.Visible; useCellDataView.Visibility = ViewStates.Gone; if (result) { statusTextView.SetText(Resource.String.text_validation_complete); pauseButton.SetText(Android.Resource.String.Ok); } else { statusTextView.SetText(Resource.String.text_validation_failed); pauseButton.SetText(Android.Resource.String.Cancel); } }); }
private bool ExpansionAlreadyDownloaded() { DownloadInfo[] downloads = DownloadsDB.GetDB().GetDownloads(); if (downloads == null || !downloads.Any()) { return(false); } if (downloads != null) { DownloadInfo[] array = downloads; foreach (DownloadInfo downloadInfo in array) { if (!Helpers.DoesFileExist(this, downloadInfo.FileName, downloadInfo.TotalBytes, deleteFileOnMismatch: false)) { return(false); } } } return(true); }
/// <summary> /// Go through each of the Expansion APK files defined in the project /// and determine if the files are present and match the required size. /// </summary> /// <remarks> /// Free applications should definitely consider doing this, as this /// allows the application to be launched for the first time without /// having a network connection present. /// Paid applications that use LVL should probably do at least one LVL /// check that requires the network to be present, so this is not as /// necessary. /// </remarks> /// <returns> /// True if they are present, otherwise False; /// </returns> private bool AreExpansionFilesDelivered() { var downloads = DownloadsDB.GetDB().GetDownloads() ?? new DownloadInfo[0]; return(downloads.Any() && downloads.All(x => Helpers.DoesFileExist(this, x.FileName, x.TotalBytes, false))); }