mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Proper filename retrieval support
This commit is contained in:
parent
a6df620b0f
commit
6761e487b2
@ -2,18 +2,16 @@ package net.kdt.pojavlaunch;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.kdt.pojavlaunch.customcontrols.CustomControls;
|
||||
import net.kdt.pojavlaunch.customcontrols.LayoutConverter;
|
||||
import net.kdt.pojavlaunch.utils.FileUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -65,10 +63,7 @@ public class ImportControlActivity extends Activity {
|
||||
if(!mHasIntentChanged) return;
|
||||
mIsFileVerified = false;
|
||||
getUriData();
|
||||
//Set the name of the file in the editText.
|
||||
String editTextString = mUriData.toString().replaceAll("%..", "/");
|
||||
editTextString = editTextString.substring(editTextString.lastIndexOf('/') + 1);
|
||||
mEditText.setText(trimFileName(editTextString));
|
||||
mEditText.setText(getNameFromURI(mUriData));
|
||||
mHasIntentChanged = false;
|
||||
|
||||
//Import and verify thread
|
||||
@ -188,4 +183,12 @@ public class ImportControlActivity extends Activity {
|
||||
|
||||
}
|
||||
|
||||
public String getNameFromURI(Uri uri) {
|
||||
Cursor c = getContentResolver().query(uri, null, null, null, null);
|
||||
c.moveToFirst();
|
||||
String fileName = c.getString(c.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||
c.close();
|
||||
return trimFileName(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user