Skip to content

Commit

Permalink
Add mvp some action
Browse files Browse the repository at this point in the history
  • Loading branch information
guodongAndroid committed Mar 27, 2023
1 parent 88a17da commit 34100cd
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 10 deletions.
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 MVPDumpAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.mvpDump(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 MVPDumpTracesAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.mvpDumpTraces(project)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import com.developerphil.adbidea.adb.AdbFacade
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project

class ShowMVPDebugViewAction : AdbAction() {
class MVPShowDebugViewAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.showMVPDebugView(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 MVPShowVPStatsViewAction : AdbAction() {
override fun actionPerformed(e: AnActionEvent, project: Project) = AdbFacade.showMVPVPStatsView(project)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class QuickListAction : QuickSwitchSchemeAction(), DumbAware {
addAction("com.developerphil.adbidea.action.ShowSystemBarAction", group)
addAction("com.developerphil.adbidea.action.HideSystemBarAction", group)
group.addSeparator()
addAction("com.developerphil.adbidea.action.ShowMVPDebugViewAction", group)
addAction("com.developerphil.adbidea.action.MVPShowDebugViewAction", group)
addAction("com.developerphil.adbidea.action.MVPDumpAction", group)
addAction("com.developerphil.adbidea.action.MVPDumpTracesAction", group)
addAction("com.developerphil.adbidea.action.MVPShowVPStatsViewAction", group)
}


Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/developerphil/adbidea/adb/AdbFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ object AdbFacade {
fun showSystemBar(project: Project) = executeOnDevice(project, SystemBarCommand(true), false)
fun hideSystemBar(project: Project) = executeOnDevice(project, SystemBarCommand(false), false)
fun showMVPDebugView(project: Project) = executeOnDevice(project, MVPMonitorCommand(MVPMonitorCommand.CMD_DEBUG_VIEW))
fun mvpDump(project: Project) = executeOnDevice(project, MVPMonitorCommand(MVPMonitorCommand.CMD_DUMP))
fun mvpDumpTraces(project: Project) = executeOnDevice(project, MVPMonitorCommand(MVPMonitorCommand.CMD_DUMP_TRACES))
fun showMVPVPStatsView(project: Project) = executeOnDevice(project, MVPMonitorCommand(MVPMonitorCommand.CMD_VP_STATS_VIEW))

private fun executeOnDevice(project: Project, runnable: Command, isShowChooseModule: Boolean = true) {
if (AdbUtil.isGradleSyncInProgress(project)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class DeviceResultFetcher constructor(
private val bridge: Bridge
) {

fun fetch(isShowChooseModule: Boolean): DeviceResult? {
fun fetch(isShowChooseModule: Boolean): DeviceResult {
val facets = AndroidUtils.getApplicationFacets(project)
if (facets.isNotEmpty()) {
val facet = getFacet(facets, isShowChooseModule) ?: return null
val packageName = AndroidModuleModel.get(facet)?.applicationId ?: return null
val facet = getFacet(facets, isShowChooseModule) ?: return DeviceNotFound
val packageName = AndroidModuleModel.get(facet)?.applicationId ?: return DeviceNotFound

if (!bridge.isReady()) {
NotificationHelper.error("No platform configured")
return null
return DeviceNotFound
}

val rememberedDevices = useSameDevicesHelper.getRememberedDevices()
Expand All @@ -45,7 +45,7 @@ class DeviceResultFetcher constructor(
DeviceNotFound
}
}
return null
return DeviceNotFound
}

private fun getFacet(_facets: List<AndroidFacet>, isShowChooseModule: Boolean): AndroidFacet? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MVPMonitorCommand(private val cmd: Int) : Command {
const val CMD_DEBUG_VIEW = 1
const val CMD_DUMP = 2
const val CMD_DUMP_TRACES = 3
const val CMD_VP_STATS_VIEW = 4
}

override fun run(project: Project, device: IDevice, facet: AndroidFacet, packageName: String): Boolean {
Expand Down
24 changes: 21 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,30 @@
description="Hide System bar">
</action>

<action id="com.developerphil.adbidea.action.ShowMVPDebugViewAction"
class="com.developerphil.adbidea.action.ShowMVPDebugViewAction"
text="ADB Show MVP DebugView"
<action id="com.developerphil.adbidea.action.MVPShowDebugViewAction"
class="com.developerphil.adbidea.action.MVPShowDebugViewAction"
text="ADB MVP DebugView"
description="Show MVP DebugView">
</action>

<action id="com.developerphil.adbidea.action.MVPDumpAction"
class="com.developerphil.adbidea.action.MVPDumpAction"
text="ADB MVP Dump"
description="MVP dump">
</action>

<action id="com.developerphil.adbidea.action.MVPDumpTracesAction"
class="com.developerphil.adbidea.action.MVPDumpTracesAction"
text="ADB MVP DumpTraces"
description="MVP dumpTraces">
</action>

<action id="com.developerphil.adbidea.action.MVPShowVPStatsViewAction"
class="com.developerphil.adbidea.action.MVPShowVPStatsViewAction"
text="ADB MVP VPStatsView"
description="Show MVP VPStatsView">
</action>

</group>
</actions>

Expand Down

0 comments on commit 34100cd

Please sign in to comment.