Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pbreault/adb-idea into pb…
Browse files Browse the repository at this point in the history
…reault-master

# Conflicts:
#	build.gradle
#	src/main/kotlin/com/developerphil/adbidea/adb/AdbFacade.kt
#	src/main/kotlin/com/developerphil/adbidea/debugger/Debugger.kt
#	src/main/kotlin/com/developerphil/adbidea/ui/DeviceChooserDialog.kt
#	src/main/kotlin/com/developerphil/adbidea/ui/NotificationHelper.kt
#	src/main/resources/META-INF/plugin.xml
  • Loading branch information
longforus committed Oct 19, 2020
1 parent eacce3c commit ee35fd1
Show file tree
Hide file tree
Showing 43 changed files with 521 additions and 412 deletions.
27 changes: 14 additions & 13 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@ Run/Debug
=========

* Open project in intellij
* Create gradle.properties file, use [instruction](gradle.properties.change_me)
* Open _edit configurations_ to create a new run/debug configuration
* Choose a new gradle configuration and name it `build and run` that runs <code>./gradlew buildPlugin runIdea</code>
* Choose a new gradle configuration and name it `build and run` that runs `./gradlew buildPlugin runIde`
![Create debug configuration](website/debug_howto.png)
* hit debug button as usual

Running from command line
-------------------------
<code>
./gradlew buildPlugin runIdea
</code>
* Create gradle.properties file, use [instruction](gradle.properties.change_me)
* Execute command
```shell script
./gradlew buildPlugin runIde
```

Create new menu item
====================

* Add entry to plugin.xml (below line 100)
<code>

* Add entry to plugin.xml inside actions tab (below line 100)
```xml
<action id="com.developerphil.adbidea.action.NewAction"
class="com.developerphil.adbidea.action.NewAction"
text="New Action"
description="Playing with the plugin">
</action>
</code>
```

* Create and implement a new `NewAction` class that extends from `AdbAction` (you can create that from the plugin view, right click on the class name and choose `create class`
* implement its abstract methods
* add new entry in `QuickListAction.java` like this
<code>

addAction("com.developerphil.adbidea.action.NewAction", group);
</code>
* add new entry in `QuickListAction.kt` like this
```kotlin
addAction("com.developerphil.adbidea.action.NewAction", group)
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {

ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.3.61'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void mouseClicked(MouseEvent e) {
Utils.Companion.append2TextPane("Monkey test of " + name + " :\n", JBColor.BLUE,tp);
}
String countStr = JOptionPane.showInputDialog("Enter test count(only integers):");
if (countStr.isEmpty()) {
if (countStr==null||countStr.isEmpty()) {
HelperMethodsKt.showErrorMsg("count can not empty");
return;
}
Expand Down
154 changes: 0 additions & 154 deletions src/main/java/com/developerphil/adbidea/ui/DeviceChooserDialog.java

This file was deleted.

29 changes: 29 additions & 0 deletions src/main/kotlin/com/developerphil/adbidea/Application.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.developerphil.adbidea

import com.developerphil.adbidea.preference.ApplicationPreferences
import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl
import com.developerphil.adbidea.ui.NotificationHelper
import com.intellij.ide.plugins.PluginManager
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.components.ApplicationComponent
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.text.SemVer


private val pluginPackage = "com.developerphil.adbidea"

// This is more of a service locator than a proper DI framework.
// It's not used often enough in the codebase to warrant the complexity of a DI solution like dagger.
class Application : ApplicationComponent {
private val applicationPreferencesAccessor = PreferenceAccessorImpl(PropertiesComponent.getInstance())
private val applicationPreferences = ApplicationPreferences(applicationPreferencesAccessor)

override fun initComponent() {
try {
val version = PluginManager.getPlugin(PluginId.getId(pluginPackage))!!.version!!
applicationPreferences.savePreviousPluginVersion(SemVer.parseFromText(version)!!)
} catch (e: Exception) {
NotificationHelper.error("Couldn't initialize ADB Idea: ${e.message}")
}
}
}
10 changes: 6 additions & 4 deletions src/main/kotlin/com/developerphil/adbidea/ObjectGraph.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.developerphil.adbidea

import com.developerphil.adbidea.accessor.preference.ProjectPreferenceAccessor
import com.developerphil.adbidea.adb.BridgeImpl
import com.developerphil.adbidea.adb.DeviceResultFetcher
import com.developerphil.adbidea.adb.UseSameDevicesHelper
import com.developerphil.adbidea.preference.ProjectPreferences
import com.developerphil.adbidea.preference.accessor.PreferenceAccessorImpl
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.components.ProjectComponent
import com.intellij.openapi.project.Project

Expand All @@ -12,10 +14,10 @@ import com.intellij.openapi.project.Project
class ObjectGraph(private val project: Project) : ProjectComponent {

val deviceResultFetcher by lazy { DeviceResultFetcher(project, useSameDevicesHelper, bridge) }
val pluginPreferences: PluginPreferences by lazy { PluginPreferencesImpl(preferenceAccessor) }
val projectPreferences: ProjectPreferences by lazy { ProjectPreferences(projectPreferenceAccessor) }

private val useSameDevicesHelper by lazy { UseSameDevicesHelper(pluginPreferences, bridge) }
private val preferenceAccessor by lazy { ProjectPreferenceAccessor(project) }
private val useSameDevicesHelper by lazy { UseSameDevicesHelper(projectPreferences, bridge) }
private val projectPreferenceAccessor by lazy { PreferenceAccessorImpl(PropertiesComponent.getInstance(project)) }
private val bridge by lazy { BridgeImpl(project) }


Expand Down
28 changes: 0 additions & 28 deletions src/main/kotlin/com/developerphil/adbidea/PluginPreferences.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.developerphil.adbidea.action

import com.developerphil.adbidea.adb.AdbFacade
import com.developerphil.adbidea.adb.AdbUtil
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class ClearDataAndRestartWithDebuggerAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.clearDataAndRestartWithDebugger(project)

override fun update(e: AnActionEvent) {
e.presentation.isEnabled = AdbUtil.isDebuggingAvailable
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.developerphil.adbidea.action

import com.developerphil.adbidea.adb.AdbFacade
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class DisableMobileAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.disableMobile(project)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.developerphil.adbidea.action

import com.developerphil.adbidea.adb.AdbFacade
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class DisableWifiAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.disableWifi(project)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.developerphil.adbidea.action

import com.developerphil.adbidea.adb.AdbFacade
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class EnableMobileAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.enableMobile(project)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.developerphil.adbidea.action

import com.developerphil.adbidea.adb.AdbFacade
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class EnableWifiAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.enableWifi(project)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ class ScreenRecordAction : AdbAction() {
}
val dialog = RecordOptionDialog { deleteRemoteFile ->
saveDirChooserDescriptor.title = "Select $videoName save to..."
val choose = FileChooserDialogImpl(saveDirChooserDescriptor, project)
.choose(project, selectedFile)
val chooserDialogImpl = FileChooserDialogImpl(saveDirChooserDescriptor, project)
val choose = if (selectedFile != null) {
chooserDialogImpl
.choose(project, selectedFile!!)
} else {
chooserDialogImpl
.choose(project)
}
if (choose.isNotEmpty()) {
selectedFile = choose[0]
AdbFacade.pullFile(project, remotePath, File(selectedFile?.canonicalPath, videoName), deleteRemoteFile)
Expand Down
Loading

0 comments on commit ee35fd1

Please sign in to comment.