GUI: mobile file dialog improvements, part 2
This commit is contained in:
parent
4e88a677d0
commit
4daf959f15
2 changed files with 66 additions and 2 deletions
|
|
@ -2,12 +2,14 @@ package org.tildearrow.furnace;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
public class MainActivity extends SDLActivity {
|
||||
static final int TA_FILE_REQUEST=1000;
|
||||
static final int TA_FILE_SAVE_REQUEST=1001;
|
||||
|
||||
public void showFileDialog() {
|
||||
Intent picker=new Intent(Intent.ACTION_GET_CONTENT);
|
||||
|
|
@ -16,12 +18,22 @@ public class MainActivity extends SDLActivity {
|
|||
startActivityForResult(picker,TA_FILE_REQUEST);
|
||||
}
|
||||
|
||||
public void showSaveFileDialog() {
|
||||
Intent picker=new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
picker.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
picker.setType("*/*");
|
||||
|
||||
startActivityForResult(picker,TA_FILE_SAVE_REQUEST);
|
||||
}
|
||||
|
||||
@Override protected void onActivityResult(int request, int result, Intent intent) {
|
||||
super.onActivityResult(request,result,intent);
|
||||
if (request==TA_FILE_REQUEST) {
|
||||
if (result==RESULT_OK) {
|
||||
Uri path=intent.getData();
|
||||
|
||||
Context context=getApplicationContext();
|
||||
Toast toast=Toast.makeText(context,"Got a file",Toast.LENGTH_SHORT);
|
||||
Toast toast=Toast.makeText(context,path.toString(),Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue