Loading res/menu/navigation_menu.xml +4 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,8 @@ android:id="@+id/mnu_actions_properties_current_folder" app:showAsAction="never" android:title="@string/actions_menu_properties_current_folder"/> <item android:id="@+id/mnu_actions_file_system_info" app:showAsAction="never" android:title="@string/actionbar_button_filesystem_cd"/> </menu> No newline at end of file res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -919,4 +919,7 @@ <string name="snackbar_unable_to_complete">Unable to complete action</string> <string name="snackbar_retry">RETRY</string> <string name="snackbar_upgrade">UPGRADE</string> <!-- File System info --> <string name="file_system_info_unavailable">Unable to fetch file system info for this path</string> </resources> src/com/cyanogenmod/filemanager/activities/MainActivity.java +0 −13 Original line number Diff line number Diff line Loading @@ -696,19 +696,6 @@ public class MainActivity extends ActionBarActivity switch (view.getId()) { //###################### //Breadcrumb Actions //###################### case com.cyanogenmod.filemanager.R.id.ab_filesystem_info: //Show information of the filesystem com.cyanogenmod.filemanager.model.MountPoint mp = ((NavigationFragment)currentFragment) .getCurrentNavigationView().getBreadcrumb().getMountPointInfo(); com.cyanogenmod.filemanager.model.DiskUsage du = ((NavigationFragment)currentFragment) .getCurrentNavigationView().getBreadcrumb().getDiskUsageInfo(); ((NavigationFragment)currentFragment).showMountPointInfo(mp, du); break; //###################### //Selection Actions //###################### case com.cyanogenmod.filemanager.R.id.ab_selection_done: Loading src/com/cyanogenmod/filemanager/tasks/FileSystemInfoTask.java 0 → 100644 +156 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cyanogenmod.filemanager.tasks; import android.os.AsyncTask; import android.util.Log; import com.cyanogenmod.filemanager.model.DiskUsage; import com.cyanogenmod.filemanager.model.MountPoint; import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment; import com.cyanogenmod.filemanager.util.MountPointHelper; import java.lang.ref.WeakReference; /** * A class for recovery information about filesystem status (mount point, disk usage, ...). */ public class FileSystemInfoTask extends AsyncTask<String, Integer, Void> { private static final String TAG = FileSystemInfoTask.class.getSimpleName(); private WeakReference<NavigationFragment> mNavigationFragmentWeakReference; final int mFreeDiskSpaceWarningLevel; private boolean mRunning; final boolean mIsDialog; private MountPoint mMountPoint; private DiskUsage mDiskUsage; /** * Constructor of <code>FileSystemInfoTask</code>. * * @param freeDiskSpaceWarningLevel The free disk space warning level */ public FileSystemInfoTask(NavigationFragment navigationFragment, int freeDiskSpaceWarningLevel) { this(navigationFragment, freeDiskSpaceWarningLevel, false); } /** * Constructor of <code>FileSystemInfoTask</code>. * * @param freeDiskSpaceWarningLevel The free disk space warning level * @param isDialog Whether or not to use dialog theme resources */ public FileSystemInfoTask(NavigationFragment navigationFragment, int freeDiskSpaceWarningLevel, boolean isDialog) { super(); mNavigationFragmentWeakReference = new WeakReference<>(navigationFragment); this.mFreeDiskSpaceWarningLevel = freeDiskSpaceWarningLevel; this.mRunning = false; this.mIsDialog = isDialog; } /** * Method that returns if there is a task running. * * @return boolean If there is a task running */ public boolean isRunning() { return this.mRunning; } /** * {@inheritDoc} */ @Override protected Void doInBackground(String... params) { //Running this.mRunning = true; //Extract the directory from arguments String dir = params[0]; //Extract filesystem mount point from directory if (isCancelled()) { return null; } mMountPoint = MountPointHelper.getMountPointFromDirectory(dir); if (mMountPoint == null) { //There is no information about this filesystem if (isCancelled()) { return null; } } else { //Load information about disk usage if (isCancelled()) { return null; } mDiskUsage = null; mDiskUsage = MountPointHelper.getMountPointDiskUsage(mMountPoint); int usage = 0; if (mDiskUsage != null && mDiskUsage.getTotal() != 0) { usage = (int) (mDiskUsage.getUsed() * 100 / mDiskUsage.getTotal()); } else { usage = mDiskUsage == null ? 0 : 100; } // Advise about diskusage (>=mFreeDiskSpaceWarningLevel) with other color if (usage >= mFreeDiskSpaceWarningLevel) { Log.i(TAG, "It's all good"); } else { Log.i(TAG, "Over warning"); } } return null; } /** * {@inheritDoc} */ @Override protected void onPostExecute(Void aVoid) { this.mRunning = false; NavigationFragment fragment = mNavigationFragmentWeakReference.get(); if (fragment != null) { fragment.setMountPoint(mMountPoint); fragment.setDiskUsage(mDiskUsage); } } /** * {@inheritDoc} */ @Override protected void onCancelled(Void aVoid) { this.mRunning = false; super.onCancelled(aVoid); } /** * {@inheritDoc} */ @Override protected void onCancelled() { this.mRunning = false; super.onCancelled(); } } src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java +50 −6 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ import com.cyanogenmod.filemanager.preferences.NavigationLayoutMode; import com.cyanogenmod.filemanager.preferences.ObjectIdentifier; import com.cyanogenmod.filemanager.preferences.PreferenceHelper; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.tasks.FileSystemInfoTask; import com.cyanogenmod.filemanager.tasks.FilesystemAsyncTask; import com.cyanogenmod.filemanager.ui.IconHolder; import com.cyanogenmod.filemanager.ui.ThemeManager; import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; Loading Loading @@ -254,12 +256,16 @@ public class NavigationFragment extends Fragment // Set the free disk space warning level of the breadcrumb widget Breadcrumb breadcrumb = getCurrentNavigationView().getBreadcrumb(); if (breadcrumb != null) { String fds = Preferences.getSharedPreferences().getString( FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(), (String)FileManagerSettings. SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue()); breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds)); mFreeDiskSpaceWarningLevel = Integer.parseInt(fds); breadcrumb.setFreeDiskSpaceWarningLevel(mFreeDiskSpaceWarningLevel); breadcrumb.updateMountPointInfo(); } updateMountPointInfo(); return; } Loading Loading @@ -442,6 +448,10 @@ public class NavigationFragment extends Fragment private int mOrientation; private FileSystemInfoTask mFileSystemInfoTask; private MountPoint mMountPoint; private DiskUsage mDiskUsage; private int mFreeDiskSpaceWarningLevel; /** * @hide Loading Loading @@ -595,6 +605,14 @@ public class NavigationFragment extends Fragment InfoActionPolicy.showPropertiesDialog(getActivity(), getCurrentNavigationView().getCurrentFso(), this); return true; case R.id.mnu_actions_file_system_info: if (mMountPoint != null && mDiskUsage != null) { showMountPointInfo(mMountPoint, mDiskUsage); } else { Toast.makeText(getActivity(), getString(R.string.file_system_info_unavailable), Toast.LENGTH_SHORT).show(); } return true; default: return false; } Loading Loading @@ -660,6 +678,11 @@ public class NavigationFragment extends Fragment mActiveDialog.dismiss(); } if (mFileSystemInfoTask != null) { mFileSystemInfoTask.cancel(true); mFileSystemInfoTask = null; } recycle(); super.onDestroy(); Loading Loading @@ -1350,6 +1373,7 @@ public class NavigationFragment extends Fragment Breadcrumb breadcrumb = getCurrentNavigationView().getBreadcrumb(); if (breadcrumb.getMountPointInfo().compareTo(mountPoint) == 0) { breadcrumb.updateMountPointInfo(); updateMountPointInfo(); } if (mountPoint.isSecure()) { // Secure mountpoints only can be unmount, so we need to move the navigation Loading @@ -1363,6 +1387,24 @@ public class NavigationFragment extends Fragment dialog.show(); } private void updateMountPointInfo() { //Cancel the current execution (if any) and launch again if (mFileSystemInfoTask != null) { mFileSystemInfoTask.cancel(true); } mFileSystemInfoTask = new FileSystemInfoTask(this, mFreeDiskSpaceWarningLevel); mFileSystemInfoTask.execute(getCurrentNavigationView().getCurrentDir()); } public void setMountPoint(MountPoint mp) { mMountPoint = mp; } public void setDiskUsage(DiskUsage ds) { mDiskUsage = ds; } /** * Method that checks the action that must be realized when the * back button is pushed. Loading Loading @@ -1871,6 +1913,8 @@ public class NavigationFragment extends Fragment mToolBar.setBackgroundColor(backgroundColor); getCurrentNavigationView().setPrimaryColor(backgroundColor); updateMountPointInfo(); if (mOnDirectoryChangedListener != null) { mOnDirectoryChangedListener.onDirectoryChanged(item); } Loading Loading
res/menu/navigation_menu.xml +4 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,8 @@ android:id="@+id/mnu_actions_properties_current_folder" app:showAsAction="never" android:title="@string/actions_menu_properties_current_folder"/> <item android:id="@+id/mnu_actions_file_system_info" app:showAsAction="never" android:title="@string/actionbar_button_filesystem_cd"/> </menu> No newline at end of file
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -919,4 +919,7 @@ <string name="snackbar_unable_to_complete">Unable to complete action</string> <string name="snackbar_retry">RETRY</string> <string name="snackbar_upgrade">UPGRADE</string> <!-- File System info --> <string name="file_system_info_unavailable">Unable to fetch file system info for this path</string> </resources>
src/com/cyanogenmod/filemanager/activities/MainActivity.java +0 −13 Original line number Diff line number Diff line Loading @@ -696,19 +696,6 @@ public class MainActivity extends ActionBarActivity switch (view.getId()) { //###################### //Breadcrumb Actions //###################### case com.cyanogenmod.filemanager.R.id.ab_filesystem_info: //Show information of the filesystem com.cyanogenmod.filemanager.model.MountPoint mp = ((NavigationFragment)currentFragment) .getCurrentNavigationView().getBreadcrumb().getMountPointInfo(); com.cyanogenmod.filemanager.model.DiskUsage du = ((NavigationFragment)currentFragment) .getCurrentNavigationView().getBreadcrumb().getDiskUsageInfo(); ((NavigationFragment)currentFragment).showMountPointInfo(mp, du); break; //###################### //Selection Actions //###################### case com.cyanogenmod.filemanager.R.id.ab_selection_done: Loading
src/com/cyanogenmod/filemanager/tasks/FileSystemInfoTask.java 0 → 100644 +156 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cyanogenmod.filemanager.tasks; import android.os.AsyncTask; import android.util.Log; import com.cyanogenmod.filemanager.model.DiskUsage; import com.cyanogenmod.filemanager.model.MountPoint; import com.cyanogenmod.filemanager.ui.fragments.NavigationFragment; import com.cyanogenmod.filemanager.util.MountPointHelper; import java.lang.ref.WeakReference; /** * A class for recovery information about filesystem status (mount point, disk usage, ...). */ public class FileSystemInfoTask extends AsyncTask<String, Integer, Void> { private static final String TAG = FileSystemInfoTask.class.getSimpleName(); private WeakReference<NavigationFragment> mNavigationFragmentWeakReference; final int mFreeDiskSpaceWarningLevel; private boolean mRunning; final boolean mIsDialog; private MountPoint mMountPoint; private DiskUsage mDiskUsage; /** * Constructor of <code>FileSystemInfoTask</code>. * * @param freeDiskSpaceWarningLevel The free disk space warning level */ public FileSystemInfoTask(NavigationFragment navigationFragment, int freeDiskSpaceWarningLevel) { this(navigationFragment, freeDiskSpaceWarningLevel, false); } /** * Constructor of <code>FileSystemInfoTask</code>. * * @param freeDiskSpaceWarningLevel The free disk space warning level * @param isDialog Whether or not to use dialog theme resources */ public FileSystemInfoTask(NavigationFragment navigationFragment, int freeDiskSpaceWarningLevel, boolean isDialog) { super(); mNavigationFragmentWeakReference = new WeakReference<>(navigationFragment); this.mFreeDiskSpaceWarningLevel = freeDiskSpaceWarningLevel; this.mRunning = false; this.mIsDialog = isDialog; } /** * Method that returns if there is a task running. * * @return boolean If there is a task running */ public boolean isRunning() { return this.mRunning; } /** * {@inheritDoc} */ @Override protected Void doInBackground(String... params) { //Running this.mRunning = true; //Extract the directory from arguments String dir = params[0]; //Extract filesystem mount point from directory if (isCancelled()) { return null; } mMountPoint = MountPointHelper.getMountPointFromDirectory(dir); if (mMountPoint == null) { //There is no information about this filesystem if (isCancelled()) { return null; } } else { //Load information about disk usage if (isCancelled()) { return null; } mDiskUsage = null; mDiskUsage = MountPointHelper.getMountPointDiskUsage(mMountPoint); int usage = 0; if (mDiskUsage != null && mDiskUsage.getTotal() != 0) { usage = (int) (mDiskUsage.getUsed() * 100 / mDiskUsage.getTotal()); } else { usage = mDiskUsage == null ? 0 : 100; } // Advise about diskusage (>=mFreeDiskSpaceWarningLevel) with other color if (usage >= mFreeDiskSpaceWarningLevel) { Log.i(TAG, "It's all good"); } else { Log.i(TAG, "Over warning"); } } return null; } /** * {@inheritDoc} */ @Override protected void onPostExecute(Void aVoid) { this.mRunning = false; NavigationFragment fragment = mNavigationFragmentWeakReference.get(); if (fragment != null) { fragment.setMountPoint(mMountPoint); fragment.setDiskUsage(mDiskUsage); } } /** * {@inheritDoc} */ @Override protected void onCancelled(Void aVoid) { this.mRunning = false; super.onCancelled(aVoid); } /** * {@inheritDoc} */ @Override protected void onCancelled() { this.mRunning = false; super.onCancelled(); } }
src/com/cyanogenmod/filemanager/ui/fragments/NavigationFragment.java +50 −6 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ import com.cyanogenmod.filemanager.preferences.NavigationLayoutMode; import com.cyanogenmod.filemanager.preferences.ObjectIdentifier; import com.cyanogenmod.filemanager.preferences.PreferenceHelper; import com.cyanogenmod.filemanager.preferences.Preferences; import com.cyanogenmod.filemanager.tasks.FileSystemInfoTask; import com.cyanogenmod.filemanager.tasks.FilesystemAsyncTask; import com.cyanogenmod.filemanager.ui.IconHolder; import com.cyanogenmod.filemanager.ui.ThemeManager; import com.cyanogenmod.filemanager.ui.ThemeManager.Theme; Loading Loading @@ -254,12 +256,16 @@ public class NavigationFragment extends Fragment // Set the free disk space warning level of the breadcrumb widget Breadcrumb breadcrumb = getCurrentNavigationView().getBreadcrumb(); if (breadcrumb != null) { String fds = Preferences.getSharedPreferences().getString( FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(), (String)FileManagerSettings. SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue()); breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds)); mFreeDiskSpaceWarningLevel = Integer.parseInt(fds); breadcrumb.setFreeDiskSpaceWarningLevel(mFreeDiskSpaceWarningLevel); breadcrumb.updateMountPointInfo(); } updateMountPointInfo(); return; } Loading Loading @@ -442,6 +448,10 @@ public class NavigationFragment extends Fragment private int mOrientation; private FileSystemInfoTask mFileSystemInfoTask; private MountPoint mMountPoint; private DiskUsage mDiskUsage; private int mFreeDiskSpaceWarningLevel; /** * @hide Loading Loading @@ -595,6 +605,14 @@ public class NavigationFragment extends Fragment InfoActionPolicy.showPropertiesDialog(getActivity(), getCurrentNavigationView().getCurrentFso(), this); return true; case R.id.mnu_actions_file_system_info: if (mMountPoint != null && mDiskUsage != null) { showMountPointInfo(mMountPoint, mDiskUsage); } else { Toast.makeText(getActivity(), getString(R.string.file_system_info_unavailable), Toast.LENGTH_SHORT).show(); } return true; default: return false; } Loading Loading @@ -660,6 +678,11 @@ public class NavigationFragment extends Fragment mActiveDialog.dismiss(); } if (mFileSystemInfoTask != null) { mFileSystemInfoTask.cancel(true); mFileSystemInfoTask = null; } recycle(); super.onDestroy(); Loading Loading @@ -1350,6 +1373,7 @@ public class NavigationFragment extends Fragment Breadcrumb breadcrumb = getCurrentNavigationView().getBreadcrumb(); if (breadcrumb.getMountPointInfo().compareTo(mountPoint) == 0) { breadcrumb.updateMountPointInfo(); updateMountPointInfo(); } if (mountPoint.isSecure()) { // Secure mountpoints only can be unmount, so we need to move the navigation Loading @@ -1363,6 +1387,24 @@ public class NavigationFragment extends Fragment dialog.show(); } private void updateMountPointInfo() { //Cancel the current execution (if any) and launch again if (mFileSystemInfoTask != null) { mFileSystemInfoTask.cancel(true); } mFileSystemInfoTask = new FileSystemInfoTask(this, mFreeDiskSpaceWarningLevel); mFileSystemInfoTask.execute(getCurrentNavigationView().getCurrentDir()); } public void setMountPoint(MountPoint mp) { mMountPoint = mp; } public void setDiskUsage(DiskUsage ds) { mDiskUsage = ds; } /** * Method that checks the action that must be realized when the * back button is pushed. Loading Loading @@ -1871,6 +1913,8 @@ public class NavigationFragment extends Fragment mToolBar.setBackgroundColor(backgroundColor); getCurrentNavigationView().setPrimaryColor(backgroundColor); updateMountPointInfo(); if (mOnDirectoryChangedListener != null) { mOnDirectoryChangedListener.onDirectoryChanged(item); } Loading