diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b1b2363..d89ad3c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -35,11 +35,8 @@ android { release{ isMinifyEnabled = false isShrinkResources = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - signingConfig = signingConfigs.getByName("release") + signingConfig = signingConfigs.getByName("release") + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") //returning for now } } compileOptions { @@ -66,6 +63,7 @@ dependencies { implementation(libs.transition) implementation(libs.fragment) implementation(libs.activity) + implementation(project(":filetree")) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..bc00987 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,10 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-keep public class * extends com.sparkleseditor.fragments.BaseFragment +-keep class com.sparkleseditor.fragments.** { *; } +-keep class com.zyron.filetree.** { *; } +-dontwarn com.zyron.filetree.** +-keep class com.sparkleseditor.MainActivity { *; } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9cc8bfe..002c7f0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,10 @@ + + + + folderPickerLauncher = + registerForActivityResult( + new ActivityResultContracts.OpenDocumentTree(), + treeUri -> { + if (treeUri == null) return; + + int flags = Intent.FLAG_GRANT_READ_URI_PERMISSION | + Intent.FLAG_GRANT_WRITE_URI_PERMISSION; + + requireContext().getContentResolver() + .takePersistableUriPermission(treeUri, flags); + + path = getRealPathFromUri(treeUri); + setupFileTree(); + Toast.makeText(requireContext(), "Folder selected!", Toast.LENGTH_LONG).show(); + + } + ); + private String getRealPathFromUri(Uri treeUri) { + String docId = DocumentsContract.getTreeDocumentId(treeUri); + String[] split = docId.split(":"); + String type = split[0]; + String relativePath = split.length > 1 ? split[1] : ""; + if ("primary".equalsIgnoreCase(type)) { + return Environment.getExternalStorageDirectory() + "/" + relativePath; + } else { + String externalStorage = System.getenv("SECONDARY_STORAGE"); + if (externalStorage == null) { + externalStorage = System.getenv("EXTERNAL_STORAGE"); + } + return externalStorage + "/" + relativePath; + } + } private FragmentMainBinding binding; + private FileTreeIconProvider fileIconProvider; + private String path =""; + + private static final int REQUEST_CODE_OPEN_DIRECTORY = 1001; public static final String[] SYMBOLS = { "TAB","↵", "{", "}", "(", ")", @@ -39,6 +94,11 @@ public class MainFragment extends BaseFragment { ">", "[", "]", ":" }; + public interface FileTreeEventListener { + void onFileClick(File file); + void onFolderClick(File folder); + } + @Override public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container, @@ -52,14 +112,50 @@ public View onCreateView( public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + + //AppStruct setupToolbar(); setupToolbox(); setupInputView(); setupTabLayoutTemp(); slideXDrawer(); + drawerLeftContent(); binding.fab.setTranslationY(-12); + } + private void drawerLeftContent() { + + binding.fileTree.setVisibility(View.VISIBLE); + binding.contentGit.setVisibility(View.GONE); + binding.btmOptions.setOnNavigationItemSelectedListener( + item -> { + var sharedAxis = new MaterialSharedAxis(MaterialSharedAxis.X, true); + TransitionManager.beginDelayedTransition(binding.container, sharedAxis); + if (item.getItemId() == R.id.option_file_tree) { + binding.contentGit.setVisibility(View.GONE); + binding.fileTree.setVisibility(View.VISIBLE); + } else if (item.getItemId() == R.id.option_git) { + binding.contentGit.setVisibility(View.VISIBLE); + binding.fileTree.setVisibility(View.GONE); + } + return true; + } + ); + setupFileTree(); + } + private void setupFileTree() { + if (path != null && !path.isEmpty()) { + binding.contentFileTree.setVisibility(View.VISIBLE); + binding.requireFolder.setVisibility(View.GONE); + binding.fileTreeView.initializeFileTree(path, this , fileIconProvider); + }else{ + binding.contentFileTree.setVisibility(View.GONE); + binding.requireFolder.setVisibility(View.VISIBLE); + binding.openFolder.setOnClickListener(v -> { + folderPickerLauncher.launch(null); + }); + } } private void slideXDrawer() { @@ -189,6 +285,27 @@ public void onDestroyView() { binding = null; } + public void onFileClick(File file) { + } + + + public void onFolderClick(File folder) {} + + + public boolean onFileLongClick(File file) { + return true; + } + + + public boolean onFolderLongClick(File folder) { + + return true; + } + + + public void onFileTreeViewUpdated(int startPosition, int itemCount) {} + + diff --git a/app/src/main/res/drawable/git_24px.xml b/app/src/main/res/drawable/git_24px.xml new file mode 100755 index 0000000..c7f0c5a --- /dev/null +++ b/app/src/main/res/drawable/git_24px.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_folder_rounded_filled_24dp.xml b/app/src/main/res/drawable/ic_folder_rounded_filled_24dp.xml new file mode 100644 index 0000000..5923958 --- /dev/null +++ b/app/src/main/res/drawable/ic_folder_rounded_filled_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_open_rounded_filled_24dp.xml b/app/src/main/res/drawable/ic_menu_open_rounded_filled_24dp.xml new file mode 100644 index 0000000..b861603 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_open_rounded_filled_24dp.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index aa44cb8..cab4aa3 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -133,14 +133,127 @@ app:srcCompat="@drawable/ic_play_arrow_rounded_filled_24dp" /> - + android:id="@+id/left_drawer_menu"> + + + + + +