Merge pull request #9225 from JosJuice/android-convertfragment-path

Android: Rename path variable in ConvertFragment
This commit is contained in:
LC 2020-11-09 02:16:59 -05:00 committed by GitHub
commit a9ef7e0e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -361,30 +361,30 @@ public class ConvertFragment extends Fragment implements View.OnClickListener
{ {
String originalPath = gameFile.getPath(); String originalPath = gameFile.getPath();
StringBuilder path = new StringBuilder(new File(originalPath).getName()); StringBuilder filename = new StringBuilder(new File(originalPath).getName());
int dotIndex = path.lastIndexOf("."); int dotIndex = filename.lastIndexOf(".");
if (dotIndex != -1) if (dotIndex != -1)
path.setLength(dotIndex); filename.setLength(dotIndex);
switch (mFormat.getValue(requireContext())) switch (mFormat.getValue(requireContext()))
{ {
case BLOB_TYPE_PLAIN: case BLOB_TYPE_PLAIN:
path.append(".iso"); filename.append(".iso");
break; break;
case BLOB_TYPE_GCZ: case BLOB_TYPE_GCZ:
path.append(".gcz"); filename.append(".gcz");
break; break;
case BLOB_TYPE_WIA: case BLOB_TYPE_WIA:
path.append(".wia"); filename.append(".wia");
break; break;
case BLOB_TYPE_RVZ: case BLOB_TYPE_RVZ:
path.append(".rvz"); filename.append(".rvz");
break; break;
} }
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/octet-stream"); intent.setType("application/octet-stream");
intent.putExtra(Intent.EXTRA_TITLE, path.toString()); intent.putExtra(Intent.EXTRA_TITLE, filename.toString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, originalPath); intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, originalPath);
startActivityForResult(intent, REQUEST_CODE_SAVE_FILE); startActivityForResult(intent, REQUEST_CODE_SAVE_FILE);