Example #1
0
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            //Lets check for permission.
            if (CheckSelfPermission(PermissionsNeeded.First()) != Permission.Granted)
            {
                _timer.Stop();

                RunOnUiThread(() =>
                {
                    AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this);
                    builder.SetTitle(Resource.String.dialog_title)
                    .SetIcon(GetDrawable(Resource.Drawable.ic_home_black_24dp))
                    .SetMessage(Resource.String.dialog_message)
                    .SetPositiveButton(Resource.String.dialog_postive, PositiveButtonSelected)
                    .SetNegativeButton(Resource.String.dialog_negative, NegativeButtonSelected)
                    .Show();
                });
            }
            else
            {
                GetOnToMainActivity();
            }
            //Whatever happens.... dispose the timer.

            _timer.Dispose();
        }
        private void InitFilterBox()
        {
            var inflater = LayoutInflater;

            try
            {
                View v = inflater.Inflate(Resource.Layout.FSTFilterLayout, null);

                for (int i = 0; i < typeFilters.Length; ++i)
                {
                    v.FindViewById <CheckBox>(typeFilters[i]).Checked = filterType[i];
                }

                var filterBox = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGVertical);
                filterBox.SetTitle(Resource.String.DBList_FilterBoxTitle);
                filterBox.SetView(v);
                filterBox.SetPositiveButton(Resource.String.AlertDialog_Set, delegate { ApplyFilter(v); });
                filterBox.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
                filterBox.SetNeutralButton(Resource.String.AlertDialog_Reset, delegate { ResetFilter(); });

                filterBox.Show();
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                ETC.ShowSnackbar(snackbarLayout, Resource.String.FilterBox_InitError, Snackbar.LengthLong);
            }
        }
Example #3
0
        private async void Adapter_ItemClick(object sender, int e)
        {
            string pvFileName = pvList[e];

            try
            {
                if (!File.Exists(Path.Combine(pvPath, $"{pvFileName}.mp4")))
                {
                    var builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBG);
                    builder.SetTitle(Resource.String.GFPVActivity_DownloadRequireDialog_Title);
                    builder.SetMessage(Resource.String.GFPVActivity_DownloadRequireDialog_Message);
                    builder.SetCancelable(true);
                    builder.SetPositiveButton(Resource.String.AlertDialog_Download, async delegate { await PVDownload(pvFileName, e); });
                    builder.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });

                    builder.Show();
                }
                else
                {
                    await RunPV(Path.Combine(pvPath, $"{pvFileName}.mp4"));
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
            }
        }
Example #4
0
        public override void OnBackPressed()
        {
            if (IsBooting == true)
            {
                return;
            }

            var ad = new AndroidX.AppCompat.App.AlertDialog.Builder(this, Resource.Style.GFD_Dialog);

            ad.SetTitle("ShutDown Zina OS");
            ad.SetMessage("Do you want to shutdown Zina OS?");
            ad.SetPositiveButton("Shutdown", delegate
            {
                IsBooting = true;
                _         = ShutdownZinaOS();
            });
            ad.SetNegativeButton("Cancel", delegate { });
            ad.SetCancelable(true);

            try
            {
                ad.Show();
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
            }
        }
Example #5
0
        private void ShowDialog(string title, string message)
        {
            var alert = new AndroidX.AppCompat.App.AlertDialog.Builder(this);

            alert.SetTitle(title);
            alert.SetMessage(message);
            alert.SetPositiveButton("OK", (s, e) => { });
            alert.Create().Show();
        }
Example #6
0
        private void ShowFailureToSave()
        {
            AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this.Context);

            builder.SetTitle("Export Failed")
            .SetMessage("ExtractR is sadly unable to save your file right now. Please try again.")
            .SetIcon(Context.GetDrawable(Resource.Drawable.abc_ab_share_pack_mtrl_alpha))
            .SetCancelable(false)
            .SetNeutralButton("Let me try again", (s, e) => { return; })
            .Show();
        }
