Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Oct 13, 2024
1 parent a4dd5c2 commit 27626eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class GsFileBrowserListAdapter extends RecyclerView.Adapter<GsFileBrowser
public static final File VIRTUAL_STORAGE_FAVOURITE = new File(VIRTUAL_STORAGE_ROOT, "Favourites");
public static final File VIRTUAL_STORAGE_POPULAR = new File(VIRTUAL_STORAGE_ROOT, "Popular");
public static final File VIRTUAL_STORAGE_APP_DATA_PRIVATE = new File(VIRTUAL_STORAGE_ROOT, "appdata-private");
public static final File VIRTUAL_STORAGE_HOME = new File(VIRTUAL_STORAGE_ROOT, "Notebook");
private static final File GO_BACK_SIGNIFIER = new File("__GO_BACK__");
private static final StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
public static final String EXTRA_CURRENT_FOLDER = "EXTRA_CURRENT_FOLDER";
Expand Down Expand Up @@ -268,6 +267,15 @@ public void onAttachedToRecyclerView(@NonNull final RecyclerView view) {
_layoutManager = (LinearLayoutManager) view.getLayoutManager();
}

public String formatFileDescription(final File file, String format) {
if (TextUtils.isEmpty(format)) {
return DateUtils.formatDateTime(_context, file.lastModified(), (DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NUMERIC_DATE));
} else {
format = format.replaceAll("FS(?=([^']*'[^']*')*[^']*$)", '\'' + GsFileUtils.getHumanReadableByteCountSI(file.length()) + '\'');
return new SimpleDateFormat(format, Locale.getDefault()).format(file.lastModified());
}
}

public void saveInstanceState(final @NonNull Bundle outState) {
if (_currentFolder != null) {
outState.putSerializable(EXTRA_CURRENT_FOLDER, _currentFolder.getAbsolutePath());
Expand All @@ -280,15 +288,6 @@ public void saveInstanceState(final @NonNull Bundle outState) {
}
}

public String formatFileDescription(final File file, String format) {
if (TextUtils.isEmpty(format)) {
return DateUtils.formatDateTime(_context, file.lastModified(), (DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NUMERIC_DATE));
} else {
format = format.replaceAll("FS(?=([^']*'[^']*')*[^']*$)", '\'' + GsFileUtils.getHumanReadableByteCountSI(file.length()) + '\'');
return new SimpleDateFormat(format, Locale.getDefault()).format(file.lastModified());
}
}

public void restoreSavedInstanceState(final Bundle savedInstanceState) {
if (savedInstanceState == null) {
return;
Expand Down Expand Up @@ -405,7 +404,7 @@ public void onClick(View view) {
case R.id.opoc_filesystem_item__root: {
// A own item was clicked
if (data.file != null) {
File file = GsCollectionUtils.getOrDefault(_virtualMapping, data.file, data.file);
final File file = GsCollectionUtils.getOrDefault(_virtualMapping, data.file, data.file);

if (areItemsSelected()) {
// There are 1 or more items selected yet
Expand Down Expand Up @@ -743,11 +742,7 @@ private synchronized void _loadFolder(final @NonNull File folder, final @Nullabl
final boolean modSumChanged = modSum != _prevModSum;

if (canGoUp(folder)) {
if (
isVirtualFolder(folder) ||
_virtualMapping.containsValue(folder) ||
!GsFileUtils.isChild(VIRTUAL_STORAGE_ROOT, folder)
) {
if (isVirtualFolder(folder) || _virtualMapping.containsValue(folder) || !GsFileUtils.isChild(VIRTUAL_STORAGE_ROOT, folder)) {
newData.add(0, VIRTUAL_STORAGE_ROOT);
} else {
newData.add(0, folder.getParentFile());
Expand Down Expand Up @@ -894,10 +889,6 @@ public static class FilesystemViewerViewHolder extends RecyclerView.ViewHolder {
}
}

private boolean isParent(File parent, File child) {
return (VIRTUAL_STORAGE_ROOT.equals(parent) && _virtualMapping.containsKey(child)) || GsFileUtils.isChild(parent, child);
}

public static boolean isVirtualFolder(final File file) {
return VIRTUAL_STORAGE_RECENTS.equals(file) ||
VIRTUAL_STORAGE_FAVOURITE.equals(file) ||
Expand All @@ -906,6 +897,10 @@ public static boolean isVirtualFolder(final File file) {
VIRTUAL_STORAGE_EMULATED.equals(file);
}

private boolean isParent(File parent, File child) {
return (VIRTUAL_STORAGE_ROOT.equals(parent) && _virtualMapping.containsKey(child)) || GsFileUtils.isChild(parent, child);
}

public void showFileAfterNextLoad(final File file) {
_fileToShowAfterNextLoad = file;
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/string-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="pref_key__editor_markdown_bigger_headings_2" translatable="false">pref_key__editor_markdown_bigger_headings_2</string>
<string name="pref_key__editor_unordered_list_character" translatable="false">pref_key__editor_unordered_list_character</string>
<string name="pref_key__recent_documents" translatable="false">pref_key__recent_documents</string>
<string name="pref_key__storage" translatable="false">pref_key__recent_documents</string>
<string name="pref_key__popular_documents" translatable="false">pref_key__popular_documents</string>
<string name="pref_key__favourite_files" translatable="false">pref_key__favourite_files</string>
<string name="pref_key__select_create_document" translatable="false">pref_key__select_create_document</string>
Expand Down Expand Up @@ -424,7 +423,6 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="pref_key__template_title_format_map" translatable="false">pref_key__template_title_format_map</string>
<string name="pref_key__title_format_list" translatable="false">pref_key__title_format_list</string>
<string name="pref_key__format_share_as_link" translatable="false">pref_key__format_share_as_link</string>
<string name="action_go_to_storage" translatable="false">action_go_to_storage</string>
<string name="squarebrackets" translatable="false">Square Brackets</string>
<string name="csv" translatable="false">CSV</string>
<string name="orgmode" translatable="false">OrgMode</string>
Expand Down

0 comments on commit 27626eb

Please sign in to comment.