private void DecompileFile(string file)
        {
            _globalVariables.CurrentProjectFile.Value = file;

            string logPath = Path.Combine(Path.GetDirectoryName(file) ?? string.Empty,
                                          $"{Path.GetFileNameWithoutExtension(file)}_log.txt");

            if (!TryCreateNewLog(logPath))
            {
                return;
            }

            if (Apk != null)
            {
                Apk.Logging -= VisLog;
            }

            Apk = new Apktools(
                file,
                GlobalVariables.PathToResources,
                GlobalVariables.CurrentApktoolPath
                );

            Apk.Logging += VisLog;

            if (!Apk.HasJava())
            {
                MessBox.ShowDial(StringResources.JavaNotFoundError, StringResources.ErrorLower);
                return;
            }

            ClearVisLog();

            bool success = false;

            LoadingWindow.ShowWindow(
                beforeStarting: () => IsBusy     = true,
                threadActions: source => success = GlobalVariables.AppSettings.OnlyResources ? Apk.Decompile(options: "-s") : Apk.Decompile(),
                finishActions: () =>
            {
                IsBusy = false;

                VisLog(LogLine);
                VisLog(StringResources.Finished);
                VisLog(LogLine);

                if (GlobalVariables.AppSettings.ShowNotifications)
                {
                    NotificationService.Instance.ShowMessage(StringResources.DecompilationFinished);
                }

                if (success)
                {
                    Application.Current.Dispatcher.InvokeAction(() => LoadFolder(_globalVariables.CurrentProjectFolder.Value, true));
                }
            },
                cancelVisibility: Visibility.Collapsed,
                ownerWindow: _window
                );
        }
Beispiel #2
0
        private void BuildCommand_Execute()
        {
            if (Apk == null)
            {
                return;
            }

            if (!Apk.HasJava())
            {
                MessBox.ShowDial(StringResources.JavaNotFoundError, StringResources.ErrorLower);
                return;
            }

            ClearVisLog();

            bool success = false;
            var  errors  = new List <Error>();

            LoadingWindow.ShowWindow(
                beforeStarting: () => IsBusy     = true,
                threadActions: source => success = Apk.Compile(out errors),
                finishActions: () =>
            {
                IsBusy = false;

                VisLog(LogLine);
                VisLog(success ? StringResources.Finished : StringResources.ErrorWhileCompiling);
                VisLog(LogLine);

                if (GlobalVariables.AppSettings.ShowNotifications)
                {
                    NotificationService.Instance.ShowMessage(StringResources.CompilationFinished);
                }

                if (!success && errors.Any(error => error.Type != Error.ErrorType.None))
                {
                    if (MessBox.ShowDial("Обнаружены ошибки. Попробовать исправить?", "", MessBox.MessageButtons.Yes, MessBox.MessageButtons.No) == MessBox.MessageButtons.Yes)
                    {
                        Apktools.FixErrors(errors);
                        BuildCommand_Execute();
                    }
                }
                else
                {
                    VisLog(StringResources.FileIsSituatedIn + " " + Apk.NewApk);
                }

                RaiseCommandsCanExecute();
            },
                cancelVisibility: Visibility.Collapsed,
                ownerWindow: _window
                );
        }
        public void ViewAlliance(string AllianceName)
        {
            LoadingWindow _win = new LoadingWindow();

            _bwA                     = new BackgroundWorker();
            _bwA.DoWork             += new DoWorkEventHandler(_bwA_DoWork);
            _bwA.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_bwA_RunWorkerCompleted);
            _bwA.RunWorkerAsync(AllianceName);
            _win.ShowWindow();
            //Alliance all = _repository.GetAlliance(AllianceName);

            //AddCorpAllianceTab(all);
        }
Beispiel #4
0
        private void SignCommand_Execute()
        {
            if (Apk?.NewApk == null)
            {
                return;
            }

            if (!Apk.HasJava())
            {
                MessBox.ShowDial(StringResources.JavaNotFoundError, StringResources.ErrorLower);
                return;
            }

            bool success = false;

            LoadingWindow.ShowWindow(
                beforeStarting: () => IsBusy     = true,
                threadActions: source => success = Apk.Sign(),
                finishActions: () =>
            {
                IsBusy = false;

                VisLog(LogLine);
                VisLog(success ? StringResources.Finished : StringResources.ErrorWhileSigning);

                if (success)
                {
                    string message = $"{StringResources.FileIsSituatedIn} {Apk.SignedApk}";

                    VisLog(message);

                    string dir = Path.GetDirectoryName(Apk.SignedApk);

                    if (dir != null && MessBox.ShowDial(message, StringResources.Finished, MessBox.MessageButtons.OK, StringResources.Open) == StringResources.Open)
                    {
                        Process.Start(dir);
                    }
                }
            },
                cancelVisibility: Visibility.Collapsed,
                ownerWindow: _window
                );

            VisLog(string.Format("{0}{1}Signing...{1}{0}", LogLine, Environment.NewLine));
        }