Example #7
0
        private async Task CheckUpdate()
        {
            await Task.Delay(100);

            bool isMissing = false;

            try
            {
                isMissing = CheckImage();

                if (!isMissing)
                {
                    using (WebClient wc = new WebClient())
                    {
                        string LocalVerPath = Path.Combine(ETC.systemPath, "ShortGuideVer.txt");

                        if (!File.Exists(LocalVerPath))
                        {
                            hasUpdate = true;
                        }
                        else
                        {
                            int serverVer = int.Parse(await wc.DownloadStringTaskAsync(Path.Combine(ETC.server, "ShortGuideVer.txt")));
                            int localVer  = 0;

                            using (StreamReader sr = new StreamReader(new FileStream(LocalVerPath, FileMode.Open, FileAccess.Read)))
                            {
                                localVer = int.Parse(sr.ReadToEnd());
                            }

                            hasUpdate = localVer < serverVer;
                        }
                    }
                }

                if (hasUpdate || isMissing)
                {
                    var builder = new AndroidX.AppCompat.App.AlertDialog.Builder(Activity);
                    builder.SetTitle(Resource.String.UpdateDialog_Title);
                    builder.SetMessage(Resource.String.UpdateDialog_Message);
                    builder.SetCancelable(true);
                    builder.SetPositiveButton(Resource.String.AlertDialog_Confirm, async delegate { await DownloadShortGuideImage(); });
                    builder.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });

                    var dialog = builder.Create();
                    dialog.Show();
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, Activity);
                ETC.ShowSnackbar(snackbarLayoutF, Resource.String.UpdateCheck_Fail, Snackbar.LengthLong, Android.Graphics.Color.DarkRed);
            }
        }
Example #8
0
        public void ShowSuccess(string message = null)
        {
            AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this.Context);

            builder.SetTitle("Success")
            .SetMessage(message ?? "We exported your file successfully. Please go to the history tab to have a look.")
            .SetIcon(Context.GetDrawable(Resource.Drawable.abc_ab_share_pack_mtrl_alpha))
            .SetCancelable(false)
            .SetNeutralButton("Okay", (s, e) => { return; })
            .Show();
        }
        private void InitSortBox()
        {
            string[] sortTypeList =
            {
                Resources.GetString(Resource.String.Sort_SortMethod_Name),
                Resources.GetString(Resource.String.Sort_SortMethod_Number),
                Resources.GetString(Resource.String.Sort_SortMethod_ProductTime),
                Resources.GetString(Resource.String.Sort_SortMethod_HP),
                Resources.GetString(Resource.String.Sort_SortMethod_FR),
                Resources.GetString(Resource.String.Sort_SortMethod_EV),
                Resources.GetString(Resource.String.Sort_SortMethod_AC),
                Resources.GetString(Resource.String.Sort_SortMethod_AS),
            };

            try
            {
                View v = LayoutInflater.Inflate(Resource.Layout.CommonSorterLayout, null);

                var adapter = new ArrayAdapter(this, Resource.Layout.SpinnerListLayout, sortTypeList);
                adapter.SetDropDownViewResource(Resource.Layout.SpinnerListLayout);

                var sortSpinner = v.FindViewById <Spinner>(Resource.Id.CommonSortSpinner);

                sortSpinner.Adapter = adapter;
                sortSpinner.SetSelection((int)sortType);

                switch (sortOrder)
                {
                default:
                case SortOrder.Ascending:
                    v.FindViewById <RadioButton>(Resource.Id.CommonSortOrderAscending).Checked = true;
                    break;

                case SortOrder.Descending:
                    v.FindViewById <RadioButton>(Resource.Id.CommonSortOrderDescending).Checked = true;
                    break;
                }

                var filterBox = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGVertical);
                filterBox.SetTitle(Resource.String.DBList_SortBoxTitle);
                filterBox.SetView(v);
                filterBox.SetPositiveButton(Resource.String.AlertDialog_Set, delegate { ApplySort(v); });
                filterBox.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
                filterBox.SetNeutralButton(Resource.String.AlertDialog_Reset, delegate { ResetSort(); });

                filterBox.Show();
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                ETC.ShowSnackbar(snackbarLayout, Resource.String.SortBox_InitError, Snackbar.LengthLong);
            }
        }
Example #10
0
        internal void ShowDownloadCheckMessage <T>(List <T> downloadList, string serverPath, string targetPath)
        {
            var ad = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBG);

            ad.SetTitle(Resource.String.DBList_DownloadCropImageCheckTitle);
            ad.SetMessage(Resource.String.DBList_DownloadCropImageCheckMessage);
            ad.SetCancelable(true);
            ad.SetPositiveButton(Resource.String.AlertDialog_Download, delegate { _ = CropImageDownloadProcess(downloadList, serverPath, targetPath); });
            ad.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });

            ad.Show();
        }
Example #11
0
 public void RefreshTaskFragment(NewTaskFragment fragment)
 {
     AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this);
     builder.SetTitle("Reset Work Space")
     .SetMessage("Would you like to start all over again?")
     .SetPositiveButton("Yes",
                        (s, e) =>
     {
         ResetView(fragment);
     })
     .SetNegativeButton("Quit", (s, e) => { ResetView(fragment); QuitApplication(); })
     .Show();
 }
