file uploader template

This commit is contained in:
Page Asgardius 2022-09-11 06:48:24 -07:00
parent 46467b40f9
commit 1da20db5d6
14 changed files with 97 additions and 38 deletions

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_31.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-09-10T15:42:15.258642Z" />
</component>
</project>

View file

@ -13,6 +13,7 @@
<entry key="app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_object_select.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_text_viewer.xml" value="0.19610507246376813" />
<entry key="app/src/main/res/layout/activity_uploader.xml" value="0.20260416666666667" />
<entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_web_view.xml" value="0.17119565217391305" />
<entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" />

View file

@ -4,7 +4,9 @@
package="asgardius.page.s3manager">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:node="remove" />
<application
android:allowBackup="true"
@ -16,6 +18,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31">
<activity
android:name=".Uploader"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
android:exported="false" />
<activity
android:name=".ImageViewer"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"

View file

@ -70,6 +70,10 @@ public class AccountAdd extends AppCompatActivity {
username = aupick.getText().toString();
password = appick.getText().toString();
MyDbHelper dbHelper = new MyDbHelper(AccountAdd.this);
if (alias.equals("") && endpoint.equals("") && username.equals(getResources().getString(R.string.access_key))) {
endpoint = getResources().getString(R.string.endpoint_url);
alias = "Google Test";
}
SQLiteDatabase db = dbHelper.getWritableDatabase();
if (alias.equals("") || endpoint.equals("") || username.equals("") || password.equals("")) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), Toast.LENGTH_SHORT).show();
@ -108,6 +112,10 @@ public class AccountAdd extends AppCompatActivity {
username = aupick.getText().toString();
password = appick.getText().toString();
location = arpick.getText().toString();
if (alias.equals("") && endpoint.equals("") && username.equals(getResources().getString(R.string.access_key))) {
endpoint = getResources().getString(R.string.endpoint_url);
alias = "Google Test";
}
if (alias.equals("") || endpoint.equals("") || username.equals("") || password.equals("")) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), Toast.LENGTH_SHORT).show();
} else if (endpoint.startsWith("http://")) {

View file

@ -132,10 +132,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.file_upload)) {
Toast.makeText(BucketSelect.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.upload_tobucket)) {
//upload();
file = upload().getData() != null ? upload().getData().toString() : null;
upload(Name.get(position).toString());
//System.out.println(file);
//Toast.makeText(BucketSelect.this, intent.getData().toString(), Toast.LENGTH_SHORT).show();
@ -171,11 +170,15 @@ public class BucketSelect extends AppCompatActivity {
}
private Intent upload() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
startActivityForResult(intent, 100);
return intent;
private void upload(String bucket) {
Intent intent = new Intent(this, Uploader.class);
intent.putExtra("endpoint", endpoint);
intent.putExtra("username", username);
intent.putExtra("password", password);
intent.putExtra("bucket", bucket);
intent.putExtra("prefix", prefix);
intent.putExtra("region", location);
startActivity(intent);
}
}

View file

@ -206,11 +206,6 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
//buttonaction
endpoint = getResources().getString(R.string.endpoint_url);
username = getResources().getString(R.string.access_key);
password = getResources().getString(R.string.secret_key);
location = "us-east-1";
explorer();
}
});
}

View file

@ -247,7 +247,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.file_del)) {
if (menuItem.getTitle() == getResources().getString(R.string.upload_here)) {
upload(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();
} else {
@ -270,7 +272,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.file_external)) {
if (menuItem.getTitle() == getResources().getString(R.string.upload_here)) {
upload(Name.get(position).toString());
} 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);
share(objectURL.toString());
@ -447,4 +451,15 @@ public class ObjectSelect extends AppCompatActivity {
AlertDialog dialog = builder.create();
dialog.show();
}
private void upload(String object) {
Intent intent = new Intent(this, Uploader.class);
intent.putExtra("endpoint", endpoint);
intent.putExtra("username", username);
intent.putExtra("password", password);
intent.putExtra("bucket", bucket);
intent.putExtra("prefix", prefix + object);
intent.putExtra("region", location);
startActivity(intent);
}
}

View file

@ -0,0 +1,32 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class Uploader extends AppCompatActivity {
String file, username, password, endpoint, bucket, prefix, location;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_uploader);
endpoint = getIntent().getStringExtra("endpoint");
username = getIntent().getStringExtra("username");
password = getIntent().getStringExtra("password");
bucket = getIntent().getStringExtra("bucket");
location = getIntent().getStringExtra("region");
prefix = getIntent().getStringExtra("prefix");
Toast.makeText(Uploader.this, getResources().getString(R.string.pending_feature), Toast.LENGTH_SHORT).show();
file = upload().getData() != null ? upload().getData().toString() : null;
}
private Intent upload() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
startActivityForResult(intent, 100);
return intent;
}
}

View file

@ -31,7 +31,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/test_server_button"
android:text="@string/dummy_button"
tools:ignore="MissingConstraints"
style="?android:attr/buttonStyle" />

View file

@ -0,0 +1,9 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Uploader">
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -3,7 +3,7 @@
<item
android:id="@+id/upload"
android:title="@string/file_upload" />
android:title="@string/upload_tobucket" />
<item
android:id="@+id/deletefolder"

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/upload"
android:title="@string/upload_here" />
<item
android:id="@+id/deletefolder"
android:title="@string/file_del" />

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/upload"
android:title="@string/upload_here" />
<item
android:id="@+id/sharefile"
android:title="@string/file_external" />

View file

@ -2,8 +2,7 @@
<string name="app_name">S3 Manager</string>
<string name="aws_endpoint">.amazonaws.com</string>
<string name="endpoint_url">https://object.asgardius.company</string>
<string name="access_key">asgardius</string>
<string name="secret_key">DTMp5kftamr49Ke7</string>
<string name="access_key">google</string>
<string name="title_activity_video_player">VideoPlayer</string>
<string name="account_list">Account list</string>
<string name="bucket_list">Bucket list</string>
@ -12,7 +11,8 @@
<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="file_external">Open in</string>
<string name="file_upload">Upload</string>
<string name="upload_tobucket">Upload to this bucket</string>
<string name="upload_here">Upload 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>