diff options
author | jruesga <jorge@ruesga.com> | 2012-09-30 02:02:22 +0200 |
---|---|---|
committer | jruesga <jorge@ruesga.com> | 2012-09-30 02:02:22 +0200 |
commit | d27cbaf5eadd425ad0067467d3fbb5fd56a7901c (patch) | |
tree | 6a4b7a827b24a51e61dca463bf06ec83e12f9ced /src | |
parent | 47c142cb6b2ac01f16d3aef2a3fdf83b9e3e9861 (diff) | |
download | android_packages_apps_CMFileManager-d27cbaf5eadd425ad0067467d3fbb5fd56a7901c.tar.gz android_packages_apps_CMFileManager-d27cbaf5eadd425ad0067467d3fbb5fd56a7901c.tar.bz2 android_packages_apps_CMFileManager-d27cbaf5eadd425ad0067467d3fbb5fd56a7901c.zip |
New setting for "compute folder statistics" option
Diffstat (limited to 'src')
3 files changed, 37 insertions, 9 deletions
diff --git a/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java b/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java index 3335f5ac..4f990aaf 100644 --- a/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java +++ b/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java @@ -118,6 +118,7 @@ public class SettingsPreferences extends PreferenceActivity { private CheckBoxPreference mCaseSensitiveSort; private ListPreference mDefaultLongClickAction; private ListPreference mFreeDiskSpaceWarningLevel; + private CheckBoxPreference mComputeFolderStatistics; private CheckBoxPreference mAllowConsoleSelection; private boolean mLoaded = false; @@ -208,6 +209,12 @@ public class SettingsPreferences extends PreferenceActivity { defaultValue); this.mOnChangeListener.onPreferenceChange(this.mFreeDiskSpaceWarningLevel, value); + // Compute folder statistics + this.mComputeFolderStatistics = + (CheckBoxPreference)findPreference( + ExplorerSettings.SETTINGS_COMPUTE_FOLDER_STATISTICS.getId()); + this.mComputeFolderStatistics.setOnPreferenceChangeListener(this.mOnChangeListener); + // Allow console selection this.mAllowConsoleSelection = (CheckBoxPreference)findPreference( diff --git a/src/com/cyanogenmod/explorer/preferences/ExplorerSettings.java b/src/com/cyanogenmod/explorer/preferences/ExplorerSettings.java index 006b4ae3..fdda4097 100644 --- a/src/com/cyanogenmod/explorer/preferences/ExplorerSettings.java +++ b/src/com/cyanogenmod/explorer/preferences/ExplorerSettings.java @@ -84,6 +84,12 @@ public enum ExplorerSettings { "cm_explorer_disk_usage_warning_level", //$NON-NLS-1$ new String("95")), //$NON-NLS-1$ /** + * When to compute folder statistics in folder properties dialog + * @hide + */ + SETTINGS_COMPUTE_FOLDER_STATISTICS( + "cm_explorer_compute_folder_statistics", Boolean.TRUE), //$NON-NLS-1$ + /** * When to use case sensitive comparison in sorting of files * @hide */ diff --git a/src/com/cyanogenmod/explorer/ui/dialogs/FsoPropertiesDialog.java b/src/com/cyanogenmod/explorer/ui/dialogs/FsoPropertiesDialog.java index 8824908f..880dab84 100644 --- a/src/com/cyanogenmod/explorer/ui/dialogs/FsoPropertiesDialog.java +++ b/src/com/cyanogenmod/explorer/ui/dialogs/FsoPropertiesDialog.java @@ -51,6 +51,8 @@ import com.cyanogenmod.explorer.model.Permissions; import com.cyanogenmod.explorer.model.Symlink; import com.cyanogenmod.explorer.model.User; import com.cyanogenmod.explorer.model.UserPermission; +import com.cyanogenmod.explorer.preferences.ExplorerSettings; +import com.cyanogenmod.explorer.preferences.Preferences; import com.cyanogenmod.explorer.util.AIDHelper; import com.cyanogenmod.explorer.util.CommandHelper; import com.cyanogenmod.explorer.util.DialogHelper; @@ -99,6 +101,7 @@ public class FsoPropertiesDialog private boolean mIgnoreCheckEvents; private boolean mHasPrivileged; + private final boolean mComputeFolderStatistics; private AsyncResultExecutable mFolderUsageExecutable; private FolderUsage mFolderUsage; private boolean mDrawingFolderUsage; @@ -137,6 +140,14 @@ public class FsoPropertiesDialog this.mDialog.setOnCancelListener(this); this.mDialog.setOnDismissListener(this); + // Retrieve the user settings about computing folder statistics + this.mComputeFolderStatistics = + Preferences.getSharedPreferences(). + getBoolean( + ExplorerSettings.SETTINGS_COMPUTE_FOLDER_STATISTICS.getId(), + ((Boolean)ExplorerSettings.SETTINGS_COMPUTE_FOLDER_STATISTICS. + getDefaultValue()).booleanValue()); + //Fill the dialog fillData(this.mContentView); } @@ -239,7 +250,9 @@ public class FsoPropertiesDialog // Load owners and groups AIDs in background if (FileHelper.isDirectory(this.mFso)) { vContatinsRow.setVisibility(View.VISIBLE); - computeFolderUsage(); + if (this.mComputeFolderStatistics) { + computeFolderUsage(); + } } // Check if permissions operations are allowed @@ -889,15 +902,17 @@ public class FsoPropertiesDialog * Method that cancels the folder usage command execution */ private void cancelFolderUsageCommand() { - // Cancel the folder usage command - try { - if (this.mFolderUsageExecutable != null && - this.mFolderUsageExecutable.isCancelable() && - !this.mFolderUsageExecutable.isCanceled()) { - this.mFolderUsageExecutable.cancel(); + if (this.mComputeFolderStatistics) { + // Cancel the folder usage command + try { + if (this.mFolderUsageExecutable != null && + this.mFolderUsageExecutable.isCancelable() && + !this.mFolderUsageExecutable.isCanceled()) { + this.mFolderUsageExecutable.cancel(); + } + } catch (Exception ex) { + Log.e(TAG, "Failed to cancel the folder usage command", ex); //$NON-NLS-1$ } - } catch (Exception ex) { - Log.e(TAG, "Failed to cancel the folder usage command", ex); //$NON-NLS-1$ } } |