Example #12
0
        private void Pickwallpaper_Click(object sender, EventArgs e)
        {
            var button = sender as Button;

            using (AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(button.Context))
            {
                int currentwallpapersetted = int.Parse(configurationManager.RetrieveAValue(ConfigurationParameters.ChangeWallpaper, "0"));
                builder.SetTitle(Resources.GetString(Resource.String.changewallpaper));
                builder.SetSingleChoiceItems(new string[] { button.Context.GetString(Resource.String.blackwallpaper), button.Context.GetString(Resource.String.defaultwallpaper), button.Context.GetString(Resource.String.pickwallpaper) }, currentwallpapersetted, OnDialogClickEventArgs);
                builder.Create();
                builder.Show();
            }
        }
Example #13
0
        private void PromptForPermission()
        {
            AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this);

            builder.SetTitle(Resource.String.dialog_quit_title)
            .SetIcon(GetDrawable(Resource.Drawable.ic_home_black_24dp))
            .SetPositiveButton(Resource.String.dialog_quit_positive, PositiveButtonSelected)
            .SetNegativeButton(Resource.String.dialog_quit, (s, e) =>
            {
                MoveTaskToBack(true);
                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                Java.Lang.JavaSystem.Exit(1);
            }).Show();
        }
Example #14
0
        public override void OnBackPressed()
        {
            var exitDialog = new AndroidX.AppCompat.App.AlertDialog.Builder(this, Resource.Style.GFD_Dialog);

            exitDialog.SetTitle(Resource.String.Main_CheckExitTitle);
            exitDialog.SetMessage(Resource.String.Main_CheckExit);
            exitDialog.SetCancelable(true);
            exitDialog.SetPositiveButton(Resource.String.AlertDialog_Exit, delegate
            {
                FinishAffinity();
                Process.KillProcess(Process.MyPid());
            });
            exitDialog.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
            exitDialog.Show();
        }
Example #15
0
        private void ReportNothingFound()
        {
            AndroidX.AppCompat.App.AlertDialog.Builder builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this.Context);
            builder.SetTitle("No image found")
            .SetMessage("Unfortunately, EtxractR couldn't find any image to process. Try again with another file, perhaps?")
            .SetIcon(this.Context.GetDrawable(Resource.Drawable.notification_template_icon_bg))
            .SetNeutralButton("Understood", (s, e) =>
            {
                //Call refresh
                mainActivity.RefreshTaskFragment(this);
            })
            .SetCancelable(false)
            .Show();

            CouldBeRefreshed = true;
        }
        private void SelectCache()
        {
            string freeText    = Resources.GetString(Resource.String.SelectCache_FreeSpace);
            string requireText = Resources.GetString(Resource.String.SelectCache_RequireSpace);

            if (categoryCheck == null)
            {
                categoryCheck = new Dictionary <CacheCategory, bool>();
            }

            categoryCheck.Clear();

            cacheSelectView = LayoutInflater.Inflate(Resource.Layout.CacheSelectLayout, null);

            cacheSelectView.FindViewById <XTextView>(Resource.Id.CacheSelectNowFreeSpace).Text                = $"{freeText} : {freeSize}MB";
            cacheSelectView.FindViewById <XTextView>(Resource.Id.CacheSelectRequireSpace).Text                = $"{requireText} : {expectSize}MB";
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryDic).CheckedChange       += CacheSelectCategory_CheckedChange;
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryOldGFD).CheckedChange    += CacheSelectCategory_CheckedChange;
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryGuideBook).CheckedChange += CacheSelectCategory_CheckedChange;
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryStory).CheckedChange     += CacheSelectCategory_CheckedChange;
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryPV).CheckedChange        += CacheSelectCategory_CheckedChange;
            cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryOST).CheckedChange       += CacheSelectCategory_CheckedChange;
            //cacheSelectView.FindViewById<XCheckBox>(Resource.Id.CacheSelectCategoryCartoon).CheckedChange += CacheSelectCategory_CheckedChange;

            var ad = new AndroidX.AppCompat.App.AlertDialog.Builder(Activity, ETC.dialogBG);

            ad.SetTitle(Resource.String.SelectCache_Dialog_Title);
            ad.SetCancelable(true);
            ad.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
            ad.SetPositiveButton(Resource.String.AlertDialog_Confirm, async delegate
            {
                categoryCheck.Add(CacheCategory.Dic, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryDic).Checked);
                categoryCheck.Add(CacheCategory.OldGFD, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryOldGFD).Checked);
                categoryCheck.Add(CacheCategory.GuideBook, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryGuideBook).Checked);
                categoryCheck.Add(CacheCategory.Story, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryStory).Checked);
                categoryCheck.Add(CacheCategory.PV, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryPV).Checked);
                categoryCheck.Add(CacheCategory.OST, cacheSelectView.FindViewById <XCheckBox>(Resource.Id.CacheSelectCategoryOST).Checked);
                //categoryCheck.Add(CacheCategory.Cartoon, cacheSelectView.FindViewById<XCheckBox>(Resource.Id.CacheSelectCategoryCartoon).Checked);

                await DownloadAllCache();
            });
            ad.SetView(cacheSelectView);

            var dialog = ad.Show();
        }
        private void InitFilterBox()
        {
            try
            {
                View v = LayoutInflater.Inflate(Resource.Layout.DollFilterLayout, null);

                v.FindViewById <NumberPicker>(Resource.Id.DollFilterProductHour).MaxValue      = 12;
                v.FindViewById <NumberPicker>(Resource.Id.DollFilterProductMinute).MaxValue    = 59;
                v.FindViewById <NumberPicker>(Resource.Id.DollFilterProductNearRange).MaxValue = 20;

                for (int i = 0; i < gradeFilters.Length; ++i)
                {
                    v.FindViewById <CheckBox>(gradeFilters[i]).Checked = filterGrade[i];
                }
                for (int i = 0; i < typeFilters.Length; ++i)
                {
                    v.FindViewById <CheckBox>(typeFilters[i]).Checked = filterType[i];
                }
                for (int i = 0; i < productTimeFilters.Length; ++i)
                {
                    v.FindViewById <NumberPicker>(productTimeFilters[i]).Value = filterProductTime[i];
                }
                v.FindViewById <CheckBox>(modFilter).Checked = filterMod;

                var FilterBox = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGVertical);
                FilterBox.SetTitle(Resource.String.DBList_FilterBoxTitle);
                FilterBox.SetView(v);
                FilterBox.SetPositiveButton(Resource.String.AlertDialog_Set, delegate { ApplyFilter(v); });
                FilterBox.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
                FilterBox.SetNeutralButton(Resource.String.AlertDialog_Reset, delegate { ResetFilter(); });

                FilterBox.Show();
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                ETC.ShowSnackbar(snackbarLayout, Resource.String.FilterBox_InitError, Snackbar.LengthLong);
            }
        }
