Skip to content

Commit

Permalink
v250; Release
Browse files Browse the repository at this point in the history
  • Loading branch information
donmor committed Feb 17, 2024
1 parent dc11dc8 commit d0827a2
Show file tree
Hide file tree
Showing 50 changed files with 412 additions and 1,305 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
/app/release
.cxx
/app/src/main/lint.xml
devkey.jks
*.jks
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
minSdkVersion 21
targetSdkVersion 34
multiDexEnabled true
versionCode 47
versionName "2.5.0a2"
versionCode 48
versionName "2.5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
tools:targetApi="s">
<activity
android:name=".MainActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:hardwareAccelerated="true"
Expand All @@ -49,6 +48,7 @@
</activity>
<activity
android:name=".TWEditorWV"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
Expand All @@ -59,7 +59,6 @@
android:foregroundServiceType="dataSync" />
<activity
android:name=".HandlerActivity"
android:alwaysRetainTaskState="true"
android:exported="true"
android:label="@string/entry_name">
<intent-filter>
Expand Down
118 changes: 23 additions & 95 deletions app/src/main/java/top/donmor/tiddloid/FileDialogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,17 @@ class FileDialogAdapter extends RecyclerView.Adapter<FileDialogAdapter.FileViewH

private File currentDir;
private final File rootDir;
// private boolean[] selected;
private File[] files, dirs, devices;
private boolean enRoot;
private final boolean dirOnly, showHidden, ignoreReadOnly;
// private final boolean multiSelect, dirOnly, showHidden, ignoreReadOnly;
// private int filterIndex;
private boolean showHidden;
private final Context context;
// private final MimeTypeMap mimeTypeMap;
// final String[] mimeTypes;
private final FileDialogFilter filter;
// final FileDialogFilter[] filters;
private final LayoutInflater inflater;

FileDialogAdapter(Context context, FileDialogFilter filter, File dir, boolean dirOnly, boolean showHidden, boolean ignoreReadOnly) {
// FileDialogAdapter(Context context, FileDialogFilter[] filters, int filterIndex, String[] mimeTypes, MimeTypeMap mimeTypeMap, File dir, boolean multiSelect, boolean dirOnly, boolean showHidden, boolean ignoreReadOnly) {
FileDialogAdapter(Context context, FileDialogFilter filter, File dir) {
this.context = context;
// this.multiSelect = multiSelect;
this.dirOnly = dirOnly;
this.showHidden = showHidden;
this.ignoreReadOnly = ignoreReadOnly;
// this.mimeTypeMap = mimeTypeMap;
// this.mimeTypes = mimeTypes;
this.showHidden = false;
this.filter = filter;
// this.filters = filters;
// this.filterIndex = filterIndex;
inflater = LayoutInflater.from(context);
try {
currentDir = dir;
Expand All @@ -57,21 +43,17 @@ class FileDialogAdapter extends RecyclerView.Adapter<FileDialogAdapter.FileViewH
rootDir = Environment.getExternalStorageDirectory();
enRoot = false;
dirs = sortFile(getDirs());
if (dirOnly) files = new File[0];
else files = sortFile(getFiles());
// if (files != null) selected = new boolean[files.length];
devices = FileDialogOpen.getStorage(context.getApplicationContext(), ignoreReadOnly);
files = sortFile(getFiles());
devices = FileDialogOpen.getStorage(context.getApplicationContext());
}

static class FileViewHolder extends RecyclerView.ViewHolder {
private final Button cbD, cbF, cbR;
// private final CheckBox cbMF;

FileViewHolder(View itemView) {
super(itemView);
cbD = itemView.findViewById(R.id.c_buttonD);
cbF = itemView.findViewById(R.id.c_buttonF);
// cbMF = itemView.findViewById(R.id.c_buttonMF);
cbR = itemView.findViewById(R.id.c_buttonR);
}
}
Expand All @@ -95,27 +77,13 @@ public void onBindViewHolder(@NonNull FileViewHolder holder, int position) {
holder.cbD.setVisibility(View.VISIBLE);
}
} else if (pos < dirs.length + files.length) {
// if (multiSelect) {
// holder.cbMF.setText(files[pos - dirs.length].getName());
// holder.cbMF.setChecked(false);
// holder.cbMF.setVisibility(View.VISIBLE);
// } else {
holder.cbF.setText(files[pos - dirs.length].getName());
holder.cbF.setVisibility(View.VISIBLE);
// }
holder.cbF.setText(files[pos - dirs.length].getName());
holder.cbF.setVisibility(View.VISIBLE);
}
}
View.OnClickListener ocl = v -> mItemClickListener.onItemClick(pos);
// CompoundButton.OnCheckedChangeListener orl = new CompoundButton.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// selected[pos - dirs.length] = isChecked;
// mItemClickListener.onItemClick(pos);
// }
// };
holder.cbD.setOnClickListener(ocl);
holder.cbF.setOnClickListener(ocl);
// holder.cbMF.setOnCheckedChangeListener(orl);
holder.cbR.setOnClickListener(ocl);
}

