hide missing feature

This commit is contained in:
Page Asgardius 2022-09-11 12:12:48 -07:00
parent 512421c109
commit 0c736c170f
10 changed files with 214 additions and 32 deletions

View file

@ -155,11 +155,9 @@ public class BucketSelect 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.upload_tobucket)) {
//upload();
upload(Name.get(position).toString());
//System.out.println(file);
//Toast.makeText(BucketSelect.this, intent.getData().toString(), 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(), false);
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
//upload();
@ -276,7 +274,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);
@ -284,6 +282,7 @@ public class BucketSelect extends AppCompatActivity {
intent.putExtra("bucket", bucket);
intent.putExtra("prefix", prefix);
intent.putExtra("region", location);
intent.putExtra("isfolder", isfolder);
startActivity(intent);
}

View file

@ -248,8 +248,9 @@ 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.upload_here)) {
upload(Name.get(position).toString());
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(Name.get(position).toString(), false);
} 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();
@ -273,8 +274,9 @@ 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.upload_here)) {
upload(Name.get(position).toString());
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(Name.get(position).toString(), false);
} else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) {
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
URL objectURL = s3client.generatePresignedUrl(request);
@ -454,7 +456,7 @@ public class ObjectSelect extends AppCompatActivity {
dialog.show();
}
private void upload(String object) {
private void upload(String object, boolean isfolder) {
Intent intent = new Intent(this, Uploader.class);
intent.putExtra("endpoint", endpoint);
intent.putExtra("username", username);
@ -462,6 +464,7 @@ public class ObjectSelect extends AppCompatActivity {
intent.putExtra("bucket", bucket);
intent.putExtra("prefix", prefix + object);
intent.putExtra("region", location);
intent.putExtra("isfolder", isfolder);
startActivity(intent);
}
}

View file

@ -2,12 +2,37 @@ package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
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 java.net.URL;
public class Uploader extends AppCompatActivity {
String file, username, password, endpoint, bucket, prefix, location;
String username, password, endpoint, bucket, prefix, location;
boolean isfolder;
Uri file, folder;
EditText fprefix;
Region region;
S3ClientOptions s3ClientOptions;
AWSCredentials myCredentials;
AmazonS3 s3client;
ProgressBar simpleProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -19,14 +44,114 @@ public class Uploader extends AppCompatActivity {
bucket = getIntent().getStringExtra("bucket");
location = getIntent().getStringExtra("region");
prefix = getIntent().getStringExtra("prefix");
isfolder = getIntent().getBooleanExtra("isfolder", false);
region = Region.getRegion(location);
s3ClientOptions = S3ClientOptions.builder().build();
if (!endpoint.contains(getResources().getString(R.string.aws_endpoint))) {
s3ClientOptions.setPathStyleAccess(true);
}
myCredentials = new BasicAWSCredentials(username, password);
s3client = new AmazonS3Client(myCredentials, region);
s3client.setEndpoint(endpoint);
s3client.setS3ClientOptions(s3ClientOptions);
fprefix = (EditText)findViewById(R.id.fprefix);
Button fileUpload = (Button)findViewById(R.id.fileupload);
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
Toast.makeText(Uploader.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
file = upload().getData() != null ? upload().getData().toString() : null;
/*if (isfolder) {
folder = uploadFolder();
} else {
file = uploadFile();
}*/
fileUpload.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
//buttonaction
if (file == null && folder == null) {
Toast.makeText(Uploader.this, getResources().getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show();
} else {
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
System.out.println(file.getPath());
Thread uploadFile = new Thread(new Runnable() {
@Override
public void run() {
try {
//Your code goes here
//s3client.createBucket(bucket, location);
runOnUiThread(new Runnable() {
@Override
public void run() {
// Sending reference and data to Adapter
Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show();
simpleProgressBar.setVisibility(View.INVISIBLE);
}
});
//System.out.println("tree "+treelevel);
//System.out.println("prefix "+prefix);
} catch (Exception e) {
e.printStackTrace();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
finish();
}
}
});
//simpleProgressBar.setVisibility(View.VISIBLE);
//uploadFile.start();
}
}
private Intent upload() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
startActivityForResult(intent, 100);
return intent;
});
}
/*
private Uri uploadFolder() {
StorageManager sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
Intent intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent();
String startDir = "Documents";
Uri uri = intent.getParcelableExtra("android.provider.extra.INITIAL_URI");
String scheme = uri.toString();
scheme = scheme.replace("/root/", "/document/");
scheme += "%3A" + startDir;
uri = Uri.parse(scheme);
intent.putExtra("android.provider.extra.INITIAL_URI", uri);
((Activity) this).startActivityForResult(intent,100);
return uri;
}
private Uri uploadFile() {
StorageManager sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
Intent intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent();
String startDir = "Documents";
Uri uri = intent.getParcelableExtra("android.provider.extra.INITIAL_URI");
String scheme = uri.toString();
scheme = scheme.replace("/root/", "/document/");
scheme += "%3A" + startDir;
uri = Uri.parse(scheme);
intent.putExtra("android.provider.extra.INITIAL_URI", uri);
((Activity) this).startActivityForResult(intent,100);
return uri;
}*/
}

View file

@ -15,7 +15,7 @@
android:textSize="30sp" />
<EditText
android:id="@+id/bname"
android:id="@+id/fprefix"
android:layout_width="match_parent"
android:layout_height="48dp"
android:focusable="true"

View file

@ -1,9 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<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=".Uploader">
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/upload_prefix"
android:textAlignment="center"
android:textSize="30sp" />
<EditText
android:id="@+id/bname"
android:layout_width="match_parent"
android:layout_height="48dp"
android:focusable="true"
android:hint="@string/upload_prefix"
android:importantForAutofill="no"
android:inputType="text"
android:textColorHint="?attr/colorOnSecondary"
tools:ignore="MissingConstraints" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:padding="10dp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">
<Button
android:id="@+id/fileupload"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/upload_button"
tools:ignore="MissingConstraints" />
</LinearLayout>
<ProgressBar
android:id="@+id/simpleProgressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:indeterminate="true"
android:max="100"
android:padding="20dp"
android:progress="50"
android:visibility="invisible"
tools:ignore="MissingConstraints" />
</LinearLayout>

View file

@ -2,8 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/upload"
android:title="@string/upload_tobucket" />
android:id="@+id/upload_file"
android:title="@string/upload_file_tobucket" />
<item
android:id="@+id/newbucket"

View file

@ -2,8 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/upload"
android:title="@string/upload_here" />
android:id="@+id/upload_file"
android:title="@string/upload_file_here" />
<item
android:id="@+id/deletefolder"

View file

@ -2,8 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/upload"
android:title="@string/upload_here" />
android:id="@+id/upload_file"
android:title="@string/upload_file_here" />
<item
android:id="@+id/sharefile"
android:title="@string/file_external" />

View file

@ -14,10 +14,16 @@
<string name="bucket_name">Bucket name</string>
<string name="bucket_name_empty">A bucket name is required</string>
<string name="file_external">Open in</string>
<string name="upload_tobucket">Upload to this bucket</string>
<string name="upload_file_tobucket">Upload file to this bucket</string>
<string name="upload_folder_tobucket">Upload folder to this bucket</string>
<string name="upload_button">Upload file</string>
<string name="upload_prefix">Upload prefix</string>
<string name="no_file_selected">Please select a file</string>
<string name="upload_success">File uploaded successfully</string>
<string name="create_bucket">Create new bucket</string>
<string name="create_bucket_success">Bucket created successfully</string>
<string name="upload_here">Upload in current folder</string>
<string name="upload_file_here">Upload file in current folder</string>
<string name="upload_folder_here">Upload folder in current folder</string>
<string name="file_del">Delete</string>
<string name="file_del_confirm">Do you want to delete this file?</string>
<string name="folder_del_confirm">Do you want to delete this folder?</string>