Example #18
0
        private async Task PVDownload(string pvName, int position)
        {
            Dialog dialog = null;

            try
            {
                ProgressBar nowProgressBar;
                TextView    nowProgress;

                View v = LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null);

                v.FindViewById <TextView>(Resource.Id.ProgressStatusMessage).SetText(Resource.String.GFPVActivity_DownloadDialog_Message);
                v.FindViewById <TextView>(Resource.Id.ProgressNowFile).Text = pvName;
                v.FindViewById <LinearLayout>(Resource.Id.TotalProgressLayout).Visibility = ViewStates.Gone;

                nowProgressBar = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar);
                nowProgress    = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage);

                var pd = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGDownload);
                pd.SetTitle(Resource.String.GFPVActivity_DownloadDialog_Title);
                pd.SetCancelable(false);
                pd.SetView(v);

                dialog = pd.Create();
                dialog.Show();

                string localPath  = Path.Combine(pvPath, $"{pvName}.mp4");
                string serverPath = Path.Combine(ETC.server, "Data", "Video", "PV", $"{pvName}.mp4");

                using (var wc = new WebClient())
                {
                    wc.DownloadProgressChanged += (sender, e) =>
                    {
                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            nowProgressBar.Progress = e.ProgressPercentage;
                            nowProgress.Text        = $"{e.ProgressPercentage}%";
                        });
                    };
                    wc.DownloadFileCompleted += (sender, e) =>
                    {
                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            nowProgressBar.Progress = 100;
                            nowProgress.Text        = "100%";
                        });
                    };

                    await wc.DownloadFileTaskAsync(serverPath, localPath);
                }

                await Task.Delay(500);

                recyclerView.GetAdapter().NotifyItemChanged(position);
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
            }
            finally
            {
                dialog?.Dismiss();
            }
        }
