示例#1
0
        /// <summary>
        /// Executes the specified plugin host.
        /// </summary>
        /// <param name="pluginHost">The plugin host.</param>
        /// <param name="currentDirectory">The current directory.</param>
        /// <param name="args">The args.</param>
        public override void Execute( IPluginHost pluginHost, DroidExplorer.Core.IO.LinuxDirectoryInfo currentDirectory, string[] args )
        {
            Arguments arguments = new Arguments ( args ?? new string[] { "/install" } );
            string apkFile = string.Empty;
            var apkArg = arguments.Contains ( "apk" ) ? arguments["apk"] : string.Empty;

            // check that we have a file, and that it exists.
            if ( !string.IsNullOrWhiteSpace(apkArg) && System.IO.File.Exists(apkArg) ) {
                apkFile = apkArg;
            } else {
                System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ( );
                ofd.Title = "Select Android Application";
                ofd.Filter = "Android Applications|*.apk";
                ofd.CheckFileExists = true;
                ofd.Multiselect = false;
                if ( ofd.ShowDialog ( ) == DialogResult.OK ) {
                    apkFile = ofd.FileName;
                } else {
                    return;
                }

            }

            if ( File.Exists ( apkFile ) ) {
                try {
                    var apkInfo = this.PluginHost.CommandRunner.GetLocalApkInformation ( apkFile );
                    var id = new InstallDialog ( this.PluginHost, arguments.Contains( "uninstall" ) ? InstallDialog.InstallMode.Uninstall : InstallDialog.InstallMode.Install, apkInfo );
                    if ( pluginHost != null && pluginHost.GetHostWindow() != null ) {
                        id.Show ( );
                    } else {
                        id.ShowInTaskbar = true;
                        id.ShowDialog ( );
                    }
                } catch ( Exception ex ) {
                    MessageBox.Show ( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1 );
                    this.LogError ( ex.Message, ex );
                }
            }
        }
示例#2
0
 // TODO: async
 private void uninstallToolStripMenuItem_Click( object sender, EventArgs e )
 {
     if ( itemsList.SelectedItems.Count == 1 && itemsList.SelectedItems[0] is ApkFileSystemInfoListViewItem ) {
         ApkFileSystemInfoListViewItem apkFile = itemsList.SelectedItems[0] as ApkFileSystemInfoListViewItem;
         /*string package = apkFile.ApkInfo.Package;
         if ( string.IsNullOrEmpty ( package ) ) {
             // display error that we can not uninstall because we don't know the package name
             TaskDialog.MessageBox ( "Uninstall Error", string.Format ( Properties.Resources.UninstallErrorMessage, apkFile.Label ),
                 Properties.Resources.UninstallErrorNoPackageMessage, TaskDialogButtons.OK, SysIcons.Error );
         } else {
             // uninstall and refresh if successful, otherwise display error message
             if ( CommandRunner.Instance.UninstallApk ( package ) ) {
                 NavigateToPath ( this.CurrentDirectory );
             } else {
                 TaskDialog.MessageBox ( "Uninstall Error", string.Format ( Properties.Resources.UninstallErrorMessage, apkFile.Label ),
                     Properties.Resources.UninstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
             }
         }*/
         InstallDialog install = new InstallDialog ( this, InstallDialog.InstallMode.Uninstall, apkFile.ApkInfo );
         if ( install.ShowDialog ( this ) == DialogResult.OK ) {
             NavigateToPath ( this.CurrentDirectory );
         }
     }
 }
示例#3
0
        // TODO: async
        private void installToolStripMenuItem_Click( object sender, EventArgs e )
        {
            if ( itemsList.SelectedItems.Count == 1 && itemsList.SelectedItems[0] is ApkFileSystemInfoListViewItem ) {
                ApkFileSystemInfoListViewItem apkFile = itemsList.SelectedItems[0] as ApkFileSystemInfoListViewItem;
                System.IO.FileInfo apk = CommandRunner.Instance.PullFile ( apkFile.FileSystemInfo.FullPath );
                apkFile.ApkInfo.LocalApk = apk.FullName;
                /*if ( apk.Exists ) {
                    if ( CommandRunner.Instance.InstallApk ( apk.FullName ) ) {
                        NavigateToPath ( this.CurrentDirectory );
                    } else {
                        TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.InstallErrorMessage, apkFile.Label ),
                            Properties.Resources.InstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
                    }
                }*/

                InstallDialog install = new InstallDialog ( this, InstallDialog.InstallMode.Install, apkFile.ApkInfo );
                if ( install.ShowDialog ( this ) == DialogResult.OK ) {
                    NavigateToPath ( this.CurrentDirectory );
                }
            }
        }
