Beispiel #1
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);
            }
        }
        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);
            }
        }
Beispiel #3
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();
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public static void ShowDialog(Context context, Action positive, Action negative,
                                      string question, string positiveAns, string negativeAns)
        {
            var dialog = new AndroidX.AppCompat.App.AlertDialog.Builder(context, Resource.Style.AppCompatAlertDialogStyle);

            dialog.SetMessage(question);

            dialog.SetNegativeButton(negativeAns, (thisalert, args) =>
            {
                negative();
            });

            dialog.SetPositiveButton(positiveAns, (thisalert, args) =>
            {
                positive();
            });

            dialog.Show();
        }
        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();
            }
        }
Beispiel #9
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();
            }
        }
Beispiel #10
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
            }
        }
Beispiel #11
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);
            }
        }
Beispiel #12
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();
            }
        }