Example #19
0
        internal async Task DownloadGFDImage()
        {
            View v = LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null);

            ProgressBar totalProgressBar = v.FindViewById <ProgressBar>(Resource.Id.TotalProgressBar);
            TextView    totalProgress    = v.FindViewById <TextView>(Resource.Id.TotalProgressPercentage);
            ProgressBar nowProgressBar   = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar);
            TextView    nowProgress      = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage);

            var builder = new AndroidX.AppCompat.App.AlertDialog.Builder(Activity, ETC.dialogBGDownload);

            builder.SetTitle(Resource.String.UpdateDownloadDialog_Title);
            builder.SetView(v);
            builder.SetCancelable(false);

            Dialog dialog = builder.Create();

            dialog.Show();

            await Task.Delay(100);

            try
            {
                totalProgressBar.Max      = imageName.Length;
                totalProgressBar.Progress = 0;

                using (WebClient wc = new WebClient())
                {
                    wc.DownloadFileCompleted += (object sender, System.ComponentModel.AsyncCompletedEventArgs e) =>
                    {
                        totalProgressBar.Progress += 1;
                        totalProgress.Text         = $"{totalProgressBar.Progress} / {totalProgressBar.Max}";
                    };
                    wc.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
                    {
                        nowProgressBar.Progress = e.ProgressPercentage;
                        nowProgress.Text        = $"{e.BytesReceived / 1024}KB";
                    };

                    foreach (string s in imageName)
                    {
                        string url    = Path.Combine(ETC.server, "Data", "Images", "OldGFD", "Images", lang, $"{s}.png");
                        string target = Path.Combine(ETC.cachePath, "OldGFD", "Images", $"{lang}_{s}.gfdcache");

                        await wc.DownloadFileTaskAsync(url, target);
                    }

                    wc.DownloadFile(Path.Combine(ETC.server, "OldGFDVer.txt"), Path.Combine(ETC.systemPath, "OldGFDVer.txt"));
                }

                ETC.ShowSnackbar(snackbarLayout_F, Resource.String.UpdateDownload_Complete, Snackbar.LengthLong, Android.Graphics.Color.DarkOliveGreen);
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, Activity);
                ETC.ShowSnackbar(snackbarLayout_F, Resource.String.UpdateDownload_Fail, Snackbar.LengthLong, Android.Graphics.Color.DarkRed);
            }
            finally
            {
                dialog.Dismiss();
            }

            await Task.Delay(100);
        }
Example #20
0
        private async Task CropImageDownloadProcess <T>(List <T> downloadList, string serverPath, string targetPath)
        {
            Dialog      dialog;
            ProgressBar totalProgressBar;
            ProgressBar nowProgressBar;
            TextView    totalProgress;
            TextView    nowProgress;

            var v = LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null);

            int pNow   = 0;
            int pTotal = 0;

            var pd = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGDownload);

            pd.SetTitle(Resource.String.DBList_DownloadCropImageTitle);
            pd.SetCancelable(false);
            pd.SetView(v);

            dialog = pd.Create();
            dialog.Show();

            try
            {
                totalProgressBar = v.FindViewById <ProgressBar>(Resource.Id.TotalProgressBar);
                totalProgress    = v.FindViewById <TextView>(Resource.Id.TotalProgressPercentage);
                nowProgressBar   = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar);
                nowProgress      = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage);

                pTotal = downloadList.Count;
                totalProgressBar.Max      = 100;
                totalProgressBar.Progress = pNow;

                using (var wc = new WebClient())
                {
                    wc.DownloadProgressChanged += (sender, e) =>
                    {
                        nowProgressBar.Progress = e.ProgressPercentage;

                        MainThread.BeginInvokeOnMainThread(() => { nowProgress.Text = $"{e.ProgressPercentage}%"; });
                    };
                    wc.DownloadFileCompleted += (sender, e) =>
                    {
                        pNow += 1;
                        totalProgressBar.Progress = Convert.ToInt32((pNow / Convert.ToDouble(pTotal)) * 100);

                        MainThread.BeginInvokeOnMainThread(() => { totalProgress.Text = $"{totalProgressBar.Progress}%"; });
                    };

                    for (int i = 0; i < pTotal; ++i)
                    {
                        string url    = Path.Combine(serverPath, $"{downloadList[i]}.png");
                        string target = Path.Combine(targetPath, $"{downloadList[i]}.gfdcache");

                        await wc.DownloadFileTaskAsync(url, target);
                    }
                }

                ETC.ShowSnackbar(snackbarLayout, Resource.String.DBList_DownloadCropImageComplete, Snackbar.LengthLong, Android.Graphics.Color.DarkOliveGreen);

                await Task.Delay(500);

                _ = ListItem();
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                ETC.ShowSnackbar(snackbarLayout, Resource.String.DBList_DownloadCropImageFail, Snackbar.LengthShort, Android.Graphics.Color.DeepPink);
            }
            finally
            {
                dialog.Dismiss();
            }
        }