示例#4
0
 private void installPackageToolStripMenuItem_Click( object sender, EventArgs e )
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ( );
     ofd.Filter = "Android Application|*.apk";
     ofd.FilterIndex = 0;
     ofd.Title = "Select Android Application to Install";
     if ( ofd.ShowDialog ( this ) == DialogResult.OK ) {
         AaptBrandingCommandResult apkInfo = CommandRunner.Instance.GetLocalApkInformation ( ofd.FileName );
         InstallDialog install = new InstallDialog ( this, InstallDialog.InstallMode.Install, apkInfo );
         install.ShowDialog ( this );
     }
 }
        private void uninstallToolStripButton_Click( object sender, EventArgs e )
        {
            if ( this.packagesList.SelectedItems.Count == 1 ) {
            ApkPackageListViewItem lvi = packagesList.SelectedItems[ 0 ] as ApkPackageListViewItem;
            if ( lvi != null && lvi.ApkInformation != null && !string.IsNullOrEmpty ( lvi.ApkInformation.Package ) ) {
              InstallDialog install = new InstallDialog ( (IPluginHost)this.ParentForm, InstallDialog.InstallMode.Uninstall, lvi.ApkInformation );
              if ( install.ShowDialog ( this ) == DialogResult.OK ) {
            RemoveListViewItem ( packagesList.Items, lvi );
              }

              /*string package = lvi.ApkInformation.Package;
              string name = string.IsNullOrEmpty ( lvi.ApkInformation.Label ) ? lvi.ApkInformation.Package : lvi.ApkInformation.Label;

              if ( CommandRunner.Instance.UninstallApk ( package ) ) {
            try {
                RemoveListViewItem ( packagesList.Items, lvi );
                TaskDialog.MessageBox ( "Uninstall Complete", string.Format ( "Successfully uninstalled {0}", name ),
                string.Empty, TaskDialogButtons.OK, SysIcons.Information );
            } catch ( Exception ex ) {
              Console.WriteLine ( "[{0}] {1}", this.GetType ( ).Name, ex.ToString ( ) );

              TaskDialog.MessageBox ( "Uninstall Error", string.Format ( Properties.Resources.UninstallErrorMessage, name ),
                ex.Message, TaskDialogButtons.OK, SysIcons.Error );
            }
              } else {
            TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.UninstallErrorMessage, name ),
              Properties.Resources.UninstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
              }*/
            }
              }
        }
        private void installToolStripButton_Click( object sender, EventArgs e )
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ();
              ofd.Title = "Select application to install";
              ofd.Filter = "Android Application|*.apk|All Files (*.*)|*.*";
              ofd.FilterIndex = 0;
              ofd.InitialDirectory = Environment.GetFolderPath ( Environment.SpecialFolder.Desktop );
              ofd.RestoreDirectory = true;
              ofd.Multiselect = false;
              if ( ofd.ShowDialog ( this ) == DialogResult.OK ) {
            AaptBrandingCommandResult apkInfo = CommandRunner.Instance.GetLocalApkInformation ( ofd.FileName );
            apkInfo.LocalApk = ofd.FileName;
            InstallDialog install = new InstallDialog ((IPluginHost)this.ParentForm, InstallDialog.InstallMode.Install, apkInfo );
            install.ShowDialog ( this );

            /*if ( CommandRunner.Instance.InstallApk ( ofd.FileName ) ) {
              try {
              TaskDialog.MessageBox ( "Install Complete", string.Format ( "Successfully installed {0}", System.IO.Path.GetFileName ( ofd.FileName ) ),
            string.Empty, TaskDialogButtons.OK, SysIcons.Information );
              } catch ( Exception ex ) {
            Console.WriteLine ( "[{0}] {1}", this.GetType ( ).Name, ex.ToString ( ) );

            TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.InstallErrorMessage, System.IO.Path.GetFileName ( ofd.FileName ) ),
              ex.Message, TaskDialogButtons.OK, SysIcons.Error );
              }
            } else {
              TaskDialog.MessageBox ( "Install Error", string.Format ( Properties.Resources.InstallErrorMessage, System.IO.Path.GetFileName ( ofd.FileName ) ),
            Properties.Resources.InstallErrorGenericMessage, TaskDialogButtons.OK, SysIcons.Error );
            }*/

              }
        }