Expand All @@ -137,7 +105,7 @@ public int getItemViewType(int position) {

private ItemClickListener mItemClickListener;

public interface ItemClickListener {
interface ItemClickListener {
void onItemClick(int position);
}

Expand All @@ -146,22 +114,24 @@ void setOnItemClickListener(ItemClickListener itemClickListener) {

}

/**
* @noinspection SameParameterValue
*/
void setShowHidden(boolean val) {
this.showHidden = val;
setDir(currentDir);
}

boolean getShowHidden() {
return this.showHidden;
}

private File[] getDirs() {
return currentDir.listFiles(pathname -> (!pathname.isHidden() || showHidden) && pathname.isDirectory());
}

private File[] getFiles() {
return currentDir.listFiles(pathname -> {
// if (mimeTypes != null)
// if ((!pathname.isHidden() || showHidden) && pathname.isFile())
// if (mimeTypes[filterIndex].equals(TWEditorWV.MIME_ANY)) return true;
// else
// return mimeTypes[filterIndex].equals(mimeTypeMap.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(pathname.getName())));
// else return false;
// else
// return (!pathname.isHidden() || showHidden) && pathname.isFile() && filters[filterIndex].meetExtensions(pathname.getName());
return (!pathname.isHidden() || showHidden) && pathname.isFile() && filter.meetExtensions(pathname.getName());
});
return currentDir.listFiles(pathname -> (!pathname.isHidden() || showHidden) && pathname.isFile() && filter.meetExtensions(pathname.getName()));
}

private File[] sortFile(File[] src) {
Expand All @@ -188,14 +158,6 @@ private boolean chrSort(String s1, String s2) {
return false;
}

// void setFilterIndex(int index) {
// filterIndex = index;
// }

// int getFilterIndex() {
// return filterIndex;
// }

File getFile(int position) {
if (enRoot) return devices[position];
else {
Expand All @@ -207,30 +169,10 @@ File getFile(int position) {
}
}

// File[] getSelectedFiles() {
// if (enRoot) return new File[0];
// else {
// File[] files1 = new File[files.length];
// int i = 0;
// for (int j = 0; j < selected.length; j++)
// if (selected[j]) {
// files1[i] = files[j];
// i++;
// }
// File[] files2 = new File[i];
// System.arraycopy(files1, 0, files2, 0, i);
// return files2;
// }
// }

File[] getDevices() {
return devices;
}

// File getCurrentDir() {
// return currentDir;
// }

File getRootDir() {
return rootDir;
}
Expand All @@ -252,27 +194,13 @@ void setDir(File dir) {
currentDir = rootDir;
}
dirs = sortFile(getDirs());
if (dirOnly) files = new File[0];
else files = sortFile(getFiles());
// if (files != null) selected = new boolean[files.length];
files = sortFile(getFiles());
enRoot = false;
}

void setRoot() {
devices = FileDialogOpen.getStorage(context.getApplicationContext(), ignoreReadOnly);
// selected = new boolean[0];
devices = FileDialogOpen.getStorage(context.getApplicationContext());
enRoot = true;
}

// void reload() {
// if (!enRoot) {
// dirs = sortFile(getDirs());
// if (dirOnly) files = new File[0];
// else files = sortFile(getFiles());
//// if (files != null) selected = new boolean[files.length];
// } else {
// devices = FileDialogOpen.getStorage(context.getApplicationContext(), ignoreReadOnly);
//// selected = new boolean[0];
// }
// }
}
5 changes: 0 additions & 5 deletions app/src/main/java/top/donmor/tiddloid/FileDialogFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* The File type filter for FileDialogOpen.
*/
class FileDialogFilter {
// /**
// * The name of the filter.
// */
// public final String name;
/**
* The extension names related.
*/
Expand All @@ -27,7 +23,6 @@ class FileDialogFilter {
* @param extensions The extensions array. It should be formatted like { ".extension1", ".extension2", ... }. The extension can be like ".ext1.ext2". Use { "*" } for all types. The first extension in array will be used as default to create new files.
*/
FileDialogFilter(String[] extensions) {
// this.name = name;
this.extensions = extensions;
}

Expand Down
Loading

0 comments on commit d0827a2

Please sign in to comment.