Commit eb1c8c3c authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Files app: Remember "Show all Play folders" option.

When "Show all Play folders" is toggled, we make modification on FileFilter
instance which filter visible folders/files.
FileFilter dispatches 'changed' event, and we can remember the current option
on the event handler.

Bug: 863200
Test: Manually tested on ARC-enabled devices.
Change-Id: I517cabfea04e1c17e2e2a844fb2ca35c4becb648
Reviewed-on: https://chromium-review.googlesource.com/1143101Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576421}
parent 8f064215
...@@ -42,7 +42,7 @@ function AppStateController(dialogType) { ...@@ -42,7 +42,7 @@ function AppStateController(dialogType) {
* @private {string} * @private {string}
*/ */
this.fileListSortDirection_ = AppStateController.DEFAULT_SORT_DIRECTION; this.fileListSortDirection_ = AppStateController.DEFAULT_SORT_DIRECTION;
}; }
/** /**
* Default sort field of the file list. * Default sort field of the file list.
...@@ -109,6 +109,8 @@ AppStateController.prototype.initialize = function(ui, directoryModel) { ...@@ -109,6 +109,8 @@ AppStateController.prototype.initialize = function(ui, directoryModel) {
'column-resize-end', this.saveViewOptions.bind(this)); 'column-resize-end', this.saveViewOptions.bind(this));
directoryModel.getFileList().addEventListener( directoryModel.getFileList().addEventListener(
'sorted', this.onFileListSorted_.bind(this)); 'sorted', this.onFileListSorted_.bind(this));
directoryModel.getFileFilter().addEventListener(
'changed', this.onFileFilterChanged_.bind(this));
directoryModel.addEventListener( directoryModel.addEventListener(
'directory-changed', this.onDirectoryChanged_.bind(this)); 'directory-changed', this.onDirectoryChanged_.bind(this));
...@@ -121,6 +123,8 @@ AppStateController.prototype.initialize = function(ui, directoryModel) { ...@@ -121,6 +123,8 @@ AppStateController.prototype.initialize = function(ui, directoryModel) {
this.fileListSortDirection_ = this.viewOptions_.sortDirection; this.fileListSortDirection_ = this.viewOptions_.sortDirection;
this.directoryModel_.getFileList().sort( this.directoryModel_.getFileList().sort(
this.fileListSortField_, this.fileListSortDirection_); this.fileListSortField_, this.fileListSortDirection_);
if (this.viewOptions_.isAllAndroidFoldersVisible)
this.directoryModel_.getFileFilter().setAllAndroidFoldersVisible(true);
if (this.viewOptions_.columnConfig) { if (this.viewOptions_.columnConfig) {
this.ui_.listContainer.table.columnModel.restoreColumnConfig( this.ui_.listContainer.table.columnModel.restoreColumnConfig(
this.viewOptions_.columnConfig); this.viewOptions_.columnConfig);
...@@ -136,6 +140,8 @@ AppStateController.prototype.saveViewOptions = function() { ...@@ -136,6 +140,8 @@ AppStateController.prototype.saveViewOptions = function() {
sortDirection: this.fileListSortDirection_, sortDirection: this.fileListSortDirection_,
columnConfig: {}, columnConfig: {},
listType: this.ui_.listContainer.currentListType, listType: this.ui_.listContainer.currentListType,
isAllAndroidFoldersVisible:
this.directoryModel_.getFileFilter().isAllAndroidFoldersVisible()
}; };
var cm = this.ui_.listContainer.table.columnModel; var cm = this.ui_.listContainer.table.columnModel;
prefs.columnConfig = cm.exportColumnConfig(); prefs.columnConfig = cm.exportColumnConfig();
...@@ -155,6 +161,9 @@ AppStateController.prototype.saveViewOptions = function() { ...@@ -155,6 +161,9 @@ AppStateController.prototype.saveViewOptions = function() {
} }
}; };
/**
* @private
*/
AppStateController.prototype.onFileListSorted_ = function() { AppStateController.prototype.onFileListSorted_ = function() {
var currentDirectory = this.directoryModel_.getCurrentDirEntry(); var currentDirectory = this.directoryModel_.getCurrentDirEntry();
if (!currentDirectory) if (!currentDirectory)
...@@ -170,6 +179,19 @@ AppStateController.prototype.onFileListSorted_ = function() { ...@@ -170,6 +179,19 @@ AppStateController.prototype.onFileListSorted_ = function() {
this.saveViewOptions(); this.saveViewOptions();
}; };
/**
* @private
*/
AppStateController.prototype.onFileFilterChanged_ = function() {
const isAllAndroidFoldersVisible =
this.directoryModel_.getFileFilter().isAllAndroidFoldersVisible();
if (this.viewOptions_.isAllAndroidFoldersVisible !==
isAllAndroidFoldersVisible) {
this.viewOptions_.isAllAndroidFoldersVisible = isAllAndroidFoldersVisible;
this.saveViewOptions();
}
};
/** /**
* @param {Event} event * @param {Event} event
* @private * @private
......
...@@ -833,6 +833,8 @@ CommandHandler.COMMANDS_['toggle-hidden-android-folders'] = ...@@ -833,6 +833,8 @@ CommandHandler.COMMANDS_['toggle-hidden-android-folders'] =
!!fileManager.volumeManager.getCurrentProfileVolumeInfo( !!fileManager.volumeManager.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.ANDROID_FILES); VolumeManagerCommon.VolumeType.ANDROID_FILES);
event.command.setHidden(!event.canExecute); event.command.setHidden(!event.canExecute);
event.command.checked =
fileManager.fileFilter.isAllAndroidFoldersVisible();
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment