new release

This commit is contained in:
Page Asgardius 2022-12-31 10:16:44 -07:00
parent 697d2b8b07
commit 5dd93a01c5
7 changed files with 56 additions and 31 deletions

View file

@ -9,7 +9,7 @@ android {
applicationId "asgardius.page.s3manager" applicationId "asgardius.page.s3manager"
minSdk 23 minSdk 23
targetSdk 33 targetSdk 33
versionCode 56 versionCode 57
versionName "0.6.0" versionName "0.6.0"
setProperty("archivesBaseName", "s3-manager-$versionName") setProperty("archivesBaseName", "s3-manager-$versionName")

View file

@ -52,8 +52,7 @@
<activity <activity
android:name=".Downloader" android:name=".Downloader"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false" android:exported="false" />
android:label="@string/download_file" />
<activity <activity
android:name=".CreateBucket" android:name=".CreateBucket"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
@ -62,8 +61,7 @@
<activity <activity
android:name=".Uploader" android:name=".Uploader"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false" android:exported="false" />
android:label="@string/upload_button" />
<activity <activity
android:name=".ImageViewer" android:name=".ImageViewer"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"

View file

@ -79,6 +79,11 @@ public class Downloader extends AppCompatActivity {
style = getIntent().getBooleanExtra("style", false); style = getIntent().getBooleanExtra("style", false);
isfolder = getIntent().getBooleanExtra("isfolder", false); isfolder = getIntent().getBooleanExtra("isfolder", false);
prefix = getIntent().getStringExtra("prefix"); prefix = getIntent().getStringExtra("prefix");
if(isfolder) {
getSupportActionBar().setTitle(getResources().getString(R.string.download_files));
} else {
getSupportActionBar().setTitle(getResources().getString(R.string.download_file));
}
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
fileDownload = (Button)findViewById(R.id.filedownload); fileDownload = (Button)findViewById(R.id.filedownload);
region = Region.getRegion(location); region = Region.getRegion(location);

View file

@ -23,12 +23,15 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.amazonaws.AbortedException;
import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region; import com.amazonaws.regions.Region;
import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions; import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.AmazonS3Exception;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest; import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadResult; import com.amazonaws.services.s3.model.InitiateMultipartUploadResult;
@ -87,6 +90,11 @@ public class Uploader extends AppCompatActivity {
style = getIntent().getBooleanExtra("style", false); style = getIntent().getBooleanExtra("style", false);
isfolder = getIntent().getBooleanExtra("isfolder", false); isfolder = getIntent().getBooleanExtra("isfolder", false);
prefix = getIntent().getStringExtra("prefix"); prefix = getIntent().getStringExtra("prefix");
if(isfolder) {
getSupportActionBar().setTitle(getResources().getString(R.string.batch_upload_button));
} else {
getSupportActionBar().setTitle(getResources().getString(R.string.upload_button));
}
fprefix = (EditText)findViewById(R.id.fprefix); fprefix = (EditText)findViewById(R.id.fprefix);
fprefixlabel = (TextView) findViewById(R.id.fprefixlabel); fprefixlabel = (TextView) findViewById(R.id.fprefixlabel);
region = Region.getRegion(location); region = Region.getRegion(location);
@ -152,14 +160,14 @@ public class Uploader extends AppCompatActivity {
int treelevel = 0; int treelevel = 0;
ArrayList<Integer> fileindex = new ArrayList<Integer>(); ArrayList<Integer> fileindex = new ArrayList<Integer>();
fileindex.add(0); fileindex.add(0);
for (int i = 0; i < filelist.length; i++) { for (int i = 0; i < filelist.length && !cancel; i++) {
filepath.add(filelist[i].getName()); filepath.add(filelist[i].getName());
if(filelist[i].isDirectory()) { if(filelist[i].isDirectory()) {
treelevel++; treelevel++;
fileindex.add(0); fileindex.add(0);
document = filelist[i]; document = filelist[i];
filelist = document.listFiles(); filelist = document.listFiles();
while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length+1) { while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length+1 && !cancel) {
if(fileindex.get(treelevel) == filelist.length) { if(fileindex.get(treelevel) == filelist.length) {
fileindex.remove(treelevel); fileindex.remove(treelevel);
document = document.getParentFile(); document = document.getParentFile();
@ -214,9 +222,13 @@ public class Uploader extends AppCompatActivity {
mWakeLock.release(); mWakeLock.release();
//System.out.println("WakeLock released"); //System.out.println("WakeLock released");
} }
if(!cancel) {
simpleProgressBar.setProgress(100); simpleProgressBar.setProgress(100);
}
//simpleProgressBar.setVisibility(View.INVISIBLE); //simpleProgressBar.setVisibility(View.INVISIBLE);
if (isfolder) { if (cancel) {
fileUpload.setText(getResources().getString(R.string.upload_canceled));
} else if (isfolder) {
fileUpload.setText(getResources().getString(R.string.batch_upload_success)); fileUpload.setText(getResources().getString(R.string.batch_upload_success));
} else { } else {
fileUpload.setText(getResources().getString(R.string.upload_success)); fileUpload.setText(getResources().getString(R.string.upload_success));
@ -431,7 +443,8 @@ public class Uploader extends AppCompatActivity {
// Upload the file parts. // Upload the file parts.
long fileOffset = 0; long fileOffset = 0;
for (int partNumber = 1; fileOffset < contentLength; ++partNumber) { try{
for (int partNumber = 1; fileOffset < contentLength && !cancel; ++partNumber) {
// Because the last part could be less than 5 MB, adjust the part size as needed. // Because the last part could be less than 5 MB, adjust the part size as needed.
partSize = Math.min(partSize, (contentLength - fileOffset)); partSize = Math.min(partSize, (contentLength - fileOffset));
@ -457,6 +470,13 @@ public class Uploader extends AppCompatActivity {
// Complete the multipart upload. // Complete the multipart upload.
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId(), partETags); CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId(), partETags);
s3client.completeMultipartUpload(compRequest); s3client.completeMultipartUpload(compRequest);
} catch (AbortedException | AmazonS3Exception e) {
e.printStackTrace();
AbortMultipartUploadRequest abort = new AbortMultipartUploadRequest(bucket, objectKey, initResponse.getUploadId());
s3client.abortMultipartUpload(abort);
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//finish();
}
} }
private void calculateSize() { private void calculateSize() {

View file

@ -11,6 +11,7 @@
<string name="bucket_name_empty">Se requiere un nombre para el bucket</string> <string name="bucket_name_empty">Se requiere un nombre para el bucket</string>
<string name="file_share">Compartir archivo</string> <string name="file_share">Compartir archivo</string>
<string name="download_file">Descargar archivo</string> <string name="download_file">Descargar archivo</string>
<string name="download_files">Descargar archivos</string>
<string name="cancel_download">Cancelar descarga</string> <string name="cancel_download">Cancelar descarga</string>
<string name="download_success">Archivo descargado exitosamente</string> <string name="download_success">Archivo descargado exitosamente</string>
<string name="upload_file_tobucket">Subir archivo en este bucket</string> <string name="upload_file_tobucket">Subir archivo en este bucket</string>

View file

@ -24,6 +24,7 @@
<string name="file_share">Share file</string> <string name="file_share">Share file</string>
<string name="file_external">Open in</string> <string name="file_external">Open in</string>
<string name="download_file">Download file</string> <string name="download_file">Download file</string>
<string name="download_files">Download files</string>
<string name="download_bucket">Download bucket content</string> <string name="download_bucket">Download bucket content</string>
<string name="download_folder">Download folder content</string> <string name="download_folder">Download folder content</string>
<string name="cancel_download">Cancel download</string> <string name="cancel_download">Cancel download</string>