diff --git a/.idea/misc.xml b/.idea/misc.xml
index a3f0bb8..8b5abe5 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -14,6 +14,7 @@
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6a5e6f5..894774b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,6 +19,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31">
+
= 1) {
@@ -383,14 +376,15 @@ public class ObjectSelect extends AppCompatActivity {
private void share(String object) {
- try {
-
- Intent shareIntent = new Intent(Intent.ACTION_VIEW);
- shareIntent.setData(Uri.parse(object));
- startActivity(Intent.createChooser(shareIntent, "choose one"));
- } catch(Exception e) {
- Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
- }
+ Intent intent = new Intent(this, Share.class);
+ //treelevel ++;
+ intent.putExtra("endpoint", endpoint);
+ intent.putExtra("username", username);
+ intent.putExtra("password", password);
+ intent.putExtra("bucket", bucket);
+ intent.putExtra("object", object);
+ intent.putExtra("region", location);
+ startActivity(intent);
}
diff --git a/app/src/main/java/asgardius/page/s3manager/Share.java b/app/src/main/java/asgardius/page/s3manager/Share.java
new file mode 100644
index 0000000..9f46d39
--- /dev/null
+++ b/app/src/main/java/asgardius/page/s3manager/Share.java
@@ -0,0 +1,127 @@
+package asgardius.page.s3manager;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.regions.Region;
+import com.amazonaws.services.s3.AmazonS3;
+import com.amazonaws.services.s3.AmazonS3Client;
+import com.amazonaws.services.s3.S3ClientOptions;
+import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
+
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+
+public class Share extends AppCompatActivity {
+ String username, password, endpoint, bucket, object, location;
+ Region region;
+ S3ClientOptions s3ClientOptions;
+ AWSCredentials myCredentials;
+ AmazonS3 s3client;
+ Calendar mycal;
+ EditText datepick, monthpick, yearpick, hourpick, minutepick;
+ int date, month, year, hour, minute;
+ Button share;
+
+ public static String URLify(String str) {
+ str = str.trim();
+ int length = str.length();
+ int trueL = length;
+ if(str.contains(" ")) {
+ for(int i = 0; i < length; i++) {
+ if(str.charAt(i) == ' ') {
+ trueL = trueL + 2;
+ }
+ }
+ char[] oldArr = str.toCharArray();
+ char[] newArr = new char[trueL];
+ int x = 0;
+ for(int i = 0; i < length; i++) {
+ if(oldArr[i] == ' ') {
+ newArr[x] = '%';
+ newArr[x+1] = '2';
+ newArr[x+2] = '0';
+ x += 3;
+ } else {
+ newArr[x] = oldArr[i];
+ x++;
+ }
+ }
+ str = new String(newArr, 0, trueL);
+ }
+ return str;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_share);
+ mycal = Calendar.getInstance();
+ datepick = (EditText)findViewById(R.id.Date);
+ monthpick = (EditText)findViewById(R.id.Month);
+ yearpick = (EditText)findViewById(R.id.Year);
+ hourpick = (EditText)findViewById(R.id.Hour);
+ minutepick = (EditText)findViewById(R.id.Minute);
+ share = (Button)findViewById(R.id.share);
+ endpoint = getIntent().getStringExtra("endpoint");
+ username = getIntent().getStringExtra("username");
+ password = getIntent().getStringExtra("password");
+ bucket = getIntent().getStringExtra("bucket");
+ location = getIntent().getStringExtra("region");
+ object = getIntent().getStringExtra("object");
+ region = Region.getRegion(location);
+ s3ClientOptions = S3ClientOptions.builder().build();
+ myCredentials = new BasicAWSCredentials(username, password);
+ try {
+ s3client = new AmazonS3Client(myCredentials, region);
+ } catch (Exception e) {
+ Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
+ }
+ s3client.setEndpoint(endpoint);
+ if (!endpoint.contains(getResources().getString(R.string.aws_endpoint))) {
+ s3ClientOptions.setPathStyleAccess(true);
+ }
+ s3client.setS3ClientOptions(s3ClientOptions);
+ share.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View view) {
+ //buttonaction
+ try {
+ date = Integer.parseInt(datepick.getText().toString());
+ month = Integer.parseInt(monthpick.getText().toString());
+ year = Integer.parseInt(yearpick.getText().toString());
+ hour = Integer.parseInt(hourpick.getText().toString());
+ minute = Integer.parseInt(minutepick.getText().toString());
+ mycal.set(Calendar.YEAR, year);
+ mycal.set(Calendar.MONTH, month-1);
+ mycal.set(Calendar.DATE, date);
+ mycal.set(Calendar.HOUR, hour);
+ mycal.set(Calendar.MINUTE, minute);
+ mycal.set(Calendar.SECOND, 0);
+ Date expiration = mycal.getTime();
+ //System.out.println(expiration);
+ GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
+ URL objectURL = s3client.generatePresignedUrl(request);
+ //System.out.println(URLify(objectURL.toString()));
+ Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ shareIntent.setType("text/plain");
+ shareIntent.putExtra(Intent.EXTRA_TEXT, URLify(objectURL.toString()));
+ startActivity(Intent.createChooser(shareIntent, "choose one"));
+ } catch (Exception e) {
+ Toast.makeText(getApplicationContext(),getResources().getString(R.string.invalid_expiration_date), Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_share.xml b/app/src/main/res/layout/activity_share.xml
new file mode 100644
index 0000000..27942ff
--- /dev/null
+++ b/app/src/main/res/layout/activity_share.xml
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/object_menu.xml b/app/src/main/res/menu/object_menu.xml
index 82c7ba8..056673d 100644
--- a/app/src/main/res/menu/object_menu.xml
+++ b/app/src/main/res/menu/object_menu.xml
@@ -11,7 +11,7 @@
+ android:title="@string/file_share" />
- Establezca el nombre del nuevo bucket
Nombre del bucket
Se requiere un nombre para el bucket
- Abrir en
+ Compartir archivo
Descargar archivo
Descarga en proceso
Archivo descargado exitosamente
@@ -68,4 +68,13 @@
Contenido de prueba
servidor pdfjs
Necesita configurar un servidor pdf.js
+ DD
+ MM
+ AAAA
+ HH
+ MM
+ Fecha de expiración
+ Hora de expiración
+ Crear enlace al archivo
+ La fecha de caducidad debe ser inferior a 7 días
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bc82eb8..41aeab3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -9,12 +9,21 @@
Bucket list
Object list
Image
+ Expiration date
+ Expiration time
+ HH
+ MM
+ DD
+ MM
+ YYYY
+ Create file link
+ Expiration date must be at most 7 days
Local database is corrupted. Please reinstall this app
This feature is not implemented yet
Set new bucket name
Bucket name
A bucket name is required
- Open in
+ Share file
Download file
Download in progress
File downloaded successfully