Skip to content

Commit 57e9447

Browse files
committed
Fixes for refreshing fragments on File/Directory selections
1 parent d375274 commit 57e9447

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

java/src/main/java/org/astonbitecode/rustkeylock/fragments/FileSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void onListItemClick(ListView l, View v, int pos, long id) {
8484

8585
@Override
8686
public void onClick(View view) {
87-
Log.d(TAG, "Selected File " + selectedFileName);
87+
Log.d(TAG, "Returning File " + selectedFileName);
8888
Intent intent = new Intent(getActivity(), this.getClass());
8989
intent.putExtra("file", selectedFileName);
9090
getTargetFragment().onActivityResult(getTargetRequestCode(), 0, intent);

java/src/main/java/org/astonbitecode/rustkeylock/fragments/SelectPath.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class SelectPath extends Fragment implements BackButtonHandler, OnClickLi
3232
private transient EditText editFileName;
3333
private transient EditText editPassword;
3434
private transient EditText editNumber;
35-
private String workingDirectoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
35+
private String workingDirectoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
36+
.getAbsolutePath();
3637
private String filename = new SimpleDateFormat("yyyyMMdd_HHmm").format(new Date()) + "_rust_keylock";
3738
private int FRAGMENT_CODE_DIR = 11;
3839
private int FRAGMENT_CODE_FILE = 33;
@@ -61,6 +62,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6162
return rootView;
6263
}
6364

65+
@Override
66+
public void onResume() {
67+
if (this.editFileName != null) {
68+
this.editFileName.setText(filename);
69+
}
70+
if (this.editPath != null) {
71+
this.editPath.setText(workingDirectoryPath);
72+
}
73+
super.onResume();
74+
}
75+
6476
private void initialize(View view) {
6577
TextView title = (TextView) view.findViewById(R.id.selectPathLabel);
6678
if (export) {
@@ -80,7 +92,6 @@ private void initialize(View view) {
8092
this.editPath = editPath;
8193

8294
EditText editFilename = (EditText) view.findViewById(R.id.editFileName);
83-
filename = export ? filename : "";
8495
editFilename.setText(filename);
8596
editFilename.setEnabled(export);
8697
this.editFileName = editFilename;
@@ -142,10 +153,15 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
142153
backButtonHandler = this;
143154
super.onActivityResult(requestCode, resultCode, data);
144155
if (requestCode == FRAGMENT_CODE_DIR) {
156+
Log.d(TAG, "Directory selector returned " + data.getStringExtra("directory"));
145157
workingDirectoryPath = data.getStringExtra("directory");
146158
filename = export ? filename : "";
147159
} else if (requestCode == FRAGMENT_CODE_FILE) {
160+
Log.d(TAG, "File selector returned " + data.getStringExtra("file"));
148161
filename = data.getStringExtra("file");
162+
} else {
163+
Log.d(TAG, "Unhandled selector request code '" + requestCode
164+
+ "'. Please consider opening a bug to the developers.");
149165
}
150166
}
151167

0 commit comments

Comments
 (0)