Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1055049 - merge pull request #30001 from dominickuo:bug-1055049 t…
Browse files Browse the repository at this point in the history
…o mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed May 28, 2015
2 parents 21f22a8 + cffd5fe commit 87ad265
Show file tree
Hide file tree
Showing 30 changed files with 887 additions and 474 deletions.
73 changes: 44 additions & 29 deletions apps/music/index.html
Expand Up @@ -28,9 +28,6 @@
<script defer src="shared/js/accessibility_helper.js"></script>
<script defer src="shared/js/async_storage.js"></script>
<script defer src="shared/js/image_utils.js"></script>
<script defer src="shared/js/text_normalizer.js"></script>
<script defer src="shared/js/bluetooth_helper.js"></script>
<script defer src="shared/js/media/remote_controls.js"></script>
<script defer src="shared/js/omadrm/fl.js"></script>
<!-- Web components -->
<script defer src="shared/js/component_utils.js"></script>
Expand All @@ -43,11 +40,18 @@
<script defer src="js/ui/title_bar.js"></script>
<script defer src="js/ui/tab_bar.js"></script>
<script defer src="js/ui/views/mode_manager.js"></script>
<!-- Lazy load code -->
<!--
<script defer src="shared/js/text_normalizer.js"></script>
<script defer src="shared/js/bluetooth_helper.js"></script>
<script defer src="shared/js/media/remote_controls.js"></script>
<script defer src="js/metadata/*.js"></script>
<script defer src="js/communications.js"></script>
<script defer src="js/ui/views/tiles_view.js"></script>
<script defer src="js/ui/views/list_view.js"></script>
<script defer src="js/ui/views/subList_view.js"></script>
<script defer src="js/ui/views/search_view.js"></script>
<script defer src="js/communications.js"></script>
-->
</head>

