Compare commits

...

1 Commits

Author SHA1 Message Date
3b2396395f feat: 경로 직접 입력 및 이동 기능 구현 2026-01-05 01:37:05 +09:00

View File

@@ -1,16 +1,10 @@
package be.gyu.android.file.explorer;
// ... (imports)
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.navigation.NavigationView;
import androidx.appcompat.app.ActionBarDrawerToggle;
import android.view.SubMenu;
public class MainActivity extends AppCompatActivity implements FileAdapter.OnItemClickListener, FileAdapter.OnItemLongClickListener, NavigationView.OnNavigationItemSelectedListener {
public class MainActivity extends AppCompatActivity /* ... (implements) */ {
// ... (other variables)
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle drawerToggle;
// ... (variables)
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -19,57 +13,51 @@ public class MainActivity extends AppCompatActivity implements FileAdapter.OnIte
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
drawerLayout = findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
setupDrawerContent(navigationView);
// Add click listener to toolbar to edit path
toolbar.setOnClickListener(v -> showPathEditDialog());
// ... (rest of onCreate)
}
private void setupDrawerContent(NavigationView navigationView) {
Menu menu = navigationView.getMenu();
SubMenu storageMenu = menu.findItem(R.id.group_storage).getSubMenu();
storageMenu.clear();
private void showPathEditDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Go to Path");
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
List<StorageVolume> storageVolumes = storageManager.getStorageVolumes();
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);
// Set current path as default text
if (isRemoteMode) {
input.setText(currentRemotePath);
} else {
input.setText(currentDirectory.getAbsolutePath());
}
builder.setView(input);
for (int i = 0; i < storageVolumes.size(); i++) {
StorageVolume volume = storageVolumes.get(i);
if (volume.getState().equals(Environment.MEDIA_MOUNTED)) {
File path = volume.getDirectory();
if (path != null) {
MenuItem item = storageMenu.add(Menu.NONE, i, Menu.NONE, volume.getDescription(this));
item.setIcon(R.drawable.ic_storage);
item.setOnMenuItemClickListener(menuItem -> {
loadFiles(path);
drawerLayout.closeDrawers();
return true;
});
}
builder.setPositiveButton("Go", (dialog, which) -> {
String newPath = input.getText().toString();
navigateToPath(newPath);
});
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
builder.show();
}
private void navigateToPath(String path) {
if (path == null || path.isEmpty()) return;
if (isRemoteMode) {
loadFtpFiles(path);
} else {
File newDir = new File(path);
if (newDir.exists() && newDir.isDirectory()) {
loadFiles(newDir);
} else {
Toast.makeText(this, "Path not found or not a directory.", Toast.LENGTH_SHORT).show();
}
}
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.nav_remote_storage) {
Intent intent = new Intent(this, RemoteStorageActivity.class);
startActivity(intent);
}
drawerLayout.closeDrawers();
return true;
}
// Need to add string resources for drawer_open and drawer_close
// ... (rest of MainActivity)
}