Skip to content

Commit f1d9edd

Browse files
rasoulmiriRasoul Miri
and
Rasoul Miri
authored
version 1.0.1 (#3)
* 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 <[email protected]>
1 parent b41bd01 commit f1d9edd

File tree

21 files changed

+150
-73
lines changed

21 files changed

+150
-73
lines changed

build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import java.util.*
33
plugins {
44
id("java")
55
id("org.jetbrains.kotlin.jvm") version "1.8.21"
6-
id("org.jetbrains.intellij") version "1.13.3"
6+
id("org.jetbrains.intellij") version "1.15.0"
77
id("io.gitlab.arturbosch.detekt") version "1.22.0"
88
}
99

1010
group = "com.androidstudiotoolsmissed"
11-
version = "1.0-SNAPSHOT"
11+
version = "1.0.1-SNAPSHOT"
1212

1313
repositories {
1414
mavenCentral()
@@ -83,7 +83,7 @@ tasks {
8383
intelliJTokenFile.inputStream().use { inputStream ->
8484
properties.load(inputStream)
8585
}
86-
val intelliJToken: String = properties.getProperty("password").trim()
86+
val intelliJToken: String = properties.getProperty("token").trim()
8787
token.set(System.getenv(intelliJToken))
8888
}
8989
}

src/main/kotlin/androidstudio/tools/missed/features/ErrorView.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package androidstudio.tools.missed.features
22

33
import androidstudio.tools.missed.manager.resource.ResourceManager
4+
import androidstudio.tools.missed.utils.DELAY_MEDIUM
5+
import androidstudio.tools.missed.utils.DisabledIcon
46
import com.intellij.icons.AllIcons
57
import com.intellij.openapi.ui.VerticalFlowLayout
68
import com.intellij.ui.AnimatedIcon
@@ -18,7 +20,11 @@ class ErrorView(private val resourceManager: ResourceManager, private val onRetr
1820
// label
1921
val descriptionLabel = JLabel(
2022
resourceManager.string("InitialPluginError"),
21-
AnimatedIcon.Blinking(AllIcons.General.BalloonError),
23+
AnimatedIcon(
24+
DELAY_MEDIUM.toInt(),
25+
AllIcons.General.BalloonError,
26+
DisabledIcon(AllIcons.General.BalloonError)
27+
),
2228
SwingConstants.CENTER
2329
)
2430
panel.add(descriptionLabel)

src/main/kotlin/androidstudio/tools/missed/features/NeedToConnectDeviceView.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package androidstudio.tools.missed.features
22

33
import androidstudio.tools.missed.manager.resource.ResourceManager
4+
import androidstudio.tools.missed.utils.DELAY_MEDIUM
5+
import androidstudio.tools.missed.utils.DisabledIcon
46
import com.intellij.icons.AllIcons
57
import com.intellij.openapi.ui.VerticalFlowLayout
68
import com.intellij.openapi.util.IconLoader
@@ -20,9 +22,14 @@ class NeedToConnectDeviceView(
2022
val panel = JPanel(VerticalFlowLayout(VerticalFlowLayout.CENTER, true, false))
2123

2224
// label
25+
val androidDeviceIcon = IconLoader.getIcon("/icons/androidDevice/androidDevice.svg", javaClass)
2326
val descriptionLabel = JLabel(
2427
resourceManager.string("needToConnectDeviceDescription"),
25-
AnimatedIcon.Blinking(IconLoader.getIcon("/icons/androidDevice/androidDevice.svg", javaClass)),
28+
AnimatedIcon(
29+
DELAY_MEDIUM.toInt(),
30+
androidDeviceIcon,
31+
DisabledIcon(androidDeviceIcon)
32+
),
2633
SwingConstants.CENTER
2734
)
2835
panel.add(descriptionLabel)

src/main/kotlin/androidstudio/tools/missed/features/apk/presenter/ApkView.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class ApkView(
5252
group(resourceManager.string("downloadApkTitle")) {
5353
row {
5454
label(resourceManager.string("apkTitle")).gap(RightGap.SMALL)
55-
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools")
55+
browserLink(
56+
resourceManager.string("help"),
57+
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools"
58+
)
5659
}
5760

5861
row {
@@ -95,7 +98,10 @@ class ApkView(
9598
group(resourceManager.string("installApkTitle")) {
9699
row {
97100
label(resourceManager.string("installApplicationFromApkFiles")).gap(RightGap.SMALL)
98-
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools")
101+
browserLink(
102+
resourceManager.string("help"),
103+
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/APK-Tools"
104+
)
99105
}
100106

101107
row {

src/main/kotlin/androidstudio/tools/missed/features/battery/presenter/BatteryView.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package androidstudio.tools.missed.features.battery.presenter
33
import androidstudio.tools.missed.base.CollapsibleGroupView
44
import androidstudio.tools.missed.manager.notification.NotificationManager
55
import androidstudio.tools.missed.manager.resource.ResourceManager
6+
import androidstudio.tools.missed.utils.DIMENSION_3
67
import androidstudio.tools.missed.utils.debounce
78
import com.intellij.ui.JBIntSpinner
89
import com.intellij.ui.components.OnOffButton
@@ -13,6 +14,7 @@ import com.intellij.ui.dsl.builder.panel
1314
import kotlinx.coroutines.flow.collect
1415
import kotlinx.coroutines.flow.collectLatest
1516
import kotlinx.coroutines.launch
17+
import java.awt.Dimension
1618
import java.awt.event.ItemEvent
1719
import java.awt.event.ItemListener
1820
import javax.swing.JEditorPane
@@ -69,8 +71,7 @@ class BatteryView(
6971
init {
7072
setContent(
7173
title = resourceManager.string("batteryTitle"),
72-
batteryDetailView(),
73-
powerSavingModeView()
74+
batteryDetailView()
7475
)
7576
}
7677

@@ -85,6 +86,9 @@ class BatteryView(
8586
row {
8687
cell(chargerConnectionLabel).gap(RightGap.SMALL)
8788
chargerConnectionComment = comment("")
89+
chargerConnectionComment.component.apply {
90+
preferredSize = Dimension(DIMENSION_3, chargerConnectionLabel.preferredSize.height)
91+
}
8892
cell(chargerConnectionButton).gap(RightGap.COLUMNS)
8993
chargerConnectionButton.addItemListener(chargerConnectionButtonItemListener)
9094
}.layout(RowLayout.PARENT_GRID)
@@ -96,23 +100,19 @@ class BatteryView(
96100
batteryLevelSpinner.addChangeListener(batteryLevelSpinnerChangeListener)
97101
cell(batteryLevelSpinner)
98102
}.layout(RowLayout.PARENT_GRID)
99-
}
100-
}
101103

102-
private fun powerSavingModeView(): JPanel {
103-
return panel {
104-
row {
105-
cell(powerSavingModeLabel).gap(RightGap.SMALL)
106-
powerSavingModeComment = comment("")
107-
cell(powerSavingModeButton)
108-
powerSavingModeButton.addItemListener(powerSavingModeButtonItemListener)
109-
}
104+
row {
105+
cell(powerSavingModeLabel).gap(RightGap.SMALL)
106+
powerSavingModeComment = comment("").widthGroup("GroupName")
107+
cell(powerSavingModeButton)
108+
powerSavingModeButton.addItemListener(powerSavingModeButtonItemListener)
109+
}.layout(RowLayout.PARENT_GRID)
110110

111-
row {
112-
button(resourceManager.string("resetBatterySetting")) {
113-
viewModel.resetBatterySetting()
114-
}
111+
row {
112+
button(resourceManager.string("resetBatterySetting")) {
113+
viewModel.resetBatterySetting()
115114
}
115+
}.layout(RowLayout.PARENT_GRID)
116116
}
117117
}
118118

src/main/kotlin/androidstudio/tools/missed/features/deviceAndpackageid/presenter/model/DevicesComboBoxRenderer.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ internal class DevicesComboBoxRenderer(private val placeHolder: String) : JLabel
1818
text = if (index == -1 && value == null) {
1919
placeHolder
2020
} else {
21-
if ((value as? DeviceInformation)?.title != null) {
22-
(value as? DeviceInformation)?.title
21+
if ((value as? DeviceInformation)?.name != null) {
22+
(value as? DeviceInformation)?.name
2323
} else {
2424
value.toString()
2525
}

src/main/kotlin/androidstudio/tools/missed/features/dozeandstandby/presenter/DozeAndStandbyView.kt

+13-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ class DozeAndStandbyView(
7878
group(resourceManager.string("doze")) {
7979
row {
8080
label(resourceManager.string("dozeDescription")).gap(RightGap.SMALL)
81-
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze")
81+
browserLink(
82+
resourceManager.string("help"),
83+
"https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze"
84+
)
8285
}
8386

8487
row {
@@ -102,7 +105,11 @@ class DozeAndStandbyView(
102105
group(resourceManager.string("standby")) {
103106
row {
104107
label(resourceManager.string("standbyDescription")).gap(RightGap.SMALL)
105-
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby#understand_app_standby")
108+
browserLink(
109+
resourceManager.string("help"),
110+
"https://developer.android.com/" +
111+
"training/monitoring-device-state/doze-standby#understand_app_standby"
112+
)
106113
}
107114

108115
row {
@@ -124,7 +131,10 @@ class DozeAndStandbyView(
124131
group(resourceManager.string("whiteListTitle")) {
125132
row {
126133
label(resourceManager.string("whiteListDescription")).gap(RightGap.SMALL)
127-
browserLink(resourceManager.string("help"), "https://developer.android.com/training/monitoring-device-state/doze-standby")
134+
browserLink(
135+
resourceManager.string("help"),
136+
"https://developer.android.com/training/monitoring-device-state/doze-standby"
137+
)
128138
}
129139

130140
row {

src/main/kotlin/androidstudio/tools/missed/features/input/presenter/InputTextView.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ class InputTextView(
5353
return panel {
5454
row {
5555
text(resourceManager.string("inputTextDescription")).gap(RightGap.SMALL)
56-
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Input-Tools")
56+
browserLink(
57+
resourceManager.string("help"),
58+
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Input-Tools"
59+
)
5760
}
5861

5962
row {

src/main/kotlin/androidstudio/tools/missed/features/permission/presenter/PermissionView.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class PermissionView(
6666
group(resourceManager.string("permissionsSingleTitle")) {
6767
row {
6868
label(resourceManager.string("permissionsSingleDescription")).gap(RightGap.SMALL)
69-
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools")
69+
browserLink(
70+
resourceManager.string("help"),
71+
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools"
72+
)
7073
}
7174

7275
row {
@@ -125,7 +128,10 @@ class PermissionView(
125128
group(resourceManager.string("permissionsAllTitle")) {
126129
row {
127130
label(resourceManager.string("permissionsAllDescription")).gap(RightGap.SMALL)
128-
browserLink(resourceManager.string("help"), "https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools")
131+
browserLink(
132+
resourceManager.string("help"),
133+
"https://github.com/rasoulmiri/AndroidStudioToolsMissed/wiki/Permissions-Tools"
134+
)
129135
}
130136
row {
131137
grantAllButton = button(resourceManager.string("grantAllPermissions")) {
@@ -136,7 +142,7 @@ class PermissionView(
136142
}
137143
}
138144
}.component.apply {
139-
preferredSize = Dimension(DIMENSION_6, preferredSize.height) // Set your preferred button size
145+
preferredSize = Dimension(DIMENSION_6, preferredSize.height)
140146
}
141147

142148
restartApplicationGrantCheckBox = checkBox(resourceManager.string("restartApplication")).component
@@ -152,7 +158,7 @@ class PermissionView(
152158
}
153159
}
154160
}.component.apply {
155-
preferredSize = Dimension(DIMENSION_6, preferredSize.height) // Set your preferred button size
161+
preferredSize = Dimension(DIMENSION_6, preferredSize.height)
156162
}
157163
restartApplicationRevokeCheckBox = checkBox(resourceManager.string("restartApplication")).component
158164
restartApplicationRevokeCheckBox.toolTipText = resourceManager.string("revokeAllPermissionsHint")

src/main/kotlin/androidstudio/tools/missed/manager/adb/di/AdbManagerModule.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import androidstudio.tools.missed.manager.adb.logger.AdbLogger
66
import androidstudio.tools.missed.manager.adb.logger.AdbLoggerImpl
77
import com.android.ddmlib.AndroidDebugBridge
88
import org.koin.dsl.module
9+
import java.util.concurrent.TimeUnit
910

11+
@Suppress("MagicNumber")
1012
val adbManagerModule = module {
11-
single<AndroidDebugBridge> { AndroidDebugBridge.createBridge() }
13+
single<AndroidDebugBridge> { AndroidDebugBridge.createBridge(10, TimeUnit.SECONDS) }
1214
single<AdbLogger> { AdbLoggerImpl() }
1315
single<AdbManager> { AdbManagerImpl(get(), get(), get()) }
1416
}

src/main/kotlin/androidstudio/tools/missed/manager/adb/logger/AdbLoggerImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class AdbLoggerImpl : AdbLogger {
1515
println(
1616
"\nExecuteShellCommand ____________________________________________________________________________" +
1717
"\nDevice = ${
18-
if (device?.title == "Unknow") {
18+
if (device?.name == "Unknow") {
1919
device.iDevice.serialNumber
2020
} else {
21-
device?.title?.replace("\n", "")
21+
device?.name?.replace("\n", "")
2222
}
2323
}\nCommandName = ${adbCommand::class.java.simpleName}\n ${adbCommand.command} \nResult = ${
2424
message.ifEmpty {

src/main/kotlin/androidstudio/tools/missed/manager/device/DeviceManager.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ interface DeviceManager {
1717
suspend fun pullFile(remoteFilepath: String, localFilePath: String): Result<String>
1818
suspend fun setSelectedDevice(device: DeviceInformation?)
1919
suspend fun setSelectedPackageId(packageId: String?)
20-
fun getDeviceSelectedName(): String
20+
fun getDeviceSelectedName(): String?
2121
}

src/main/kotlin/androidstudio/tools/missed/manager/device/DeviceManagerImpl.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class DeviceManagerImpl(
8282
_packageIdSelectedStateFlow.emit(null)
8383
}
8484

85-
override fun getDeviceSelectedName(): String =
86-
"${_selectedDeviceStateFlow.value?.brand} ${_selectedDeviceStateFlow.value?.model}"
85+
override fun getDeviceSelectedName(): String? = _selectedDeviceStateFlow.value?.name
8786

8887
override suspend fun executeShellCommand(adbCommand: AdbCommand): Result<String> {
8988
if (adbCommand.isNeedDevice && (_selectedDeviceStateFlow.value == null || _devicesStateFlow.value.isEmpty())) {

src/main/kotlin/androidstudio/tools/missed/manager/device/model/DeviceInformation.kt

+8-16
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,19 @@ package androidstudio.tools.missed.manager.device.model
33
import com.android.ddmlib.IDevice
44
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
55

6-
class DeviceInformation(var title: String, var brand: String, var model: String, val iDevice: IDevice)
6+
class DeviceInformation(var name: String, val iDevice: IDevice)
77

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

11-
var brand = ""
12-
var model = ""
13-
val title: String
14-
15-
if (this.isEmulator) {
16-
brand = this.avdName?.replace("_", " ").orEmpty().trim().toUpperCaseAsciiOnly()
17-
model = ""
18-
title = "$brand [${this.serialNumber}]"
11+
val name = if (this.isEmulator) {
12+
this.name?.replace("_", " ").toString()
1913
} else {
20-
brand = deviceInformation.iDevice.getProperty("ro.product.brand").trim().toUpperCaseAsciiOnly()
21-
model = deviceInformation.iDevice.getProperty("ro.product.model").trim().toUpperCaseAsciiOnly()
22-
title = "$brand $model [${this.serialNumber}]"
14+
val brand = deviceInformation.iDevice.getProperty("ro.product.brand").trim().toUpperCaseAsciiOnly()
15+
val model = deviceInformation.iDevice.getProperty("ro.product.model").trim().toUpperCaseAsciiOnly()
16+
"$brand $model [${this.serialNumber}]"
2317
}
24-
deviceInformation.title = title
25-
deviceInformation.brand = brand
26-
deviceInformation.model = model
18+
deviceInformation.name = name
2719

2820
return deviceInformation
2921
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package androidstudio.tools.missed.utils
2+
3+
import java.awt.AlphaComposite
4+
import java.awt.Component
5+
import java.awt.Graphics
6+
import java.awt.Graphics2D
7+
import javax.swing.Icon
8+
9+
class DisabledIcon(private val originalIcon: Icon, private val transparency: Float = 0.2f) : Icon {
10+
override fun paintIcon(c: Component, g: Graphics, x: Int, y: Int) {
11+
val g2d = g.create() as Graphics2D
12+
g2d.composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transparency)
13+
originalIcon.paintIcon(c, g2d, x, y)
14+
g2d.dispose()
15+
}
16+
17+
override fun getIconWidth() = originalIcon.iconWidth
18+
19+
override fun getIconHeight() = originalIcon.iconHeight
20+
}

0 commit comments

Comments
 (0)