diff --git a/app_pojavlauncher/src/main/java/com/kdt/mcgui/mcAccountSpinner.java b/app_pojavlauncher/src/main/java/com/kdt/mcgui/mcAccountSpinner.java
index 04665f384..ffe842589 100644
--- a/app_pojavlauncher/src/main/java/com/kdt/mcgui/mcAccountSpinner.java
+++ b/app_pojavlauncher/src/main/java/com/kdt/mcgui/mcAccountSpinner.java
@@ -83,7 +83,7 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
};
private final DoneListener mDoneListener = account -> {
- Toast.makeText(getContext(), "Login done", Toast.LENGTH_SHORT).show();
+ Toast.makeText(getContext(), R.string.main_login_done, Toast.LENGTH_SHORT).show();
mSelectecAccount = account;
invalidate();
mAccountList.add(account.username);
@@ -220,7 +220,7 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
if(fromFiles){
mAccountList.clear();
- mAccountList.add("Add account");
+ mAccountList.add(getContext().getString(R.string.main_add_account));
File accountFolder = new File(Tools.DIR_ACCOUNT_NEW);
if(accountFolder.exists()){
for (String fileName : accountFolder.list()) {
diff --git a/app_pojavlauncher/src/main/java/com/kdt/pickafile/DialogTitleListener.java b/app_pojavlauncher/src/main/java/com/kdt/pickafile/DialogTitleListener.java
new file mode 100644
index 000000000..1e1ddb4a8
--- /dev/null
+++ b/app_pojavlauncher/src/main/java/com/kdt/pickafile/DialogTitleListener.java
@@ -0,0 +1,5 @@
+package com.kdt.pickafile;
+
+public interface DialogTitleListener {
+ void onChangeDialogTitle(String newTitle);
+}
diff --git a/app_pojavlauncher/src/main/java/com/kdt/pickafile/FileListView.java b/app_pojavlauncher/src/main/java/com/kdt/pickafile/FileListView.java
index 0bcf8b176..b48619207 100644
--- a/app_pojavlauncher/src/main/java/com/kdt/pickafile/FileListView.java
+++ b/app_pojavlauncher/src/main/java/com/kdt/pickafile/FileListView.java
@@ -3,9 +3,8 @@ package com.kdt.pickafile;
import androidx.appcompat.app.*;
import android.content.*;
import android.util.*;
-import android.view.*;
import android.widget.*;
-import android.widget.AdapterView.*;
+
import com.ipaulpro.afilechooser.*;
import java.io.*;
import java.util.*;
@@ -15,14 +14,14 @@ import android.os.*;
public class FileListView extends LinearLayout
{
//For list view:
- private String fullPath;
+ private File fullPath;
private ListView mainLv;
private Context context;
//For File selected listener:
- private FileSelectedListener listener;
- private AlertDialog build;
- private String lockPath = "/";
+ private FileSelectedListener fileSelectedListener;
+ private DialogTitleListener dialogTitleListener;
+ private File lockPath = new File("/");
//For filtering by file types:
private final String[] fileSuffixes;
@@ -31,17 +30,17 @@ public class FileListView extends LinearLayout
public FileListView(AlertDialog build) {
this(build.getContext(), null, new String[0]);
- this.build = build;
+ dialogToTitleListener(build);
}
public FileListView(AlertDialog build, String fileSuffix) {
this(build.getContext(), null, new String[]{fileSuffix});
- this.build = build;
+ dialogToTitleListener(build);
}
public FileListView(AlertDialog build, String[] fileSuffixes){
this(build.getContext(), null, fileSuffixes);
- this.build = build;
+ dialogToTitleListener(build);
}
public FileListView(Context context){
@@ -62,11 +61,15 @@ public class FileListView extends LinearLayout
init(context);
}
+ private void dialogToTitleListener(AlertDialog dialog) {
+ if(dialog != null) dialogTitleListener = dialog::setTitle;
+ }
+
public void init(final Context context) {
//Main setup:
this.context = context;
- LayoutParams layParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
+ LayoutParams layParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
setOrientation(VERTICAL);
@@ -78,7 +81,7 @@ public class FileListView extends LinearLayout
if (p3 == 0 && !lockPath.equals(fullPath)) {
parentDir();
} else {
- listFileAt(mainFile.getAbsolutePath());
+ listFileAt(mainFile);
}
});
@@ -86,7 +89,7 @@ public class FileListView extends LinearLayout
// TODO: Implement this method
File mainFile = new File(p1.getItemAtPosition(p3).toString());
if (mainFile.isFile()) {
- listener.onFileLongClick(mainFile, mainFile.getAbsolutePath());
+ fileSelectedListener.onFileLongClick(mainFile, mainFile.getAbsolutePath());
return true;
}
return false;
@@ -94,22 +97,24 @@ public class FileListView extends LinearLayout
addView(mainLv, layParam);
try {
- listFileAt(Environment.getExternalStorageDirectory().getAbsolutePath());
+ listFileAt(Environment.getExternalStorageDirectory());
} catch (NullPointerException e) {} // Android 10+ disallows access to sdcard
}
public void setFileSelectedListener(FileSelectedListener listener)
{
- this.listener = listener;
+ this.fileSelectedListener = listener;
+ }
+ public void setDialogTitleListener(DialogTitleListener listener) {
+ this.dialogTitleListener = listener;
}
- public void listFileAt(final String path) {
+ public void listFileAt(final File path) {
try{
- final File mainPath = new File(path);
- if(mainPath.exists()){
- if(mainPath.isDirectory()){
+ if(path.exists()){
+ if(path.isDirectory()){
fullPath = path;
- File[] listFile = mainPath.listFiles();
+ File[] listFile = path.listFiles();
FileListAdapter fileAdapter = new FileListAdapter(context);
if(!path.equals(lockPath)){
fileAdapter.add(new File(path, ".."));
@@ -140,9 +145,9 @@ public class FileListView extends LinearLayout
}
}
mainLv.setAdapter(fileAdapter);
- if (build != null) build.setTitle(new File(path).getName());
+ if(dialogTitleListener != null) dialogTitleListener.onChangeDialogTitle(path.getAbsolutePath());
} else {
- listener.onFileSelected(mainPath, path);
+ fileSelectedListener.onFileSelected(path, path.getAbsolutePath());
}
} else {
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
@@ -153,7 +158,7 @@ public class FileListView extends LinearLayout
}
}
- public String getFullPath(){
+ public File getFullPath(){
return fullPath;
}
@@ -162,13 +167,12 @@ public class FileListView extends LinearLayout
}
public void parentDir() {
- File pathFile = new File(fullPath);
- if(!pathFile.getAbsolutePath().equals("/")){
- listFileAt(pathFile.getParent());
+ if(!fullPath.getAbsolutePath().equals("/")){
+ listFileAt(fullPath.getParentFile());
}
}
- public void lockPathAt(String path) {
+ public void lockPathAt(File path) {
lockPath = path;
listFileAt(path);
}
diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/CustomControlsActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/CustomControlsActivity.java
index 2a8d68a80..e7611ed67 100644
--- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/CustomControlsActivity.java
+++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/CustomControlsActivity.java
@@ -120,7 +120,7 @@ public class CustomControlsActivity extends BaseActivity {
final AlertDialog dialog = builder.create();
FileListView flv = new FileListView(dialog, "json");
- flv.lockPathAt(Tools.CTRLMAP_PATH);
+ flv.lockPathAt(new File(Tools.CTRLMAP_PATH));
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
@@ -200,8 +200,8 @@ public class CustomControlsActivity extends BaseActivity {
final AlertDialog dialog = builder.create();
FileListView flv = new FileListView(dialog, "json");
- if(Build.VERSION.SDK_INT < 29)flv.listFileAt(Tools.CTRLMAP_PATH);
- else flv.lockPathAt(Tools.CTRLMAP_PATH);
+ if(Build.VERSION.SDK_INT < 29)flv.listFileAt(new File(Tools.CTRLMAP_PATH));
+ else flv.lockPathAt(new File(Tools.CTRLMAP_PATH));
flv.setFileSelectedListener(new FileSelectedListener(){
@Override
diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/FileSelectorFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/FileSelectorFragment.java
index 23edeb3f2..7cb262746 100644
--- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/FileSelectorFragment.java
+++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/FileSelectorFragment.java
@@ -1,13 +1,13 @@
package net.kdt.pojavlaunch.fragments;
import android.app.AlertDialog;
-import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -31,6 +31,7 @@ public class FileSelectorFragment extends Fragment {
private Button mSelectFolderButton, mCreateFolderButton;
private FileListView mFileListView;
+ private TextView mFilePathView;
private boolean mSelectFolder = true;
private boolean mShowFiles = true;
@@ -48,23 +49,26 @@ public class FileSelectorFragment extends Fragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
bindViews(view);
parseBundle();
+ if(!mSelectFolder) mSelectFolderButton.setVisibility(View.GONE);
+ else mSelectFolderButton.setVisibility(View.VISIBLE);
mFileListView.setShowFiles(mShowFiles);
mFileListView.setShowFolders(mShowFolders);
- mFileListView.lockPathAt(mRootPath);
+ mFileListView.lockPathAt(new File(mRootPath));
+ mFileListView.setDialogTitleListener((title)->mFilePathView.setText(removeLockPath(title)));
mFileListView.refreshPath();
mCreateFolderButton.setOnClickListener(v -> {
final EditText editText = new EditText(getContext());
new AlertDialog.Builder(getContext())
- .setTitle("Insert folder name")
+ .setTitle(R.string.folder_dialog_insert_name)
.setView(editText)
.setNegativeButton(android.R.string.cancel, null)
- .setPositiveButton("Create", (dialog, which) -> {
+ .setPositiveButton(R.string.folder_dialog_create, (dialog, which) -> {
File folder = new File(mFileListView.getFullPath(), editText.getText().toString());
boolean success = folder.mkdir();
if(success){
- mFileListView.listFileAt(mFileListView.getFullPath() + "/" + editText.getText().toString());
+ mFileListView.listFileAt(new File(mFileListView.getFullPath(),editText.getText().toString()));
}else{
mFileListView.refreshPath();
}
@@ -72,7 +76,7 @@ public class FileSelectorFragment extends Fragment {
});
mSelectFolderButton.setOnClickListener(v -> {
- ExtraCore.setValue(ExtraConstants.FILE_SELECTOR, removeLockPath(mFileListView.getFullPath()));
+ ExtraCore.setValue(ExtraConstants.FILE_SELECTOR, removeLockPath(mFileListView.getFullPath().getAbsolutePath()));
Tools.removeCurrentFragment(requireActivity());
});
@@ -86,7 +90,7 @@ public class FileSelectorFragment extends Fragment {
}
private String removeLockPath(String path){
- return path.replace(mRootPath, "");
+ return path.replace(mRootPath, ".");
}
private void parseBundle(){
@@ -102,5 +106,6 @@ public class FileSelectorFragment extends Fragment {
mSelectFolderButton = view.findViewById(R.id.file_selector_select_folder);
mCreateFolderButton = view.findViewById(R.id.file_selector_create_folder);
mFileListView = view.findViewById(R.id.file_selector);
+ mFilePathView = view.findViewById(R.id.file_selector_current_path);
}
}
diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/ProfileEditorFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/ProfileEditorFragment.java
index 944ca99b1..1f1255ac1 100644
--- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/ProfileEditorFragment.java
+++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/ProfileEditorFragment.java
@@ -102,6 +102,7 @@ public class ProfileEditorFragment extends Fragment {
Bundle bundle = new Bundle(2);
bundle.putBoolean(FileSelectorFragment.BUNDLE_SELECT_FOLDER, true);
bundle.putString(FileSelectorFragment.BUNDLE_ROOT_PATH, Tools.DIR_GAME_HOME);
+ bundle.putBoolean(FileSelectorFragment.BUNDLE_SHOW_FILE, false);
mValueToConsume = FileSelectorFragment.BUNDLE_SELECT_FOLDER;
Tools.swapFragment(requireActivity(),
diff --git a/app_pojavlauncher/src/main/res/layout/fragment_file_selector.xml b/app_pojavlauncher/src/main/res/layout/fragment_file_selector.xml
index 30adf29c6..c2254e614 100644
--- a/app_pojavlauncher/src/main/res/layout/fragment_file_selector.xml
+++ b/app_pojavlauncher/src/main/res/layout/fragment_file_selector.xml
@@ -11,8 +11,9 @@
android:layout_width="match_parent"
android:layout_height="0dp"
+ android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@id/file_selector_create_folder"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toBottomOf="@+id/file_selector_current_path" />
+
+
\ No newline at end of file
diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml
index b6ff16e6f..44b71130d 100644
--- a/app_pojavlauncher/src/main/res/values/strings.xml
+++ b/app_pojavlauncher/src/main/res/values/strings.xml
@@ -312,4 +312,8 @@
%d tasks in progress
Terminate
The game is running!
+ Create
+ Insert folder name
+ Login done
+ Add account