Example #21
0
        /// <summary>
        /// Check DB version & Refresh notification data
        /// </summary>
        private async Task CheckNetworkData()
        {
            await Task.Delay(100);

            //tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBChecking)})";

            try
            {
                // Check Server Status


                /*await Task.Run(async () =>
                 * {
                 *  // Check DB Version
                 *
                 *  if (await ETC.CheckDBVersion())
                 *  {
                 *      //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateAvailable)})"; });
                 *
                 *      var ad = new Android.Support.V7.App.AlertDialog.Builder(this, ETC.dialogBG);
                 *      ad.SetTitle(Resource.String.CheckDBUpdateDialog_Title);
                 *      ad.SetMessage(Resource.String.CheckDBUpdateDialog_Question);
                 *      ad.SetCancelable(true);
                 *      ad.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
                 *      ad.SetPositiveButton(Resource.String.AlertDialog_Confirm, async delegate
                 *      {
                 *          await ETC.UpdateDB(this, true);
                 *
                 *          if (!await ETC.CheckDBVersion())
                 *          {
                 *              //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateNewest)})"; });
                 *          }
                 *          else
                 *          {
                 *              //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateAvailable)})"; });
                 *          }
                 *
                 *      });
                 *
                 *      RunOnUiThread(() => { ad.Show(); });
                 *  }
                 *  else
                 *  {
                 *      //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateNewest)})"; });
                 *  }
                 * });*/

                if (await ETC.CheckDBVersion())
                {
                    //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateAvailable)})"; });

                    var ad = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBG);
                    ad.SetTitle(Resource.String.CheckDBUpdateDialog_Title);
                    ad.SetMessage(Resource.String.CheckDBUpdateDialog_Question);
                    ad.SetCancelable(true);
                    ad.SetNegativeButton(Resource.String.AlertDialog_Cancel, delegate { });
                    ad.SetPositiveButton(Resource.String.AlertDialog_Confirm, async delegate
                    {
                        await ETC.UpdateDB(this, true);

                        if (!await ETC.CheckDBVersion())
                        {
                            //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateNewest)})"; });
                        }
                        else
                        {
                            //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateAvailable)})"; });
                        }
                    });

                    RunOnUiThread(() => { ad.Show(); });
                }
                else
                {
                    //RunOnUiThread(() => { tv.Text = $"DB Ver.{ETC.dbVersion} ({Resources.GetString(Resource.String.Main_DBUpdateNewest)})"; });
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                ETC.ShowSnackbar(snackbarLayout, Resource.String.Main_NotificationInitializeFail, Snackbar.LengthLong, Android.Graphics.Color.DarkRed);
            }
        }
        private async Task DownloadAllCache()
        {
            var downloadURLs = new List <(string source, string target)>();

            var v = LayoutInflater.Inflate(Resource.Layout.SpinnerProgressDialogLayout, null);

            var ad = new AndroidX.AppCompat.App.AlertDialog.Builder(Activity, ETC.dialogBG);
            var pd = new AndroidX.AppCompat.App.AlertDialog.Builder(Activity, ETC.dialogBGDownload);

            pd.SetTitle(Resource.String.SettingActivity_DownloadAllCache_DialogTitle);
            pd.SetMessage(Resource.String.SettingActivity_DownloadAllCache_DialogMessage);
            pd.SetCancelable(false);
            pd.SetView(v);

            var dialog = pd.Show();

            try
            {
                var statusText = v.FindViewById <TextView>(Resource.Id.SpinnerProgressStatusMessage);

                statusText.Text = "Ready download list...";

                await Task.Delay(100);

                var listThread = new Thread(new ThreadStart(delegate
                {
                    if (categoryCheck[CacheCategory.Dic])
                    {
                        ListDoll(downloadURLs);
                        ListEquip(downloadURLs);
                        ListFairy(downloadURLs);
                        ListEnemy(downloadURLs);
                        ListFST(downloadURLs);
                        ListCoalition(downloadURLs);
                        ListSkill(downloadURLs);
                    }
                    if (categoryCheck[CacheCategory.OldGFD])
                    {
                        ListOldGFD(downloadURLs);
                    }
                    if (categoryCheck[CacheCategory.GuideBook])
                    {
                        ListGuideBook(downloadURLs);
                    }
                    if (categoryCheck[CacheCategory.Story])
                    {
                        ListStory(downloadURLs);
                    }
                    if (categoryCheck[CacheCategory.PV])
                    {
                        ListPV(downloadURLs);
                    }
                    if (categoryCheck[CacheCategory.OST])
                    {
                        ListMusic(downloadURLs);
                    }

                    /*if (categoryCheck[CacheCategory.Cartoon])
                     * {
                     *  ListCartoon(downloadURLs);
                     * }*/
                }));

                listThread.Start();
                listThread.Join();

                using (var wc = new WebClient())
                {
                    var now   = 0;
                    var total = downloadURLs.Count;

                    wc.DownloadFileCompleted += (sender, e) => { statusText.Text = $"{++now}/{total}"; };

                    foreach (var(source, target) in downloadURLs)
                    {
                        try
                        {
                            await wc.DownloadFileTaskAsync(source, target);
                        }
                        catch
                        {
                            statusText.Text += " Retry";
                            await wc.DownloadFileTaskAsync(source, target);
                        }
                    }
                }

                Toast.MakeText(Activity, Resource.String.SettingActivity_DownloadAllCache_CompleteDialogMessage, ToastLength.Short).Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(Activity, Resource.String.SettingActivity_DownloadAllCache_FailDialogMessage, ToastLength.Short).Show();
            }
            finally
            {
                dialog.Dismiss();
            }
        }
