Skip to content

Commit

Permalink
version 1.0.1 (#3)
Browse files Browse the repository at this point in the history
* add screen recording help

* add screen recording help

* link helps button to wiki

* change internet connection to network

* Update README.md

* remove AnimatedIcon.Blinking

* remove brand and model from DeviceInformation model

* add PARENT_GRID for BatteryView

* change anchor right to left for plugin

* change anchor right to left for plugin

* detekt

---------

Co-authored-by: Rasoul Miri <rmiri@volvocars.com>
  • Loading branch information
rasoulmiri and Rasoul Miri authored Jul 31, 2023
1 parent b41bd01 commit f1d9edd
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 73 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import java.util.*
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.8.21"
id("org.jetbrains.intellij") version "1.13.3"
id("org.jetbrains.intellij") version "1.15.0"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
}

group = "com.androidstudiotoolsmissed"
version = "1.0-SNAPSHOT"
version = "1.0.1-SNAPSHOT"

repositories {
mavenCentral()
Expand Down Expand Up @@ -83,7 +83,7 @@ tasks {
intelliJTokenFile.inputStream().use { inputStream ->
properties.load(inputStream)
}
val intelliJToken: String = properties.getProperty("password").trim()
val intelliJToken: String = properties.getProperty("token").trim()
token.set(System.getenv(intelliJToken))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package androidstudio.tools.missed.features

import androidstudio.tools.missed.manager.resource.ResourceManager
import androidstudio.tools.missed.utils.DELAY_MEDIUM
import androidstudio.tools.missed.utils.DisabledIcon
import com.intellij.icons.AllIcons
import com.intellij.openapi.ui.VerticalFlowLayout
import com.intellij.ui.AnimatedIcon
Expand All @@ -18,7 +20,11 @@ class ErrorView(private val resourceManager: ResourceManager, private val onRetr
// label
val descriptionLabel = JLabel(
resourceManager.string("InitialPluginError"),
AnimatedIcon.Blinking(AllIcons.General.BalloonError),
AnimatedIcon(
DELAY_MEDIUM.toInt(),
AllIcons.General.BalloonError,
DisabledIcon(AllIcons.General.BalloonError)
),
SwingConstants.CENTER
)
panel.add(descriptionLabel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package androidstudio.tools.missed.features

import androidstudio.tools.missed.manager.resource.ResourceManager
import androidstudio.tools.missed.utils.DELAY_MEDIUM
import androidstudio.tools.missed.utils.DisabledIcon
import com.intellij.icons.AllIcons
import com.intellij.openapi.ui.VerticalFlowLayout
import com.intellij.openapi.util.IconLoader
Expand All @@ -20,9 +22,14 @@ class NeedToConnectDeviceView(
val panel = JPanel(VerticalFlowLayout(VerticalFlowLayout.CENTER, true, false))

// label
val androidDeviceIcon = IconLoader.getIcon("/icons/androidDevice/androidDevice.svg", javaClass)
val descriptionLabel = JLabel(
resourceManager.string("needToConnectDeviceDescription"),
AnimatedIcon.Blinking(IconLoader.getIcon("/icons/androidDevice/androidDevice.svg", javaClass)),
AnimatedIcon(
DELAY_MEDIUM.toInt(),
androidDeviceIcon,
DisabledIcon(androidDeviceIcon)
),
SwingConstants.CENTER
)
panel.add(descriptionLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class ApkView(
group(resourceManager.string("downloadApkTitle")) {
row {
label(resourceManager.string("apkTitle")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools")
browserLink(
resourceManager.string("help"),
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools"
)
}

row {
Expand Down Expand Up @@ -95,7 +98,10 @@ class ApkView(
group(resourceManager.string("installApkTitle")) {
row {
label(resourceManager.string("installApplicationFromApkFiles")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools")
browserLink(
resourceManager.string("help"),
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools"
)
}

row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package androidstudio.tools.missed.features.battery.presenter
import androidstudio.tools.missed.base.CollapsibleGroupView
import androidstudio.tools.missed.manager.notification.NotificationManager
import androidstudio.tools.missed.manager.resource.ResourceManager
import androidstudio.tools.missed.utils.DIMENSION_3
import androidstudio.tools.missed.utils.debounce
import com.intellij.ui.JBIntSpinner
import com.intellij.ui.components.OnOffButton
Expand All @@ -13,6 +14,7 @@ import com.intellij.ui.dsl.builder.panel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import java.awt.Dimension
import java.awt.event.ItemEvent
import java.awt.event.ItemListener
import javax.swing.JEditorPane
Expand Down Expand Up @@ -69,8 +71,7 @@ class BatteryView(
init {
setContent(
title = resourceManager.string("batteryTitle"),
batteryDetailView(),
powerSavingModeView()
batteryDetailView()
)
}

Expand All @@ -85,6 +86,9 @@ class BatteryView(
row {
cell(chargerConnectionLabel).gap(RightGap.SMALL)
chargerConnectionComment = comment("")
chargerConnectionComment.component.apply {
preferredSize = Dimension(DIMENSION_3, chargerConnectionLabel.preferredSize.height)
}
cell(chargerConnectionButton).gap(RightGap.COLUMNS)
chargerConnectionButton.addItemListener(chargerConnectionButtonItemListener)
}.layout(RowLayout.PARENT_GRID)
Expand All @@ -96,23 +100,19 @@ class BatteryView(
batteryLevelSpinner.addChangeListener(batteryLevelSpinnerChangeListener)
cell(batteryLevelSpinner)
}.layout(RowLayout.PARENT_GRID)
}
}

private fun powerSavingModeView(): JPanel {
return panel {
row {
cell(powerSavingModeLabel).gap(RightGap.SMALL)
powerSavingModeComment = comment("")
cell(powerSavingModeButton)
powerSavingModeButton.addItemListener(powerSavingModeButtonItemListener)
}
row {
cell(powerSavingModeLabel).gap(RightGap.SMALL)
powerSavingModeComment = comment("").widthGroup("GroupName")
cell(powerSavingModeButton)
powerSavingModeButton.addItemListener(powerSavingModeButtonItemListener)
}.layout(RowLayout.PARENT_GRID)

row {
button(resourceManager.string("resetBatterySetting")) {
viewModel.resetBatterySetting()
}
row {
button(resourceManager.string("resetBatterySetting")) {
viewModel.resetBatterySetting()
}
}.layout(RowLayout.PARENT_GRID)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ internal class DevicesComboBoxRenderer(private val placeHolder: String) : JLabel
text = if (index == -1 && value == null) {
placeHolder
} else {
if ((value as? DeviceInformation)?.title != null) {
(value as? DeviceInformation)?.title
if ((value as? DeviceInformation)?.name != null) {
(value as? DeviceInformation)?.name
} else {
value.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ class DozeAndStandbyView(
group(resourceManager.string("doze")) {
row {
label(resourceManager.string("dozeDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze")
browserLink(
resourceManager.string("help"),
"https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze"
)
}

row {
Expand All @@ -102,7 +105,11 @@ class DozeAndStandbyView(
group(resourceManager.string("standby")) {
row {
label(resourceManager.string("standbyDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby#understand_app_standby")
browserLink(
resourceManager.string("help"),
"https://developer.android.com/" +
"training/monitoring-device-state/doze-standby#understand_app_standby"
)
}

row {
Expand All @@ -124,7 +131,10 @@ class DozeAndStandbyView(
group(resourceManager.string("whiteListTitle")) {
row {
label(resourceManager.string("whiteListDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby")
browserLink(
resourceManager.string("help"),
"https://developer.android.com/training/monitoring-device-state/doze-standby"
)
}

row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ class InputTextView(
return panel {
row {
text(resourceManager.string("inputTextDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Input-Tools")
browserLink(
resourceManager.string("help"),
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Input-Tools"
)
}

row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class PermissionView(
group(resourceManager.string("permissionsSingleTitle")) {
row {
label(resourceManager.string("permissionsSingleDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools")
browserLink(
resourceManager.string("help"),
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools"
)
}

row {
Expand Down Expand Up @@ -125,7 +128,10 @@ class PermissionView(
group(resourceManager.string("permissionsAllTitle")) {
row {
label(resourceManager.string("permissionsAllDescription")).gap(RightGap.SMALL)
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools")
browserLink(
resourceManager.string("help"),
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools"
)
}
row {
grantAllButton = button(resourceManager.string("grantAllPermissions")) {
Expand All @@ -136,7 +142,7 @@ class PermissionView(
}
}
}.component.apply {
preferredSize = Dimension(DIMENSION_6, preferredSize.height) // Set your preferred button size
preferredSize = Dimension(DIMENSION_6, preferredSize.height)
}

restartApplicationGrantCheckBox = checkBox(resourceManager.string("restartApplication")).component
Expand All @@ -152,7 +158,7 @@ class PermissionView(
}
}
}.component.apply {
preferredSize = Dimension(DIMENSION_6, preferredSize.height) // Set your preferred button size
preferredSize = Dimension(DIMENSION_6, preferredSize.height)
}
restartApplicationRevokeCheckBox = checkBox(resourceManager.string("restartApplication")).component
restartApplicationRevokeCheckBox.toolTipText = resourceManager.string("revokeAllPermissionsHint")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import androidstudio.tools.missed.manager.adb.logger.AdbLogger
import androidstudio.tools.missed.manager.adb.logger.AdbLoggerImpl
import com.android.ddmlib.AndroidDebugBridge
import org.koin.dsl.module
import java.util.concurrent.TimeUnit

@Suppress("MagicNumber")
val adbManagerModule = module {
single<AndroidDebugBridge> { AndroidDebugBridge.createBridge() }
single<AndroidDebugBridge> { AndroidDebugBridge.createBridge(10, TimeUnit.SECONDS) }
single<AdbLogger> { AdbLoggerImpl() }
single<AdbManager> { AdbManagerImpl(get(), get(), get()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class AdbLoggerImpl : AdbLogger {
println(
"\nExecuteShellCommand ____________________________________________________________________________" +
"\nDevice = ${
if (device?.title == "Unknow") {
if (device?.name == "Unknow") {
device.iDevice.serialNumber
} else {
device?.title?.replace("\n", "")
device?.name?.replace("\n", "")
}
}\nCommandName = ${adbCommand::class.java.simpleName}\n ${adbCommand.command} \nResult = ${
message.ifEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ interface DeviceManager {
suspend fun pullFile(remoteFilepath: String, localFilePath: String): Result<String>
suspend fun setSelectedDevice(device: DeviceInformation?)
suspend fun setSelectedPackageId(packageId: String?)
fun getDeviceSelectedName(): String
fun getDeviceSelectedName(): String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class DeviceManagerImpl(
_packageIdSelectedStateFlow.emit(null)
}

override fun getDeviceSelectedName(): String =
"${_selectedDeviceStateFlow.value?.brand} ${_selectedDeviceStateFlow.value?.model}"
override fun getDeviceSelectedName(): String? = _selectedDeviceStateFlow.value?.name

override suspend fun executeShellCommand(adbCommand: AdbCommand): Result<String> {
if (adbCommand.isNeedDevice && (_selectedDeviceStateFlow.value == null || _devicesStateFlow.value.isEmpty())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@ package androidstudio.tools.missed.manager.device.model
import com.android.ddmlib.IDevice
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly

class DeviceInformation(var title: String, var brand: String, var model: String, val iDevice: IDevice)
class DeviceInformation(var name: String, val iDevice: IDevice)

fun IDevice.toDeviceInformation(): DeviceInformation {
val deviceInformation = DeviceInformation(title = "Unknow", brand = "", model = "", iDevice = this)
val deviceInformation = DeviceInformation(name = "Unknow", iDevice = this)

var brand = ""
var model = ""
val title: String

if (this.isEmulator) {
brand = this.avdName?.replace("_", " ").orEmpty().trim().toUpperCaseAsciiOnly()
model = ""
title = "$brand [${this.serialNumber}]"
val name = if (this.isEmulator) {
this.name?.replace("_", " ").toString()
} else {
brand = deviceInformation.iDevice.getProperty("ro.product.brand").trim().toUpperCaseAsciiOnly()
model = deviceInformation.iDevice.getProperty("ro.product.model").trim().toUpperCaseAsciiOnly()
title = "$brand $model [${this.serialNumber}]"
val brand = deviceInformation.iDevice.getProperty("ro.product.brand").trim().toUpperCaseAsciiOnly()
val model = deviceInformation.iDevice.getProperty("ro.product.model").trim().toUpperCaseAsciiOnly()
"$brand $model [${this.serialNumber}]"
}
deviceInformation.title = title
deviceInformation.brand = brand
deviceInformation.model = model
deviceInformation.name = name

return deviceInformation
}
20 changes: 20 additions & 0 deletions src/main/kotlin/androidstudio/tools/missed/utils/DisabledIcon.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package androidstudio.tools.missed.utils

import java.awt.AlphaComposite
import java.awt.Component
import java.awt.Graphics
import java.awt.Graphics2D
import javax.swing.Icon

class DisabledIcon(private val originalIcon: Icon, private val transparency: Float = 0.2f) : Icon {
override fun paintIcon(c: Component, g: Graphics, x: Int, y: Int) {
val g2d = g.create() as Graphics2D
g2d.composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transparency)
originalIcon.paintIcon(c, g2d, x, y)
g2d.dispose()
}

override fun getIconWidth() = originalIcon.iconWidth

override fun getIconHeight() = originalIcon.iconHeight
}
Loading

0 comments on commit f1d9edd

Please sign in to comment.