<body role="application" class="theme-media">
Expand Down Expand Up @@ -131,31 +135,42 @@ <h1 id="title-text"><bdi data-l10n-id="music"></bdi></h1>
</div>
<audio id="player-audio" class="hidden"></audio>
</div>
</div>
<div id="search" class="hidden">
<div id="views-search-no-result" class="search-category hidden">
<p id="search-no-result" data-l10n-id="search-no-result">No musiC founD</p>
</div>
<div id="views-search-artists" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-artists">ArtistS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
</div>
<div id="views-search-albums" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-albums">AlbumS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
</div>
<div id="views-search-titles" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-titles">TrackS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
<div id="views-search" class="view hidden">
<form id="views-search-form" role="search" class="skin-dark">
<button id="views-search-close" data-l10n-id="search-close" type="submit">close</button>
<p>
<input id="views-search-input" type="search" dir="auto"
x-inputmode="verbatim"
data-l10n-id="search-music" placeholder="SearcH MusiC">
<button id="views-search-clear" type="reset">Clear</button>
</p>
</form>
<div id="views-search-no-result" class="search-category hidden">
<p id="search-no-result" data-l10n-id="search-no-result">No musiC founD</p>
</div>
<div id="views-search-anchor">
<div id="views-search-artists" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-artists">ArtistS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
</div>
<div id="views-search-albums" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-albums">AlbumS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
</div>
<div id="views-search-titles" class="search-category hidden">
<gaia-subheader skin="dark">
<span data-l10n-id="search-titles">TrackS</span>
(<span class="search-result-count"></span>)
</gaia-subheader>
<div class="search-results" role="listbox"></div>
</div>
</div>
</div>
</div>
<!-- BB tabs -->
Expand Down
27 changes: 8 additions & 19 deletions apps/music/js/communications.js
@@ -1,5 +1,5 @@
/* exported MusicComms */
/* global App, musicdb, LazyLoader, ModeManager, MODE_PLAYER, PlayerView,
/* global musicdb, ModeManager, MODE_PLAYER, PlayerView,
PLAYSTATUS_PLAYING, PLAYSTATUS_STOPPED, INTERRUPT_BEGIN, TYPE_MIX,
MediaRemoteControls */
'use strict';
Expand Down Expand Up @@ -32,16 +32,14 @@ var MusicComms = {
}
} else {
// Play in shuffle order if music app is launched remotely.
// Please note bug 855208, if music app is launched via system message
// in background, the audio channel will be paused.
if (PlayerView.playStatus === PLAYSTATUS_STOPPED) {
musicdb.getAll(function remote_getAll(dataArray) {
PlayerView.setSourceType(TYPE_MIX);
PlayerView.dataSource = dataArray;
PlayerView.setShuffle(true);
PlayerView.play(PlayerView.shuffledList[0]);

ModeManager.push(MODE_PLAYER);
ModeManager.push(MODE_PLAYER, function() {
PlayerView.setSourceType(TYPE_MIX);
PlayerView.dataSource = dataArray;
PlayerView.setShuffle(true);
PlayerView.play(PlayerView.shuffledList[0]);
});
});
} else if (PlayerView.playStatus === PLAYSTATUS_PLAYING) {
PlayerView.pause();
Expand Down Expand Up @@ -157,16 +155,7 @@ var MusicComms = {
},

_getPlayerReady: function(callback) {
if (typeof PlayerView === 'undefined') {
LazyLoader.load('js/ui/views/player_view.js', function() {
PlayerView.init();
PlayerView.setOptions(App.playerSettings);

callback();
});
} else {
callback();
}
ModeManager.initView(ModeManager.views[MODE_PLAYER], callback);
},

_isPlayerActivated: function() {
Expand Down
5 changes: 3 additions & 2 deletions apps/music/js/db.js
Expand Up @@ -107,8 +107,9 @@ function initDB() {
// TabBar should be set to "mix" to sync with the tab selection.
if (!App.pendingPick) {
TabBar.option = 'mix';
ModeManager.start(MODE_TILES);
TilesView.hideSearch();
ModeManager.start(MODE_TILES, function() {
TilesView.hideSearch();
});
}
}

Expand Down
50 changes: 25 additions & 25 deletions apps/music/js/music.js
@@ -1,16 +1,13 @@
/* exported App */
/* global initDB, MusicComms, TitleBar, TabBar, asyncStorage, TilesView,
ListView, SubListView, SearchView, ModeManager, MODE_PICKER,
MODE_TILES, MODE_LIST, reparsingMetadata */
/* global initDB, MusicComms, TitleBar, TabBar, TilesView,
ListView, ModeManager, MODE_PICKER, MODE_TILES, MODE_LIST,
reparsingMetadata, LazyLoader */
'use strict';

/*
* This is Music Application of Gaia
*/

// Key for store the player options of repeat and shuffle
var SETTINGS_OPTION_KEY = 'settings_option_key';

var App = (function() {
var app;
var chromeInteractive = false;
Expand All @@ -25,10 +22,6 @@ var App = (function() {
initDB();

TitleBar.init();
TilesView.init();
ListView.init();
SubListView.init();
SearchView.init();
TabBar.init();

setStartMode();
Expand All @@ -54,26 +47,21 @@ var App = (function() {
var activityName = a.source.name;

if (activityName === 'pick') {
// Display the correct ui for the pick activity.
document.body.classList.add('picker-mode');
app.pendingPick = a;
}
});

TabBar.option = 'title';
ModeManager.start(MODE_PICKER);
} else {
TabBar.option = 'mix';
ModeManager.start(MODE_TILES);

// The player options will be used later,
// so let's get them first before the player is loaded.
asyncStorage.getItem(SETTINGS_OPTION_KEY, function(settings) {
app.playerSettings = settings;
TabBar.option = 'title';
ModeManager.start(MODE_PICKER);
});

} else {
// The done button must be removed when we are not in picker mode
// because the rules of the header building blocks
var doneButton = document.getElementById('title-done');
doneButton.parentNode.removeChild(doneButton);
TitleBar.doneButton.parentNode.removeChild(TitleBar.doneButton);

TabBar.option = 'mix';
ModeManager.start(MODE_TILES);
}
}

Expand Down Expand Up @@ -182,7 +170,7 @@ var App = (function() {
if (document.URL.indexOf('#pick') === -1) {
// We need to wait to init the music comms until the UI is fully loaded
// because the init of music comms could slow down the startup time.
MusicComms.init();
setupCommunications();
}

if (callback) {
Expand All @@ -191,6 +179,18 @@ var App = (function() {
});
}

function setupCommunications() {
var files = [
'shared/js/bluetooth_helper.js',
'shared/js/media/remote_controls.js',
'js/communications.js',
];

LazyLoader.load(files, function() {
MusicComms.init();
});
}

function dbReady(refresh, callback) {
// Hide the nocard or pluggedin overlay if it is displayed
if (app.currentOverlay === 'nocard' || app.currentOverlay === 'pluggedin') {
Expand Down
32 changes: 10 additions & 22 deletions apps/music/js/ui/tab_bar.js
@@ -1,5 +1,5 @@
/* exported TabBar */
/* global AccessibilityHelper, ListView, TilesView, SearchView,
/* global AccessibilityHelper, ListView, TilesView,
MODE_TILES, MODE_LIST, ModeManager */
'use strict';

Expand Down Expand Up @@ -79,19 +79,17 @@ var TabBar = {

ModeManager.start(MODE_TILES);
TilesView.hideSearch();
SearchView.searchContext = SearchView.context.ALL;

break;
case 'tabs-playlists':
ModeManager.start(MODE_LIST);
ListView.activate();
ModeManager.start(MODE_LIST, function() {
ListView.activate();

this.playlistArray.forEach(function(playlist) {
ListView.update(this.option, playlist);
this.playlistArray.forEach(function(playlist) {
ListView.update(this.option, playlist);
}.bind(this));
}.bind(this));

SearchView.searchContext = SearchView.context.ALL;

break;
case 'tabs-artists':
case 'tabs-albums':
Expand All @@ -103,20 +101,10 @@ var TabBar = {
option: this.option
};

ModeManager.start(MODE_LIST);
ListView.activate(info);

switch (target.id) {
case 'tabs-artists':
SearchView.searchContext = SearchView.context.ARTISTS;
break;
case 'tabs-albums':
SearchView.searchContext = SearchView.context.ALBUMS;
break;
case 'tabs-songs':
SearchView.searchContext = SearchView.context.SONGS;
break;
}
ModeManager.start(MODE_LIST, function() {
ListView.activate(info);
});

break;
}

Expand Down
4 changes: 4 additions & 0 deletions apps/music/js/ui/title_bar.js
Expand Up @@ -16,6 +16,10 @@ var TitleBar = {
return document.getElementById('title-player');
},

get doneButton() {
return document.getElementById('title-done');
},

get scanProgress() {
return document.getElementById('scan-progress');
},
Expand Down

0 comments on commit 87ad265

Please sign in to comment.