Example #23
0
        internal static async Task UpdateDB(Activity activity, bool dbLoad = false, int titleMsg = Resource.String.CheckDBUpdateDialog_Title, int messageMgs = Resource.String.CheckDBUpdateDialog_Message)
        {
            Dialog dialog;
            View   v = activity.LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null);

            TextView    status           = v.FindViewById <TextView>(Resource.Id.ProgressStatusMessage);
            ProgressBar totalProgressBar = v.FindViewById <ProgressBar>(Resource.Id.TotalProgressBar);
            TextView    totalProgress    = v.FindViewById <TextView>(Resource.Id.TotalProgressPercentage);
            ProgressBar nowProgressBar   = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar);
            TextView    nowProgress      = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage);

            var pd = new AndroidX.AppCompat.App.AlertDialog.Builder(activity, dialogBGDownload);

            pd.SetTitle(titleMsg);
            pd.SetMessage(Resources.GetString(messageMgs));
            pd.SetView(v);
            pd.SetCancelable(false);

            dialog = pd.Create();
            dialog.Show();

            await Task.Delay(100);

            try
            {
                totalProgressBar.Max      = dbFiles.Length;
                totalProgressBar.Progress = 0;

                using (WebClient wc = new WebClient())
                {
                    wc.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
                    {
                        nowProgressBar.Progress = e.ProgressPercentage;
                        nowProgress.Text        = (e.BytesReceived > 2048) ? $"{e.BytesReceived / 1024}KB" : $"{e.BytesReceived}B";
                    };
                    wc.DownloadFileCompleted += (object sender, System.ComponentModel.AsyncCompletedEventArgs e) =>
                    {
                        totalProgressBar.Progress += 1;
                        totalProgress.Text         = $"{totalProgressBar.Progress} / {totalProgressBar.Max}";
                    };

                    for (int i = 0; i < dbFiles.Length; ++i)
                    {
                        await wc.DownloadFileTaskAsync(Path.Combine(server, "Data", "DB", dbFiles[i]), Path.Combine(tempPath, dbFiles[i]));
                    }

                    await wc.DownloadFileTaskAsync(Path.Combine(server, "DBVer.txt"), Path.Combine(tempPath, "DBVer.txt"));

                    await Task.Delay(100);
                }

                for (int i = 0; i < dbFiles.Length; ++i)
                {
                    //File.Copy(Path.Combine(tempPath, DBFiles[i]), Path.Combine(DBPath, DBFiles[i]), true);
                    CopyFile(Path.Combine(tempPath, dbFiles[i]), Path.Combine(dbPath, dbFiles[i]));

                    await Task.Delay(100);
                }

                await Task.Delay(500);

                activity.RunOnUiThread(() => { status.Text = Resources.GetString(Resource.String.UpdateDBDialog_RefreshVersionMessage); });

                string oldVersion = Path.Combine(systemPath, "DBVer.txt");
                string newVersion = Path.Combine(tempPath, "DBVer.txt");

                //File.Copy(newVersion, oldVersion, true);
                CopyFile(newVersion, oldVersion);

                using (StreamReader sr = new StreamReader(new FileStream(oldVersion, FileMode.Open, FileAccess.Read)))
                {
                    _ = int.TryParse(sr.ReadToEnd(), out dbVersion);
                }

                await Task.Delay(500);

                if (dbLoad)
                {
                    activity.RunOnUiThread(() => { status.Text = Resources.GetString(Resource.String.UpdateDBDialog_LoadDB); });

                    await Task.Delay(100);
                    await LoadDB();
                }
            }
            catch (Exception ex)
            {
                LogError(ex, activity);
            }
            finally
            {
                dialog.Dismiss();
            }
        }
