Flipper Zero: added duration to Intent API

This commit is contained in:
Daniel Dakhno 2022-09-09 04:54:10 +02:00
parent a5ed37ab79
commit 570670fb28

View File

@ -58,8 +58,10 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
return; return;
} }
long millis = intent.getExtras().getInt("EXTRA_DURATION", 1000);
GB.toast(String.format("playing %s file", appName), Toast.LENGTH_SHORT, GB.INFO); GB.toast(String.format("playing %s file", appName), Toast.LENGTH_SHORT, GB.INFO);
playFile(appName, filePath); playFile(appName, filePath, millis);
Intent response = new Intent(ACTION_PLAY_DONE); Intent response = new Intent(ACTION_PLAY_DONE);
getContext().sendBroadcast(response); getContext().sendBroadcast(response);
@ -184,14 +186,14 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
openApp("Infrared"); openApp("Infrared");
} }
private void playFile(String appName, String filePath){ private void playFile(String appName, String filePath, long durationMillis){
openApp(appName); openApp(appName);
try { try {
Thread.sleep(500); Thread.sleep(1000);
appLoadFile(filePath); appLoadFile(filePath);
Thread.sleep(500); Thread.sleep(1000);
appButtonPress(); appButtonPress();
Thread.sleep(500); Thread.sleep(durationMillis);
appButtonRelease(); appButtonRelease();
Thread.sleep(1000); Thread.sleep(1000);
appExitRequest(); appExitRequest();