Loading src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +43 −1 Original line number Diff line number Diff line Loading @@ -301,6 +301,20 @@ public class NavigationActivity extends Activity } } } else if (intent.getAction().compareTo( FileManagerSettings.INTENT_FILE_CHANGED) == 0) { // Retrieve the file that was changed String file = intent.getStringExtra(FileManagerSettings.EXTRA_FILE_CHANGED_KEY); try { FileSystemObject fso = CommandHelper.getFileInfo(context, file, null); if (fso != null) { getCurrentNavigationView().refresh(fso); } } catch (Exception e) { ExceptionUtil.translateException(context, e, true, false); } } else if (intent.getAction().compareTo( FileManagerSettings.INTENT_THEME_CHANGED) == 0) { applyTheme(); Loading Loading @@ -627,6 +641,7 @@ public class NavigationActivity extends Activity if (curDir != null) { VirtualMountPointConsole vc = VirtualMountPointConsole.getVirtualConsoleForPath( mNavigationViews[mCurrentNavigationView].getCurrentDir()); getCurrentNavigationView().refresh(true); if (vc != null && !vc.isMounted()) { onRequestBookmarksRefresh(); removeUnmountedHistory(); Loading Loading @@ -1883,6 +1898,10 @@ public class NavigationActivity extends Activity if (searchInfo != null && searchInfo.isSuccessNavigation()) { //Navigate to previous history back(); } else { // I don't know is the search view was changed, so try to do a refresh // of the navigation view getCurrentNavigationView().refresh(true); } } // reset bookmarks list to default as the user could have set a Loading Loading @@ -1919,6 +1938,13 @@ public class NavigationActivity extends Activity */ @Override public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { // Refresh only the item this.getCurrentNavigationView().refresh((FileSystemObject)o); } else if (o == null) { // Refresh all getCurrentNavigationView().refresh(); } if (clearSelection) { this.getCurrentNavigationView().onDeselectAll(); } Loading @@ -1938,8 +1964,13 @@ public class NavigationActivity extends Activity @Override public void onRequestRemove(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { // Remove from view this.getCurrentNavigationView().removeItem((FileSystemObject)o); //Remove from history removeFromHistory((FileSystemObject)o); } else { onRequestRefresh(null, clearSelection); } if (clearSelection) { this.getCurrentNavigationView().onDeselectAll(); Loading Loading @@ -2292,8 +2323,19 @@ public class NavigationActivity extends Activity } } catch (Exception e) { // Do nothing, objects should be removed by the FileObserver in NavigationView // Notify the user ExceptionUtil.translateException(this, e); // Remove the object if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) { // If have a FileSystemObject reference then there is no need to search // the path (less resources used) if (item instanceof FileSystemObject) { getCurrentNavigationView().removeItem((FileSystemObject)item); } else { getCurrentNavigationView().removeItem((String)item); } } return; } Loading src/com/cyanogenmod/filemanager/model/Directory.java +0 −6 Original line number Diff line number Diff line Loading @@ -36,12 +36,6 @@ public class Directory extends FileSystemObject { */ public static final char UNIX_ID = 'd'; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public Directory() {} /** * Constructor of <code>Directory</code>. * Loading src/com/cyanogenmod/filemanager/model/FileSystemObject.java +0 −6 Original line number Diff line number Diff line Loading @@ -53,12 +53,6 @@ public abstract class FileSystemObject implements Serializable, Comparable<FileS private boolean mIsSecure; private boolean mIsRemote; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public FileSystemObject() {} /** * Constructor of <code>FileSystemObject</code>. * Loading src/com/cyanogenmod/filemanager/model/RegularFile.java +0 −6 Original line number Diff line number Diff line Loading @@ -31,12 +31,6 @@ public class RegularFile extends FileSystemObject { */ public static final char UNIX_ID = '-'; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public RegularFile() {} /** * Constructor of <code>RegularFile</code>. * Loading src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java +43 −69 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.TypedArray; import android.os.AsyncTask; import android.os.FileObserver; import android.os.storage.StorageVolume; import android.util.AttributeSet; import android.util.Log; Loading Loading @@ -439,8 +438,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe // Restrictions private Map<DisplayRestrictions, Object> mRestrictions; private FileObserver mCurrentDirObserver; /** * @hide */ Loading Loading @@ -831,7 +828,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe public void recycle() { if (this.mAdapter != null) { this.mAdapter.dispose(); this.mCurrentDirObserver.stopWatching(); } } Loading Loading @@ -944,6 +940,38 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } } /** * Method that removes a {@link FileSystemObject} from the view * * @param fso The file system object */ public void removeItem(FileSystemObject fso) { // Delete also from internal list if (fso != null) { int cc = this.mFiles.size()-1; for (int i = cc; i >= 0; i--) { FileSystemObject f = this.mFiles.get(i); if (f != null && f.compareTo(fso) == 0) { this.mFiles.remove(i); break; } } } this.mAdapter.remove(fso); } /** * Method that removes a file system object from his path from the view * * @param path The file system object path */ public void removeItem(String path) { FileSystemObject fso = this.mAdapter.getItem(path); if (fso != null) { this.mAdapter.remove(fso); } } /** * Method that returns the current directory. * Loading Loading @@ -996,10 +1024,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe final String newDir, final boolean addToHistory, final boolean reload, final boolean useCurrent, final SearchInfoParcelable searchInfo, final FileSystemObject scrollTo) { if (mCurrentDirObserver != null) { mCurrentDirObserver.stopWatching(); mCurrentDirObserver = null; } NavigationTask task = new NavigationTask(useCurrent, addToHistory, reload, searchInfo, scrollTo, mRestrictions, mChRooted); task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, newDir); Loading Loading @@ -1042,7 +1066,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe void onPostExecuteTask( List<FileSystemObject> files, boolean addToHistory, boolean isNewHistory, boolean hasChanged, SearchInfoParcelable searchInfo, final String newDir, final FileSystemObject scrollTo) { String newDir, final FileSystemObject scrollTo) { try { //Check that there is not errors and have some data if (files == null) { Loading Loading @@ -1081,66 +1105,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe //The current directory is now the "newDir" this.mCurrentDir = newDir; mCurrentDirObserver = new FileObserver(newDir) { @Override public void onEvent(int event, final String path) { Runnable runnable = null; final String fullPath = newDir + '/' + path; // This is done because the implementation doesn't match the documentation // for FileObserver and we are given undocumented flags. event &= FileObserver.ALL_EVENTS; switch (event) { case FileObserver.CREATE: case FileObserver.MOVED_TO: { final FileSystemObject fso = FileHelper.createFileSystemObject( new File(fullPath)); if (FileHelper.shouldShow(fso, mRestrictions, mChRooted)) { runnable = new Runnable() { @Override public void run() { mAdapter.add(fso); // TODO: refactor to move this off of UI thread mAdapter.sort(FileHelper.getSortComparator()); } }; break; } } case FileObserver.DELETE: case FileObserver.MOVED_FROM: { runnable = new Runnable() { @Override public void run() { mAdapter.remove(mAdapter.getItem(fullPath)); } }; break; } case FileObserver.DELETE_SELF: { // TODO: Actually handle this break; } case FileObserver.MODIFY: { runnable = new Runnable() { @Override public void run() { FileHelper.updateFileSystemObject(mAdapter.getItem(fullPath)); mAdapter.notifyDataSetChanged(); } }; break; } default: Log.w(TAG, "Unknown event " + event + " for " + fullPath); } if (runnable != null) { post(runnable); } } }; mCurrentDirObserver.startWatching(); if (this.mOnDirectoryChangedListener != null) { FileSystemObject dir = FileHelper.createFileSystemObject(new File(newDir)); this.mOnDirectoryChangedListener.onDirectoryChanged(dir); Loading Loading @@ -1273,6 +1237,11 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe */ @Override public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { refresh((FileSystemObject)o); } else if (o == null) { refresh(); } if (clearSelection) { onDeselectAll(); } Loading @@ -1291,6 +1260,11 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe */ @Override public void onRequestRemove(Object o, boolean clearSelection) { if (o != null && o instanceof FileSystemObject) { removeItem((FileSystemObject)o); } else { onRequestRefresh(null, clearSelection); } if (clearSelection) { onDeselectAll(); } Loading Loading
src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +43 −1 Original line number Diff line number Diff line Loading @@ -301,6 +301,20 @@ public class NavigationActivity extends Activity } } } else if (intent.getAction().compareTo( FileManagerSettings.INTENT_FILE_CHANGED) == 0) { // Retrieve the file that was changed String file = intent.getStringExtra(FileManagerSettings.EXTRA_FILE_CHANGED_KEY); try { FileSystemObject fso = CommandHelper.getFileInfo(context, file, null); if (fso != null) { getCurrentNavigationView().refresh(fso); } } catch (Exception e) { ExceptionUtil.translateException(context, e, true, false); } } else if (intent.getAction().compareTo( FileManagerSettings.INTENT_THEME_CHANGED) == 0) { applyTheme(); Loading Loading @@ -627,6 +641,7 @@ public class NavigationActivity extends Activity if (curDir != null) { VirtualMountPointConsole vc = VirtualMountPointConsole.getVirtualConsoleForPath( mNavigationViews[mCurrentNavigationView].getCurrentDir()); getCurrentNavigationView().refresh(true); if (vc != null && !vc.isMounted()) { onRequestBookmarksRefresh(); removeUnmountedHistory(); Loading Loading @@ -1883,6 +1898,10 @@ public class NavigationActivity extends Activity if (searchInfo != null && searchInfo.isSuccessNavigation()) { //Navigate to previous history back(); } else { // I don't know is the search view was changed, so try to do a refresh // of the navigation view getCurrentNavigationView().refresh(true); } } // reset bookmarks list to default as the user could have set a Loading Loading @@ -1919,6 +1938,13 @@ public class NavigationActivity extends Activity */ @Override public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { // Refresh only the item this.getCurrentNavigationView().refresh((FileSystemObject)o); } else if (o == null) { // Refresh all getCurrentNavigationView().refresh(); } if (clearSelection) { this.getCurrentNavigationView().onDeselectAll(); } Loading @@ -1938,8 +1964,13 @@ public class NavigationActivity extends Activity @Override public void onRequestRemove(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { // Remove from view this.getCurrentNavigationView().removeItem((FileSystemObject)o); //Remove from history removeFromHistory((FileSystemObject)o); } else { onRequestRefresh(null, clearSelection); } if (clearSelection) { this.getCurrentNavigationView().onDeselectAll(); Loading Loading @@ -2292,8 +2323,19 @@ public class NavigationActivity extends Activity } } catch (Exception e) { // Do nothing, objects should be removed by the FileObserver in NavigationView // Notify the user ExceptionUtil.translateException(this, e); // Remove the object if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) { // If have a FileSystemObject reference then there is no need to search // the path (less resources used) if (item instanceof FileSystemObject) { getCurrentNavigationView().removeItem((FileSystemObject)item); } else { getCurrentNavigationView().removeItem((String)item); } } return; } Loading
src/com/cyanogenmod/filemanager/model/Directory.java +0 −6 Original line number Diff line number Diff line Loading @@ -36,12 +36,6 @@ public class Directory extends FileSystemObject { */ public static final char UNIX_ID = 'd'; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public Directory() {} /** * Constructor of <code>Directory</code>. * Loading
src/com/cyanogenmod/filemanager/model/FileSystemObject.java +0 −6 Original line number Diff line number Diff line Loading @@ -53,12 +53,6 @@ public abstract class FileSystemObject implements Serializable, Comparable<FileS private boolean mIsSecure; private boolean mIsRemote; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public FileSystemObject() {} /** * Constructor of <code>FileSystemObject</code>. * Loading
src/com/cyanogenmod/filemanager/model/RegularFile.java +0 −6 Original line number Diff line number Diff line Loading @@ -31,12 +31,6 @@ public class RegularFile extends FileSystemObject { */ public static final char UNIX_ID = '-'; /** * Normally, you shouldn't call this, however, this is in to be able * to further abstract some calls in FileHelper. **/ public RegularFile() {} /** * Constructor of <code>RegularFile</code>. * Loading
src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java +43 −69 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.TypedArray; import android.os.AsyncTask; import android.os.FileObserver; import android.os.storage.StorageVolume; import android.util.AttributeSet; import android.util.Log; Loading Loading @@ -439,8 +438,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe // Restrictions private Map<DisplayRestrictions, Object> mRestrictions; private FileObserver mCurrentDirObserver; /** * @hide */ Loading Loading @@ -831,7 +828,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe public void recycle() { if (this.mAdapter != null) { this.mAdapter.dispose(); this.mCurrentDirObserver.stopWatching(); } } Loading Loading @@ -944,6 +940,38 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe } } /** * Method that removes a {@link FileSystemObject} from the view * * @param fso The file system object */ public void removeItem(FileSystemObject fso) { // Delete also from internal list if (fso != null) { int cc = this.mFiles.size()-1; for (int i = cc; i >= 0; i--) { FileSystemObject f = this.mFiles.get(i); if (f != null && f.compareTo(fso) == 0) { this.mFiles.remove(i); break; } } } this.mAdapter.remove(fso); } /** * Method that removes a file system object from his path from the view * * @param path The file system object path */ public void removeItem(String path) { FileSystemObject fso = this.mAdapter.getItem(path); if (fso != null) { this.mAdapter.remove(fso); } } /** * Method that returns the current directory. * Loading Loading @@ -996,10 +1024,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe final String newDir, final boolean addToHistory, final boolean reload, final boolean useCurrent, final SearchInfoParcelable searchInfo, final FileSystemObject scrollTo) { if (mCurrentDirObserver != null) { mCurrentDirObserver.stopWatching(); mCurrentDirObserver = null; } NavigationTask task = new NavigationTask(useCurrent, addToHistory, reload, searchInfo, scrollTo, mRestrictions, mChRooted); task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, newDir); Loading Loading @@ -1042,7 +1066,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe void onPostExecuteTask( List<FileSystemObject> files, boolean addToHistory, boolean isNewHistory, boolean hasChanged, SearchInfoParcelable searchInfo, final String newDir, final FileSystemObject scrollTo) { String newDir, final FileSystemObject scrollTo) { try { //Check that there is not errors and have some data if (files == null) { Loading Loading @@ -1081,66 +1105,6 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe //The current directory is now the "newDir" this.mCurrentDir = newDir; mCurrentDirObserver = new FileObserver(newDir) { @Override public void onEvent(int event, final String path) { Runnable runnable = null; final String fullPath = newDir + '/' + path; // This is done because the implementation doesn't match the documentation // for FileObserver and we are given undocumented flags. event &= FileObserver.ALL_EVENTS; switch (event) { case FileObserver.CREATE: case FileObserver.MOVED_TO: { final FileSystemObject fso = FileHelper.createFileSystemObject( new File(fullPath)); if (FileHelper.shouldShow(fso, mRestrictions, mChRooted)) { runnable = new Runnable() { @Override public void run() { mAdapter.add(fso); // TODO: refactor to move this off of UI thread mAdapter.sort(FileHelper.getSortComparator()); } }; break; } } case FileObserver.DELETE: case FileObserver.MOVED_FROM: { runnable = new Runnable() { @Override public void run() { mAdapter.remove(mAdapter.getItem(fullPath)); } }; break; } case FileObserver.DELETE_SELF: { // TODO: Actually handle this break; } case FileObserver.MODIFY: { runnable = new Runnable() { @Override public void run() { FileHelper.updateFileSystemObject(mAdapter.getItem(fullPath)); mAdapter.notifyDataSetChanged(); } }; break; } default: Log.w(TAG, "Unknown event " + event + " for " + fullPath); } if (runnable != null) { post(runnable); } } }; mCurrentDirObserver.startWatching(); if (this.mOnDirectoryChangedListener != null) { FileSystemObject dir = FileHelper.createFileSystemObject(new File(newDir)); this.mOnDirectoryChangedListener.onDirectoryChanged(dir); Loading Loading @@ -1273,6 +1237,11 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe */ @Override public void onRequestRefresh(Object o, boolean clearSelection) { if (o instanceof FileSystemObject) { refresh((FileSystemObject)o); } else if (o == null) { refresh(); } if (clearSelection) { onDeselectAll(); } Loading @@ -1291,6 +1260,11 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe */ @Override public void onRequestRemove(Object o, boolean clearSelection) { if (o != null && o instanceof FileSystemObject) { removeItem((FileSystemObject)o); } else { onRequestRefresh(null, clearSelection); } if (clearSelection) { onDeselectAll(); } Loading