Example #24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                Xamarin.Essentials.Platform.Init(this, savedInstanceState);

                SetContentView(Resource.Layout.content_main);

                #region Fragment navigation

                BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);
                navigation?.SetOnNavigationItemSelectedListener(this);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, new HomeFragment())
                .Commit();

                #endregion

                #region Settings

                settings = Settings.Instance;

                #endregion

                #region App Center Crash (http: // appcenter.ms )

                if (settings.IsSendCrashes == true)
                {
                    AppCenter.Start(AppCenterId, new Type[] { typeof(Crashes) });

                    Crashes.SendingErrorReport += (sender, e) => CrashesSendingErrorReport(sender, e);

                    Crashes.ShouldAwaitUserConfirmation = () =>
                    {
                        AndroidX.AppCompat.App.AlertDialog.Builder alert = new AndroidX.AppCompat.App.AlertDialog.Builder(Platform.CurrentActivity);
                        alert.SetTitle("Confirm send");
                        alert.SetMessage("Send anonymous data about crashes in the app?");

                        alert.SetPositiveButton("Send", (senderAlert, args) =>
                        {
                            UserConfirmationDialog(UserConfirmation.Send);

                            Toast.MakeText(context, "Send", ToastLength.Short).Show();
                        });

                        alert.SetNegativeButton("Cancel", (senderAlert, args) =>
                        {
                            UserConfirmationDialog(UserConfirmation.DontSend);

                            Toast.MakeText(context, "Not Send", ToastLength.Short).Show();
                        });

                        Dialog dialog = alert.Create();
                        dialog.Show();

                        return(true);
                    };
                }

                #endregion

                if (settings.IsLogErrorStorage == true)
                {
                    Task.Run(() => PermissionsCheckRun());
                }
            }
            catch (Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(MainActivity), ex);
                #endregion
            }
        }
Example #25
0
        private async Task UpdateEvent()
        {
            View v = LayoutInflater.Inflate(Resource.Layout.ProgressDialogLayout, null);

            ProgressBar totalProgressBar = v.FindViewById <ProgressBar>(Resource.Id.TotalProgressBar);
            TextView    totalProgress    = v.FindViewById <TextView>(Resource.Id.TotalProgressPercentage);
            ProgressBar nowProgressBar   = v.FindViewById <ProgressBar>(Resource.Id.NowProgressBar);
            TextView    nowProgress      = v.FindViewById <TextView>(Resource.Id.NowProgressPercentage);

            var pd = new AndroidX.AppCompat.App.AlertDialog.Builder(this, ETC.dialogBGDownload);

            pd.SetTitle(Resource.String.UpdateEventDialog_Title);
            pd.SetMessage(Resources.GetString(Resource.String.UpdateEventDialog_Message));
            pd.SetView(v);
            pd.SetCancelable(false);

            Dialog dialog = pd.Create();

            dialog.Show();

            await Task.Delay(100);

            try
            {
                nowProgressBar.Indeterminate   = true;
                totalProgressBar.Indeterminate = true;

                if (!Directory.Exists(ETC.tempPath))
                {
                    Directory.CreateDirectory(ETC.tempPath);
                }
                if (!Directory.Exists(Path.Combine(ETC.cachePath, "Event", "Images")))
                {
                    Directory.CreateDirectory(Path.Combine(ETC.cachePath, "Event", "Images"));
                }

                using (WebClient wc = new WebClient())
                {
                    string url    = Path.Combine(ETC.server, "EventVer.txt");
                    string target = Path.Combine(ETC.tempPath, "EventVer.txt");

                    await wc.DownloadFileTaskAsync(url, target);

                    await Task.Delay(500);

                    nowProgressBar.Indeterminate   = false;
                    totalProgressBar.Indeterminate = false;
                    totalProgressBar.Progress      = 0;

                    wc.DownloadProgressChanged += (sender, e) =>
                    {
                        nowProgressBar.Progress = e.ProgressPercentage;
                        nowProgress.Text        = e.BytesReceived > 2048 ? $"{e.BytesReceived / 1024}KB" : $"{e.BytesReceived}B";
                    };
                    wc.DownloadFileCompleted += (sender, e) =>
                    {
                        totalProgressBar.Progress += 1;
                        totalProgress.Text         = $"{totalProgressBar.Progress} / {totalProgressBar.Max}";
                    };

                    int totalCount = 0;

                    using (StreamReader sr = new StreamReader(new FileStream(Path.Combine(ETC.tempPath, "EventVer.txt"), FileMode.Open, FileAccess.Read)))
                    {
                        totalCount += int.Parse(sr.ReadToEnd().Split(';')[2]);
                    }

                    totalProgressBar.Max = totalCount;

                    for (int i = 1; i <= totalCount; ++i)
                    {
                        string url2    = Path.Combine(ETC.server, "Data", "Images", "Events", "Event_" + i + ".png");
                        string target2 = Path.Combine(ETC.cachePath, "Event", "Images", "Event_" + i + ".png");

                        await wc.DownloadFileTaskAsync(url2, target2);

                        await Task.Delay(100);
                    }

                    await Task.Delay(500);

                    RunOnUiThread(() => { pd.SetMessage(Resources.GetString(Resource.String.UpdateEventDialog_RefreshVersionMessage)); });

                    string oldVersion = Path.Combine(ETC.cachePath, "Event", "EventVer.txt");
                    string newVersion = Path.Combine(ETC.tempPath, "EventVer.txt");

                    ETC.CopyFile(newVersion, oldVersion);

                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
            }
            finally
            {
                dialog.Dismiss();
            }
        }