Try to force file chooser to show internal/external storage by default

This commit is contained in:
Torsten Grote
2021-06-24 17:13:21 -03:00
parent 3f2ac528c1
commit 032f56ad67
2 changed files with 24 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package org.briarproject.briar.android.removabledrive; package org.briarproject.briar.android.removabledrive;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -27,6 +28,7 @@ import androidx.lifecycle.ViewModelProvider;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static android.widget.Toast.LENGTH_LONG; import static android.widget.Toast.LENGTH_LONG;
import static org.briarproject.briar.android.AppModule.getAndroidComponent; import static org.briarproject.briar.android.AppModule.getAndroidComponent;
import static org.briarproject.briar.android.util.UiUtils.putShowAdvancedExtra;
@MethodsNotNullByDefault @MethodsNotNullByDefault
@ParametersNotNullByDefault @ParametersNotNullByDefault
@@ -34,13 +36,22 @@ public class ReceiveFragment extends Fragment {
final static String TAG = ReceiveFragment.class.getName(); final static String TAG = ReceiveFragment.class.getName();
private static class GetFile extends GetContent {
@Override
public Intent createIntent(Context context, String input) {
Intent i = super.createIntent(context, input);
putShowAdvancedExtra(i);
return i;
}
}
// TODO we can pass an extra named DocumentsContract.EXTRA_INITIAL_URI // TODO we can pass an extra named DocumentsContract.EXTRA_INITIAL_URI
// to have the file-picker start on the usb-stick -- if get hold of URI // to have the file-picker start on the usb-stick -- if get hold of URI
// of the same. USB manager API? // of the same. USB manager API?
// Overall, passing this extra requires extending the ready-made // Overall, passing this extra requires extending the ready-made
// contracts and overriding createIntent. // contracts and overriding createIntent.
private final ActivityResultLauncher<String> launcher = private final ActivityResultLauncher<String> launcher =
registerForActivityResult(new GetContent(), this::onDocumentChosen); registerForActivityResult(new GetFile(), this::onDocumentChosen);
@Inject @Inject
ViewModelProvider.Factory viewModelFactory; ViewModelProvider.Factory viewModelFactory;

View File

@@ -1,6 +1,7 @@
package org.briarproject.briar.android.removabledrive; package org.briarproject.briar.android.removabledrive;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -29,6 +30,7 @@ import static android.os.Build.VERSION.SDK_INT;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static android.widget.Toast.LENGTH_LONG; import static android.widget.Toast.LENGTH_LONG;
import static org.briarproject.briar.android.AppModule.getAndroidComponent; import static org.briarproject.briar.android.AppModule.getAndroidComponent;
import static org.briarproject.briar.android.util.UiUtils.putShowAdvancedExtra;
@MethodsNotNullByDefault @MethodsNotNullByDefault
@ParametersNotNullByDefault @ParametersNotNullByDefault
@@ -36,8 +38,17 @@ public class SendFragment extends Fragment {
final static String TAG = SendFragment.class.getName(); final static String TAG = SendFragment.class.getName();
private static class CreateDocumentAdvanced extends CreateDocument {
@Override
public Intent createIntent(Context context, String input) {
Intent i = super.createIntent(context, input);
putShowAdvancedExtra(i);
return i;
}
}
private final ActivityResultLauncher<String> launcher = private final ActivityResultLauncher<String> launcher =
registerForActivityResult(new CreateDocument(), registerForActivityResult(new CreateDocumentAdvanced(),
this::onDocumentCreated); this::onDocumentCreated);
@Inject @Inject