diff --git a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
index c85a0da..421d8ef 100644
--- a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
+++ b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java
@@ -164,7 +164,11 @@ public class BucketSelect extends AppCompatActivity {
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_tobucket)) {
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- upload(Name.get(position).toString());
+ upload(Name.get(position).toString(), false);
+
+ } else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_tobucket)) {
+ //Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(Name.get(position).toString(), true);
} else if (menuItem.getTitle() == getResources().getString(R.string.download_bucket)) {
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
@@ -298,7 +302,7 @@ public class BucketSelect extends AppCompatActivity {
dialog.show();
}
- private void upload(String bucket) {
+ private void upload(String bucket, boolean isfolder) {
Intent intent = new Intent(this, Uploader.class);
intent.putExtra("endpoint", endpoint);
intent.putExtra("username", username);
@@ -307,6 +311,7 @@ public class BucketSelect extends AppCompatActivity {
intent.putExtra("prefix", prefix);
intent.putExtra("region", location);
intent.putExtra("style", style);
+ intent.putExtra("isfolder", isfolder);
startActivity(intent);
}
diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
index d20d6f6..d913cb3 100644
--- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
+++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
@@ -395,7 +395,10 @@ public class ObjectSelect extends AppCompatActivity {
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- upload();
+ upload(false);
+ } else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_here)) {
+ //Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(true);
} else if (menuItem.getTitle() == getResources().getString(R.string.download_folder)) {
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
download(Name.get(position).toString(), true);
@@ -431,7 +434,10 @@ public class ObjectSelect extends AppCompatActivity {
download(Name.get(position).toString(), false);
} else if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
//Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
- upload();
+ upload(false);
+ } else if (menuItem.getTitle() == getResources().getString(R.string.upload_folder_here)) {
+ //Toast.makeText(ObjectSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
+ upload(true);
} else if (menuItem.getTitle() == getResources().getString(R.string.create_link)) {
share(prefix + Name.get(position).toString(), Name.get(position).toString(), Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile));
} else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) {
@@ -645,7 +651,7 @@ public class ObjectSelect extends AppCompatActivity {
dialog.show();
}
- private void upload() {
+ private void upload(boolean isfolder) {
Intent intent = new Intent(this, Uploader.class);
intent.putExtra("endpoint", endpoint);
intent.putExtra("username", username);
@@ -654,6 +660,7 @@ public class ObjectSelect extends AppCompatActivity {
intent.putExtra("prefix", prefix);
intent.putExtra("region", location);
intent.putExtra("style", style);
+ intent.putExtra("isfolder", isfolder);
startActivity(intent);
}
diff --git a/app/src/main/java/asgardius/page/s3manager/Uploader.java b/app/src/main/java/asgardius/page/s3manager/Uploader.java
index b68ec41..d241d3c 100644
--- a/app/src/main/java/asgardius/page/s3manager/Uploader.java
+++ b/app/src/main/java/asgardius/page/s3manager/Uploader.java
@@ -19,6 +19,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
+import android.widget.TextView;
import android.widget.Toast;
import com.amazonaws.auth.AWSCredentials;
@@ -49,6 +50,7 @@ public class Uploader extends AppCompatActivity {
int progress;
Uri fileuri, folder;
EditText fprefix;
+ TextView fprefixlabel;
Region region;
S3ClientOptions s3ClientOptions;
AWSCredentials myCredentials;
@@ -59,7 +61,7 @@ public class Uploader extends AppCompatActivity {
Intent intent;
Button fileUpload;
Thread uploadFile, uploadProgress;
- boolean style;
+ boolean style, isfolder;
boolean started = false;
long transfered = 0;
private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024;
@@ -81,8 +83,10 @@ public class Uploader extends AppCompatActivity {
bucket = getIntent().getStringExtra("bucket");
location = getIntent().getStringExtra("region");
style = getIntent().getBooleanExtra("style", false);
+ isfolder = getIntent().getBooleanExtra("isfolder", false);
prefix = getIntent().getStringExtra("prefix");
fprefix = (EditText)findViewById(R.id.fprefix);
+ fprefixlabel = (TextView) findViewById(R.id.fprefixlabel);
region = Region.getRegion(location);
s3ClientOptions = S3ClientOptions.builder().build();
s3ClientOptions.setPathStyleAccess(style);
@@ -133,11 +137,15 @@ public class Uploader extends AppCompatActivity {
//Your code goes here
//s3client.createBucket(bucket, location);
//System.out.println(fkey);
- ufile = readContentToFile(fileuri);
- filesize = ufile.length();
- //PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile);
- //upload = s3client.putObject(request);
- putS3Object(bucket, fprefix.getText().toString(), ufile);
+ if (isfolder) {
+ //Nothing for now
+ } else {
+ ufile = readContentToFile(fileuri);
+ filesize = ufile.length();
+ //PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile);
+ //upload = s3client.putObject(request);
+ putS3Object(bucket, fprefix.getText().toString(), ufile);
+ }
runOnUiThread(new Runnable() {
@Override
@@ -153,7 +161,11 @@ public class Uploader extends AppCompatActivity {
}
simpleProgressBar.setProgress(100);
//simpleProgressBar.setVisibility(View.INVISIBLE);
- fileUpload.setText(getResources().getString(R.string.upload_success));
+ if (isfolder) {
+ fileUpload.setText(getResources().getString(R.string.batch_upload_success));
+ } else {
+ fileUpload.setText(getResources().getString(R.string.upload_success));
+ }
started = false;
fileUpload.setEnabled(false);
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
@@ -253,11 +265,15 @@ public class Uploader extends AppCompatActivity {
private void performFileSearch(String messageTitle) {
//uri = Uri.parse("content://com.android.externalstorage.documents/document/home");
intent = new Intent();
- intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- //intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
- //intent.putExtra("android.provider.extra.INITIAL_URI", uri);
- intent.setType("*/*");
+ if (isfolder) {
+ intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE);
+ } else {
+ intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ //intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
+ //intent.putExtra("android.provider.extra.INITIAL_URI", uri);
+ intent.setType("*/*");
+ }
((Activity) this).startActivityForResult(intent, 100);
}
@@ -276,7 +292,14 @@ public class Uploader extends AppCompatActivity {
if (resultData != null && resultData.getData() != null) {
fileuri = resultData.getData();
System.out.println(fileuri.toString());
- fprefix.setText(prefix+getDisplayName(fileuri));
+ if (isfolder) {
+ fprefix.setText(prefix);
+ fprefix.setHint(getResources().getString(R.string.upload_prefix));
+ fprefixlabel.setText(getResources().getString(R.string.upload_prefix));
+ fileUpload.setText(getResources().getString(R.string.batch_upload_button));
+ } else {
+ fprefix.setText(prefix+getDisplayName(fileuri));
+ }
//System.out.println("File selected successfully");
//System.out.println("content://com.android.externalstorage.documents"+file.getPath());
} else {
diff --git a/app/src/main/res/layout/activity_uploader.xml b/app/src/main/res/layout/activity_uploader.xml
index 6a36998..41f1c65 100644
--- a/app/src/main/res/layout/activity_uploader.xml
+++ b/app/src/main/res/layout/activity_uploader.xml
@@ -17,6 +17,7 @@
android:orientation="vertical">
+
+
diff --git a/app/src/main/res/menu/folder_menu.xml b/app/src/main/res/menu/folder_menu.xml
index bba106f..b7e68a3 100644
--- a/app/src/main/res/menu/folder_menu.xml
+++ b/app/src/main/res/menu/folder_menu.xml
@@ -5,6 +5,10 @@
android:id="@+id/upload_file"
android:title="@string/upload_file_here" />
+
+
diff --git a/app/src/main/res/menu/object_menu.xml b/app/src/main/res/menu/object_menu.xml
index 2973896..fd6fd9d 100644
--- a/app/src/main/res/menu/object_menu.xml
+++ b/app/src/main/res/menu/object_menu.xml
@@ -5,6 +5,10 @@
android:id="@+id/upload_file"
android:title="@string/upload_file_here" />
+
+
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 2365bc5..8c964d2 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -18,9 +18,12 @@
Su dispositivo no es compatible con esta característica
No se encuentra el uri del archivo
Subir archivo
+ Subir archivos
Nombre del objeto
+ Prefijo de los objetos
Favor de seleccionar un archivo
Archivo subido exitosamente
+ Archivos subidos exitosamente
Cancelar subida
Reintentar
Descarga fallida
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f5d1cd3..cac2288 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -34,9 +34,12 @@
Your device is not compatible with this feature
File uri not found
Upload file
+ Upload files
Object name
+ Object prefix
Please select a file
File uploaded successfully
+ Files uploaded successfully
Cancel Upload
Retry
Download failed