hide missing feature
This commit is contained in:
parent
512421c109
commit
0c736c170f
10 changed files with 214 additions and 32 deletions
|
@ -155,11 +155,9 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_tobucket)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_tobucket)) {
|
||||||
//upload();
|
Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
upload(Name.get(position).toString());
|
//upload(Name.get(position).toString(), false);
|
||||||
//System.out.println(file);
|
|
||||||
//Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
|
||||||
//upload();
|
//upload();
|
||||||
|
@ -276,7 +274,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upload(String bucket) {
|
private void upload(String bucket, boolean isfolder) {
|
||||||
Intent intent = new Intent(this, Uploader.class);
|
Intent intent = new Intent(this, Uploader.class);
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
|
@ -284,6 +282,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
intent.putExtra("bucket", bucket);
|
intent.putExtra("bucket", bucket);
|
||||||
intent.putExtra("prefix", prefix);
|
intent.putExtra("prefix", prefix);
|
||||||
intent.putExtra("region", location);
|
intent.putExtra("region", location);
|
||||||
|
intent.putExtra("isfolder", isfolder);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CreateBucket extends AppCompatActivity {
|
||||||
s3client = new AmazonS3Client(myCredentials, region);
|
s3client = new AmazonS3Client(myCredentials, region);
|
||||||
s3client.setEndpoint(endpoint);
|
s3client.setEndpoint(endpoint);
|
||||||
s3client.setS3ClientOptions(s3ClientOptions);
|
s3client.setS3ClientOptions(s3ClientOptions);
|
||||||
bname = (EditText)findViewById(R.id.bname);
|
bname = (EditText)findViewById(R.id.bname);
|
||||||
Button cbucket = (Button)findViewById(R.id.cbucket);
|
Button cbucket = (Button)findViewById(R.id.cbucket);
|
||||||
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
||||||
cbucket.setOnClickListener(new View.OnClickListener(){
|
cbucket.setOnClickListener(new View.OnClickListener(){
|
||||||
|
|
|
@ -248,8 +248,9 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_here)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
||||||
upload(Name.get(position).toString());
|
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)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
|
||||||
if (Name.size() == 1 && treelevel >= 1) {
|
if (Name.size() == 1 && treelevel >= 1) {
|
||||||
Toast.makeText(ObjectSelect.this, getResources().getString(R.string.only_item_onlist), Toast.LENGTH_SHORT).show();
|
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) {
|
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||||
// Toast message on menu item clicked
|
// Toast message on menu item clicked
|
||||||
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
if (menuItem.getTitle() == getResources().getString(R.string.upload_here)) {
|
if (menuItem.getTitle() == getResources().getString(R.string.upload_file_here)) {
|
||||||
upload(Name.get(position).toString());
|
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)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.file_external)) {
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
|
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
|
||||||
URL objectURL = s3client.generatePresignedUrl(request);
|
URL objectURL = s3client.generatePresignedUrl(request);
|
||||||
|
@ -454,7 +456,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upload(String object) {
|
private void upload(String object, boolean isfolder) {
|
||||||
Intent intent = new Intent(this, Uploader.class);
|
Intent intent = new Intent(this, Uploader.class);
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
|
@ -462,6 +464,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
intent.putExtra("bucket", bucket);
|
intent.putExtra("bucket", bucket);
|
||||||
intent.putExtra("prefix", prefix + object);
|
intent.putExtra("prefix", prefix + object);
|
||||||
intent.putExtra("region", location);
|
intent.putExtra("region", location);
|
||||||
|
intent.putExtra("isfolder", isfolder);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,12 +2,37 @@ package asgardius.page.s3manager;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
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 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 {
|
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
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -19,14 +44,114 @@ public class Uploader extends AppCompatActivity {
|
||||||
bucket = getIntent().getStringExtra("bucket");
|
bucket = getIntent().getStringExtra("bucket");
|
||||||
location = getIntent().getStringExtra("region");
|
location = getIntent().getStringExtra("region");
|
||||||
prefix = getIntent().getStringExtra("prefix");
|
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();
|
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 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 Intent upload() {
|
private Uri uploadFile() {
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
StorageManager sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
|
||||||
intent.setType("*/*");
|
|
||||||
startActivityForResult(intent, 100);
|
Intent intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent();
|
||||||
return intent;
|
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;
|
||||||
|
}*/
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
android:textSize="30sp" />
|
android:textSize="30sp" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/bname"
|
android:id="@+id/fprefix"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
|
|
|
@ -1,9 +1,58 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/activity_main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
tools:context=".Uploader">
|
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>
|
|
@ -2,8 +2,8 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/upload"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_tobucket" />
|
android:title="@string/upload_file_tobucket" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/newbucket"
|
android:id="@+id/newbucket"
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/upload"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_here" />
|
android:title="@string/upload_file_here" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/deletefolder"
|
android:id="@+id/deletefolder"
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/upload"
|
android:id="@+id/upload_file"
|
||||||
android:title="@string/upload_here" />
|
android:title="@string/upload_file_here" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/sharefile"
|
android:id="@+id/sharefile"
|
||||||
android:title="@string/file_external" />
|
android:title="@string/file_external" />
|
||||||
|
|
|
@ -14,10 +14,16 @@
|
||||||
<string name="bucket_name">Bucket name</string>
|
<string name="bucket_name">Bucket name</string>
|
||||||
<string name="bucket_name_empty">A bucket name is required</string>
|
<string name="bucket_name_empty">A bucket name is required</string>
|
||||||
<string name="file_external">Open in</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">Create new bucket</string>
|
||||||
<string name="create_bucket_success">Bucket created successfully</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">Delete</string>
|
||||||
<string name="file_del_confirm">Do you want to delete this file?</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>
|
<string name="folder_del_confirm">Do you want to delete this folder?</string>
|
||||||
|
|
Loading…
Reference in a new issue