Allow empty files to be opened in editor (#33)

This commit is contained in:
Akash Yadav
2022-01-02 10:16:19 +05:30
parent e57607c51d
commit 4e524787b6
3 changed files with 12 additions and 3 deletions
@@ -220,7 +220,7 @@ public class EditorActivity extends StudioActivity implements FileTreeFragment.F
mFileTreeFragment = FileTreeFragment.newInstance (this.mProject).setFileActionListener (this);
mDaemonStatusFragment = new TextSheetFragment ().setTextSelectable (true);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle (this, mBinding.editorDrawerLayout, mBinding.editorToolbar, R.string.app_name, R.string.app_name);
mBinding.editorDrawerLayout.setDrawerListener (toggle);
mBinding.editorDrawerLayout.addDrawerListener (toggle);
mBinding.startNav.setNavigationItemSelectedListener (this);
toggle.syncState ();
loadFragment (mFileTreeFragment);
@@ -92,7 +92,7 @@ public class FileTreeFragment extends BottomSheetDialogFragment implements TreeN
public void onClick(TreeNode node, Object p2) {
final File f = (File) p2;
if(f.isFile()) {
if (mFileActionListener != null && FileUtils.isUtf8(f)) {
if (mFileActionListener != null && (FileUtils.isUtf8 (f) || f.length () == 0)) {
mFileActionListener.openFile(f);
}
} else if(f.isDirectory() && f.exists()) {
@@ -22,6 +22,14 @@ import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ThrowableUtils;
import org.jetbrains.annotations.Contract;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
/**
* Logger for the IDE.
*
@@ -54,6 +62,7 @@ public class Logger {
private Logger(String tag) {
TAG = tag;
}
public Logger warn(Object... messages) {
@@ -95,7 +104,7 @@ public class Logger {
msg);
sb.append(MSG_SEPARATOR);
}
return sb.toString();
}
}