object info template

This commit is contained in:
Page Asgardius 2022-09-19 13:52:39 -07:00
parent de6a44e299
commit a4ee613f5c
10 changed files with 149 additions and 0 deletions

View file

@ -19,6 +19,14 @@
android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31">
<activity
android:name=".ObjectInfo"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".Share"
android:exported="false" />

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ObjectInfo">
<TextView
android:id="@+id/size_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/object_size"
android:textAlignment="center"
android:textSize="25sp" />
<TextView
android:id="@+id/size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="25sp" />
<ProgressBar
android:id="@+id/simpleProgressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:max="100"
android:progress="50"
android:padding="20dp"
tools:ignore="MissingConstraints"
android:indeterminate="true" />
</LinearLayout>

View file

@ -9,6 +9,10 @@
android:id="@+id/newbucket"
android:title="@string/create_bucket" />
<item
android:id="@+id/info"
android:title="@string/object_info" />
<item
android:id="@+id/deletefolder"
android:title="@string/file_del" />

View file

@ -5,6 +5,10 @@
android:id="@+id/upload_file"
android:title="@string/upload_file_here" />
<item
android:id="@+id/info"
android:title="@string/object_info" />
<item
android:id="@+id/deletefolder"
android:title="@string/file_del" />

View file

@ -13,6 +13,10 @@
android:id="@+id/sharefile"
android:title="@string/file_share" />
<item
android:id="@+id/info"
android:title="@string/object_info" />
<item
android:id="@+id/deletefile"
android:title="@string/file_del" />

View file

@ -77,4 +77,7 @@
<string name="expiration_time">Hora de expiración</string>
<string name="create_link">Crear enlace al archivo</string>
<string name="invalid_expiration_date">La fecha de caducidad debe ser inferior a 7 días</string>
<string name="object_size">Tamaño del objeto</string>
<string name="object_info">Propiedades</string>
<string name="file_external">Abir en</string>
</resources>

View file

@ -24,6 +24,7 @@
<string name="bucket_name">Bucket name</string>
<string name="bucket_name_empty">A bucket name is required</string>
<string name="file_share">Share file</string>
<string name="file_external">Open in</string>
<string name="download_file">Download file</string>
<string name="download_in_progress">Download in progress</string>
<string name="download_success">File downloaded successfully</string>
@ -39,6 +40,8 @@
<string name="retry">Retry</string>
<string name="download_failed">Download failed</string>
<string name="success">Success</string>
<string name="object_info">Properties</string>
<string name="object_size">Object Size</string>
<string name="create_bucket">Create new bucket</string>
<string name="create_bucket_success">Bucket created successfully</string>
<string name="upload_file_here">Upload file in current folder</string>