Skip to content

Commit c53e1a1

Browse files
authored
add volume drawer (#521)
1 parent 54e2ffb commit c53e1a1

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android.defaults.buildfeatures.buildconfig=true
2525
android.nonFinalResIds=false
2626

2727
GROUP=com.robotemi
28-
VERSION_NAME=1.137.0.8-SNAPSHOT
28+
VERSION_NAME=1.137.0.9-SNAPSHOT
2929
POM_URL=https://github.com/robotemi/sdk/
3030
POM_SCM_URL=https://github.com/robotemi/sdk/
3131
POM_SCM_CONNECTION=scm:git:git://github.com/robotemi/sdk.git

sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,11 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener,
19051905
dialog.listView.onItemClickListener =
19061906
OnItemClickListener { _: AdapterView<*>?, _: View?, position: Int, _: Long ->
19071907
robot.volume = adapter.getItem(position)!!.toInt()
1908+
1909+
// robot.setVolume(adapter.getItem(position)!!.toInt())
1910+
1911+
// robot.setVolume(adapter.getItem(position)!!.toInt(),true)
1912+
19081913
printLog("Set volume to ${adapter.getItem(position)}")
19091914
dialog.dismiss()
19101915
}

sdk/src/main/aidl/com/robotemi/sdk/ISdkService.aidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ interface ISdkService {
229229

230230
boolean isAutoReturnOn();
231231

232-
void setVolume(in String packageName, int volume);
232+
void setVolume(in String packageName, int volume, boolean showDrawer);
233233

234234
int getVolume();
235235

sdk/src/main/java/com/robotemi/sdk/Robot.kt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,7 @@ class Robot private constructor(private val context: Context) {
23292329
}
23302330
}
23312331

2332+
23322333
/**
23332334
* Volume of Launcher OS.
23342335
*/
@@ -2353,12 +2354,36 @@ class Robot private constructor(private val context: Context) {
23532354
volume > 10 -> 10
23542355
else -> volume
23552356
}
2356-
sdkService?.setVolume(applicationInfo.packageName, validVolume)
2357+
setVolume(validVolume, showDrawer = false)
23572358
} catch (e: RemoteException) {
23582359
Log.e(TAG, "setVolume() error")
23592360
}
23602361
}
23612362

2363+
/**
2364+
* Sets the volume value, with optional control over whether to show the drawer
2365+
*
2366+
* @param volume The volume value to be set (automatically clamped between 0-10)
2367+
* @param showDrawer Whether to display the drawer, default is false
2368+
*
2369+
* Examples:
2370+
* - Set volume only (drawer hidden by default): setVolume(5)
2371+
* - Set volume and show drawer: setVolume(5, showDrawer = true)
2372+
*
2373+
*/
2374+
fun setVolume(volume: Int, showDrawer: Boolean = false) {
2375+
try {
2376+
val validVolume = when {
2377+
volume < 0 -> 0
2378+
volume > 10 -> 10
2379+
else -> volume
2380+
}
2381+
sdkService?.setVolume(applicationInfo.packageName, validVolume, showDrawer)
2382+
} catch (e: RemoteException) {
2383+
Log.e(TAG, "setVolume() error")
2384+
}
2385+
}
2386+
23622387
/**
23632388
* Set microphone gain level to X1(default)-X4. Added in 133 version
23642389
*

0 commit comments

Comments
 (0)