Files
SubMusic/source/SubMusicApp.mc
Memen 1f3fba2289 fixed settings storage having 0 Bytes
fixed some rare crashes on receiving invalid response
added setting to enable debug logging
removed default debug output (speed improvement)
2023-02-20 15:42:22 +01:00

93 lines
2.7 KiB
MonkeyC

using Toybox.Application;
using Toybox.WatchUi;
using SubMusic.Menu;
using SubMusic.Storage;
var debug = false;
class SubMusicApp extends Application.AudioContentProviderApp {
function initialize() {
AudioContentProviderApp.initialize();
// update debug status
$.debug = Application.Properties.getValue("debug");
if ($.debug) {
System.println("SubMusicApp::initialize()");
}
// in case variables need to be reset
// Application.Storage.clearValues();
// perform storage check and fix if possible
Storage.check();
}
// onStart() is called on application start up
function onStart(state) {
if ($.debug) {
System.println("Start with state: " + state);
}
}
// onStop() is called when your application is exiting
function onStop(state) {
if ($.debug) {
System.println("Stop with state: " + state);
}
}
function onSettingsChanged() {
if ($.debug) {
System.println("Settings changed");
}
// reset the sessions for the provider
SubMusic.Provider.onSettingsChanged();
// reload the media profile
Media.requestPlaybackProfileUpdate();
}
// Get a Media.ContentDelegate for use by the system to get and iterate through media on the device
function getContentDelegate(arg) {
if ($.debug) {
System.println("getContentDelegate with arg: " + arg);
}
return new SubMusicContentDelegate();
}
// Get a delegate that communicates sync status to the system for syncing media content to the device
function getSyncDelegate() {
var syncrequest = Application.Storage.getValue(Storage.SYNC_REQUEST);
if ($.debug) {
System.println("SubMusicApp syncrequest " + syncrequest);
}
// return deprecated if sync was not started from the menu (i.e. autostart)
if (syncrequest != true) {
return new SubMusic.SyncDelegate_deprecated();
}
return new SubMusic.SyncDelegate();
}
// Get the initial view for configuring playback
function getPlaybackConfigurationView() {
var menu = new Menu.Playback();
menu.load(); // menu needs to be loaded when MenuLoader is not used
return [ new Menu.MenuView(menu), menu.delegate() ];
}
// Get the initial view for configuring sync
function getSyncConfigurationView() {
var menu = new Menu.Sync();
menu.load(); // menu needs to be loaded when MenuLoader is not used
return [ new SubMusic.Menu.MenuView(menu), menu.delegate() ];
}
function popView() {
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
}
}