bucket creation
This commit is contained in:
parent
91639641fa
commit
512421c109
7 changed files with 195 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.195" />
|
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.195" />
|
||||||
<entry key="app/src/main/res/layout/activity_account_add.xml" value="0.25" />
|
<entry key="app/src/main/res/layout/activity_account_add.xml" value="0.25" />
|
||||||
<entry key="app/src/main/res/layout/activity_bucket_select.xml" value="0.2" />
|
<entry key="app/src/main/res/layout/activity_bucket_select.xml" value="0.2" />
|
||||||
|
<entry key="app/src/main/res/layout/activity_create_bucket.xml" value="0.20260416666666667" />
|
||||||
<entry key="app/src/main/res/layout/activity_file_share.xml" value="0.19610507246376813" />
|
<entry key="app/src/main/res/layout/activity_file_share.xml" value="0.19610507246376813" />
|
||||||
<entry key="app/src/main/res/layout/activity_image_viewer.xml" value="0.19610507246376813" />
|
<entry key="app/src/main/res/layout/activity_image_viewer.xml" value="0.19610507246376813" />
|
||||||
<entry key="app/src/main/res/layout/activity_list_item.xml" value="0.19610507246376813" />
|
<entry key="app/src/main/res/layout/activity_list_item.xml" value="0.19610507246376813" />
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AsgardiusS3Manager"
|
android:theme="@style/Theme.AsgardiusS3Manager"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".CreateBucket"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Uploader"
|
android:name=".Uploader"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
|
||||||
|
|
|
@ -161,6 +161,12 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
//System.out.println(file);
|
//System.out.println(file);
|
||||||
//Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
} else if (menuItem.getTitle() == getResources().getString(R.string.create_bucket)) {
|
||||||
|
//upload();
|
||||||
|
newBucket();
|
||||||
|
//System.out.println(file);
|
||||||
|
//Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
|
} else if (menuItem.getTitle() == getResources().getString(R.string.file_del)) {
|
||||||
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
delete(prefix + Name.get(position).toString());
|
delete(prefix + Name.get(position).toString());
|
||||||
|
@ -282,13 +288,12 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newBucket() {
|
private void newBucket() {
|
||||||
Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
Intent intent = new Intent(this, CreateBucket.class);
|
||||||
/*Intent intent = new Intent(this, Uploader.class);
|
|
||||||
intent.putExtra("endpoint", endpoint);
|
intent.putExtra("endpoint", endpoint);
|
||||||
intent.putExtra("username", username);
|
intent.putExtra("username", username);
|
||||||
intent.putExtra("password", password);
|
intent.putExtra("password", password);
|
||||||
intent.putExtra("region", location);
|
intent.putExtra("region", location);
|
||||||
startActivity(intent);*/
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
117
app/src/main/java/asgardius/page/s3manager/CreateBucket.java
Normal file
117
app/src/main/java/asgardius/page/s3manager/CreateBucket.java
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
package asgardius.page.s3manager;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
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 com.amazonaws.services.s3.model.DeleteObjectsRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ListObjectsRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ObjectListing;
|
||||||
|
import com.amazonaws.services.s3.model.S3ObjectSummary;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CreateBucket extends AppCompatActivity {
|
||||||
|
String username, password, endpoint, bucket, location;
|
||||||
|
EditText bname;
|
||||||
|
Region region;
|
||||||
|
S3ClientOptions s3ClientOptions;
|
||||||
|
AWSCredentials myCredentials;
|
||||||
|
AmazonS3 s3client;
|
||||||
|
ProgressBar simpleProgressBar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_create_bucket);
|
||||||
|
endpoint = getIntent().getStringExtra("endpoint");
|
||||||
|
username = getIntent().getStringExtra("username");
|
||||||
|
password = getIntent().getStringExtra("password");
|
||||||
|
location = getIntent().getStringExtra("region");
|
||||||
|
region = Region.getRegion("us-east-1");
|
||||||
|
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);
|
||||||
|
bname = (EditText)findViewById(R.id.bname);
|
||||||
|
Button cbucket = (Button)findViewById(R.id.cbucket);
|
||||||
|
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
||||||
|
cbucket.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//buttonaction
|
||||||
|
bucket = bname.getText().toString();
|
||||||
|
if (bucket.equals("")) {
|
||||||
|
Toast.makeText(CreateBucket.this, getResources().getString(R.string.bucket_name_empty), Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
//Toast.makeText(CreateBucket.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
|
||||||
|
Thread newBucket = 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.create_bucket_success), Toast.LENGTH_SHORT).show();
|
||||||
|
mainmenu();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//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);
|
||||||
|
newBucket.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mainmenu() {
|
||||||
|
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
intent.putExtra("EXIT", true);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
58
app/src/main/res/layout/activity_create_bucket.xml
Normal file
58
app/src/main/res/layout/activity_create_bucket.xml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?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=".CreateBucket">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/set_bucket_name"
|
||||||
|
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/bucket_name"
|
||||||
|
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/cbucket"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/create_bucket"
|
||||||
|
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>
|
|
@ -5,6 +5,10 @@
|
||||||
android:id="@+id/upload"
|
android:id="@+id/upload"
|
||||||
android:title="@string/upload_tobucket" />
|
android:title="@string/upload_tobucket" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/newbucket"
|
||||||
|
android:title="@string/create_bucket" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/deletefolder"
|
android:id="@+id/deletefolder"
|
||||||
android:title="@string/file_del" />
|
android:title="@string/file_del" />
|
||||||
|
|
|
@ -10,9 +10,13 @@
|
||||||
<string name="Image">Image</string>
|
<string name="Image">Image</string>
|
||||||
<string name="broken_database">Local database is corrupted. Please reinstall this app</string>
|
<string name="broken_database">Local database is corrupted. Please reinstall this app</string>
|
||||||
<string name="pending_feature">This feature is not implemented yet</string>
|
<string name="pending_feature">This feature is not implemented yet</string>
|
||||||
|
<string name="set_bucket_name">Set new bucket name</string>
|
||||||
|
<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="file_external">Open in</string>
|
||||||
<string name="upload_tobucket">Upload to this bucket</string>
|
<string name="upload_tobucket">Upload to this bucket</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="upload_here">Upload in current folder</string>
|
<string name="upload_here">Upload 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>
|
||||||
|
|
Loading…
Reference in a new issue