From 935a36834816ae9aac25ee4b6e19b362d0054110 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Wed, 7 Sep 2022 15:04:56 -0700 Subject: [PATCH] share screen template --- .idea/misc.xml | 1 + app/src/main/AndroidManifest.xml | 3 ++ .../asgardius/page/s3manager/FileShare.java | 36 +++++++++++++++++++ .../page/s3manager/ObjectSelect.java | 18 ++++++++-- .../main/res/layout/activity_file_share.xml | 21 +++++++++++ app/src/main/res/menu/object_menu.xml | 4 +-- app/src/main/res/values/strings.xml | 1 + 7 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/asgardius/page/s3manager/FileShare.java create mode 100644 app/src/main/res/layout/activity_file_share.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index ce84a50..4c93319 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,6 +7,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94ff6e8..39e7d31 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,9 @@ android:supportsRtl="true" android:theme="@style/Theme.AsgardiusS3Manager" tools:targetApi="31"> + diff --git a/app/src/main/java/asgardius/page/s3manager/FileShare.java b/app/src/main/java/asgardius/page/s3manager/FileShare.java new file mode 100644 index 0000000..e33dfa7 --- /dev/null +++ b/app/src/main/java/asgardius/page/s3manager/FileShare.java @@ -0,0 +1,36 @@ +package asgardius.page.s3manager; + +import static com.amazonaws.regions.Regions.US_EAST_1; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +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 FileShare extends AppCompatActivity { + String username, password, endpoint, bucket, prefix; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_file_share); + endpoint = getIntent().getStringExtra("endpoint"); + username = getIntent().getStringExtra("username"); + password = getIntent().getStringExtra("password"); + bucket = getIntent().getStringExtra("bucket"); + prefix = getIntent().getStringExtra("prefix"); + Region region = Region.getRegion(US_EAST_1); + S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build(); + s3ClientOptions.setPathStyleAccess(true); + AWSCredentials myCredentials = new BasicAWSCredentials(username, password); + AmazonS3 s3client = new AmazonS3Client(myCredentials, region); + s3client.setEndpoint(endpoint); + s3client.setS3ClientOptions(s3ClientOptions); + } +} \ 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 7785e4d..d79b69a 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -226,8 +226,8 @@ public class ObjectSelect extends AppCompatActivity { public boolean onMenuItemClick(MenuItem menuItem) { // Toast message on menu item clicked //Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show(); - if (menuItem.getTitle() == getResources().getString(R.string.dummy_button)) { - Toast.makeText(ObjectSelect.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show(); + if (menuItem.getTitle() == getResources().getString(R.string.file_share)) { + share(Name.get(position).toString()); } return true; } @@ -275,4 +275,18 @@ public class ObjectSelect extends AppCompatActivity { startActivity(intent); } + + private void share(String object) { + + Toast.makeText(ObjectSelect.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(this, FileShare.class); + intent.putExtra("endpoint", endpoint); + intent.putExtra("username", username); + intent.putExtra("password", password); + intent.putExtra("bucket", bucket); + intent.putExtra("prefix", prefix + object); + //intent.putExtra("treelevel", treelevel+1); + startActivity(intent); + + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_file_share.xml b/app/src/main/res/layout/activity_file_share.xml new file mode 100644 index 0000000..b7008ce --- /dev/null +++ b/app/src/main/res/layout/activity_file_share.xml @@ -0,0 +1,21 @@ + + + + + + \ 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 5e32203..4265ab4 100644 --- a/app/src/main/res/menu/object_menu.xml +++ b/app/src/main/res/menu/object_menu.xml @@ -2,8 +2,8 @@ + android:id="@+id/sharefile" + android:title="@string/file_share" /> \ 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 4e19ae2..3025ba2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,6 +2,7 @@ S3 Manager VideoPlayer Local database is corrupted. Please reinstall this app + Share file Please choose an account Add Account Test credentials