From a4ee613f5c8c517365ee5f8f37f1ad938722cd0b Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Mon, 19 Sep 2022 13:52:39 -0700 Subject: [PATCH] object info template --- app/src/main/AndroidManifest.xml | 8 +++ .../page/s3manager/BucketSelect.java | 15 +++++ .../asgardius/page/s3manager/ObjectInfo.java | 55 +++++++++++++++++++ .../page/s3manager/ObjectSelect.java | 18 ++++++ .../main/res/layout/activity_object_info.xml | 35 ++++++++++++ app/src/main/res/menu/bucket_menu.xml | 4 ++ app/src/main/res/menu/folder_menu.xml | 4 ++ app/src/main/res/menu/object_menu.xml | 4 ++ app/src/main/res/values-es/strings.xml | 3 + app/src/main/res/values/strings.xml | 3 + 10 files changed, 149 insertions(+) create mode 100644 app/src/main/java/asgardius/page/s3manager/ObjectInfo.java create mode 100644 app/src/main/res/layout/activity_object_info.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 894774b..1a20301 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,14 @@ android:supportsRtl="true" android:theme="@style/Theme.AsgardiusS3Manager" tools:targetApi="31"> + + + diff --git a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java index 60e4e28..2bf5ce2 100644 --- a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java @@ -165,6 +165,8 @@ public class BucketSelect extends AppCompatActivity { //System.out.println(file); //Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show(); + } else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) { + objectInfo(Name.get(position).toString()); } else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { //Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show(); delete(prefix + Name.get(position).toString()); @@ -288,6 +290,19 @@ public class BucketSelect extends AppCompatActivity { startActivity(intent); } + private void objectInfo(String bucket) { + + Intent intent = new Intent(this, ObjectInfo.class); + //treelevel ++; + intent.putExtra("endpoint", endpoint); + intent.putExtra("username", username); + intent.putExtra("password", password); + intent.putExtra("bucket", bucket); + intent.putExtra("region", location); + startActivity(intent); + + } + private void newBucket() { Intent intent = new Intent(this, CreateBucket.class); intent.putExtra("endpoint", endpoint); diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java b/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java new file mode 100644 index 0000000..f91b74a --- /dev/null +++ b/app/src/main/java/asgardius/page/s3manager/ObjectInfo.java @@ -0,0 +1,55 @@ +package asgardius.page.s3manager; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.TextView; +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; + +public class ObjectInfo extends AppCompatActivity { + String username, password, endpoint, bucket, object, location; + Region region; + S3ClientOptions s3ClientOptions; + AWSCredentials myCredentials; + AmazonS3 s3client; + ProgressBar simpleProgressBar; + TextView filesize; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_object_info); + simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); + filesize = (TextView) findViewById(R.id.size); + 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); + simpleProgressBar.setVisibility(View.INVISIBLE); + } +} \ No newline at end of file diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 1a56cc6..f57d5b7 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -306,6 +306,8 @@ public class ObjectSelect extends AppCompatActivity { 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(); + } else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) { + objectInfo(prefix + Name.get(position).toString()); } else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { if (Name.size() == 1 && treelevel >= 1) { Toast.makeText(ObjectSelect.this, getResources().getString(R.string.only_item_onlist), Toast.LENGTH_SHORT).show(); @@ -337,6 +339,8 @@ public class ObjectSelect extends AppCompatActivity { upload(); } else if (menuItem.getTitle() == getResources().getString(R.string.file_share)) { share(prefix + Name.get(position).toString()); + } else if (menuItem.getTitle() == getResources().getString(R.string.object_info)) { + objectInfo(prefix + Name.get(position).toString()); } else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { if (menuItem.getTitle() == getResources().getString(R.string.file_del)) { if (Name.size() == 1 && treelevel >= 1) { @@ -418,6 +422,20 @@ public class ObjectSelect extends AppCompatActivity { } + private void objectInfo(String object) { + + Intent intent = new Intent(this, ObjectInfo.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); + + } + private void delete(String object, boolean folder) { AlertDialog.Builder builder = new AlertDialog.Builder(ObjectSelect.this); builder.setCancelable(true); diff --git a/app/src/main/res/layout/activity_object_info.xml b/app/src/main/res/layout/activity_object_info.xml new file mode 100644 index 0000000..a67b7c6 --- /dev/null +++ b/app/src/main/res/layout/activity_object_info.xml @@ -0,0 +1,35 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bucket_menu.xml b/app/src/main/res/menu/bucket_menu.xml index 3c3e897..047028e 100644 --- a/app/src/main/res/menu/bucket_menu.xml +++ b/app/src/main/res/menu/bucket_menu.xml @@ -9,6 +9,10 @@ android:id="@+id/newbucket" android:title="@string/create_bucket" /> + + diff --git a/app/src/main/res/menu/folder_menu.xml b/app/src/main/res/menu/folder_menu.xml index 1e64433..a5f1e60 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 056673d..9ab71e9 100644 --- a/app/src/main/res/menu/object_menu.xml +++ b/app/src/main/res/menu/object_menu.xml @@ -13,6 +13,10 @@ android:id="@+id/sharefile" android:title="@string/file_share" /> + + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3a731ff..f8922f9 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -77,4 +77,7 @@ Hora de expiración Crear enlace al archivo La fecha de caducidad debe ser inferior a 7 días + Tamaño del objeto + Propiedades + Abir en \ 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 41aeab3..b74cd62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,7 @@ Bucket name A bucket name is required Share file + Open in Download file Download in progress File downloaded successfully @@ -39,6 +40,8 @@ Retry Download failed Success + Properties + Object Size Create new bucket Bucket created successfully Upload file in current folder