Skip to content
This repository was archived by the owner on Mar 18, 2023. It is now read-only.

Commit 03990d3

Browse files
committed
Fixing a few more bugs, having FileProvider return File objects
1 parent ea5699d commit 03990d3

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/BasicFileProvider.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,19 @@ public DocumentPointer(String absInitFolderPath) {
894894

895895
public boolean isValid() { return isValid; }
896896

897+
public File getFile(String documentPath) {
898+
if(!isValid()) {
899+
return null;
900+
}
901+
this.filePath = documentPath.replaceFirst(fpInst.getCWD(), "");
902+
return new File(fpInst.getCWD(), filePath);
903+
}
904+
897905
public boolean locateDocument(String documentPath) throws FileNotFoundException {
898906
if(!isValid()) {
899907
return false;
900908
}
901-
this.filePath = documentPath.replaceFirst(fpInst.getCWD(), "");
902-
File docFile = new File(fpInst.getCWD(), filePath);
909+
File docFile = getFile(documentPath);
903910
documentId = fpInst.getDocIdForFile(docFile);
904911
return true;
905912
}

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/FileChooserActivity.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,7 @@ public void onClick(View btnView) {
247247
backBtn.setOnClickListener(new View.OnClickListener() {
248248
@Override
249249
public void onClick(View view) {
250-
DisplayFragments displayCtx = DisplayFragments.getInstance();
251-
if(displayCtx.pathHistoryStack.empty() || displayCtx.getCwdFolderContext().isTopLevelFolder()) {
252-
getInstance().postSelectedFilesActivityResult(new FileChooserException.CommunicateNoDataException());
253-
return;
254-
}
255-
String displayAscendingPrecurseMsg = String.format(Locale.getDefault(), "Ascending back upwards into DIR \"%s\".",
256-
displayCtx.pathHistoryStack.peek().getCWDBasePath());
257-
DisplayUtils.displayToastMessageShort(displayAscendingPrecurseMsg);
258-
if(displayCtx.pathHistoryStack.peek().isRecentDocuments()) {
259-
BasicFileProvider fpInst = BasicFileProvider.getInstance();
260-
fpInst.selectBaseDirectoryByType(FileChooserBuilder.BaseFolderPathType.BASE_PATH_DEFAULT);
261-
DisplayFragments.getInstance().descendIntoNextDirectory(true);
262-
DisplayFragments.updateFolderHistoryPaths(displayCtx.getCwdFolderContext().getCWDBasePath(), true);
263-
}
264-
else {
265-
DisplayTypes.DirectoryResultContext.probePreviousFolder(1);
266-
boolean initNewTree = displayCtx.pathHistoryStack.peek().isTopLevelFolder();
267-
DisplayFragments.getInstance().descendIntoNextDirectory(initNewTree);
268-
DisplayFragments.updateFolderHistoryPaths(displayCtx.getCwdFolderContext().getCWDBasePath(), initNewTree);
269-
}
250+
chooserBackButtonPressed();
270251
}
271252
});
272253
LinearLayout dirHistoryNavContainer = (LinearLayout) findViewById(R.id.mainDirPrevPathsNavContainer);
@@ -317,6 +298,29 @@ public void onClick(View btnView) {
317298

318299
}
319300

301+
private void chooserBackButtonPressed() {
302+
DisplayFragments displayCtx = DisplayFragments.getInstance();
303+
if(displayCtx.pathHistoryStack.empty() || displayCtx.getCwdFolderContext().isTopLevelFolder()) {
304+
getInstance().postSelectedFilesActivityResult(new FileChooserException.CommunicateNoDataException());
305+
return;
306+
}
307+
String displayAscendingPrecurseMsg = String.format(Locale.getDefault(), "Ascending back upwards into DIR \"%s\".",
308+
displayCtx.pathHistoryStack.peek().getCWDBasePath());
309+
DisplayUtils.displayToastMessageShort(displayAscendingPrecurseMsg);
310+
if(displayCtx.pathHistoryStack.peek().isRecentDocuments()) {
311+
BasicFileProvider fpInst = BasicFileProvider.getInstance();
312+
fpInst.selectBaseDirectoryByType(FileChooserBuilder.BaseFolderPathType.BASE_PATH_DEFAULT);
313+
DisplayFragments.getInstance().descendIntoNextDirectory(true);
314+
DisplayFragments.updateFolderHistoryPaths(displayCtx.getCwdFolderContext().getCWDBasePath(), true);
315+
}
316+
else {
317+
DisplayTypes.DirectoryResultContext.probePreviousFolder(1);
318+
boolean initNewTree = displayCtx.pathHistoryStack.peek().isTopLevelFolder();
319+
DisplayFragments.getInstance().descendIntoNextDirectory(initNewTree);
320+
DisplayFragments.updateFolderHistoryPaths(displayCtx.getCwdFolderContext().getCWDBasePath(), initNewTree);
321+
}
322+
}
323+
320324
@Override
321325
public void onNewIntent(Intent broadcastIntent) {
322326
super.onNewIntent(broadcastIntent);
@@ -405,6 +409,9 @@ public void postSelectedFilesActivityResult(Exception runtimeExcpt) {
405409
}
406410

407411
@Override
408-
public void onBackPressed() {}
412+
public void onBackPressed() {
413+
//super.onBackPressed();
414+
chooserBackButtonPressed();
415+
}
409416

410417
}

0 commit comments

Comments
 (0)