From 38442e5c5494c1ae33baf6228e8d52426c1ef5fd Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 24 Sep 2022 14:10:17 -0700 Subject: [PATCH 1/3] download progress handler template --- .../asgardius/page/s3manager/Downloader.java | 200 +++++++++++------- .../asgardius/page/s3manager/Uploader.java | 178 ++++++++-------- app/src/main/res/values-es/strings.xml | 5 +- app/src/main/res/values/strings.xml | 5 +- 4 files changed, 221 insertions(+), 167 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/Downloader.java b/app/src/main/java/asgardius/page/s3manager/Downloader.java index db3a0ca..cccb165 100644 --- a/app/src/main/java/asgardius/page/s3manager/Downloader.java +++ b/app/src/main/java/asgardius/page/s3manager/Downloader.java @@ -5,7 +5,6 @@ import static android.content.ContentValues.TAG; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; -import android.app.DownloadManager; import android.content.Context; import android.content.Intent; import android.database.Cursor; @@ -17,9 +16,7 @@ import android.provider.MediaStore; import android.util.Log; import android.view.View; import android.widget.Button; -import android.widget.EditText; import android.widget.ProgressBar; -import android.widget.TextView; import android.widget.Toast; import com.amazonaws.auth.AWSCredentials; @@ -29,11 +26,7 @@ import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.S3ClientOptions; import com.amazonaws.services.s3.model.S3Object; -import com.google.android.material.snackbar.Snackbar; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -48,8 +41,12 @@ public class Downloader extends AppCompatActivity { ProgressBar simpleProgressBar; Intent intent; Button fileDownload; - Thread downloadFile; + Thread downloadFile, downloadProgress; S3Object object; + boolean started = false; + boolean cancel = false; + long filesize = 0; + long transfered; private WifiManager.WifiLock mWifiLock; private PowerManager.WakeLock mWakeLock; private PowerManager powerManager; @@ -85,77 +82,124 @@ public class Downloader extends AppCompatActivity { @Override public void onClick(View view) { //buttonaction - simpleProgressBar.setVisibility(View.VISIBLE); - fileDownload.setEnabled(false); - fileDownload.setText(getResources().getString(R.string.download_in_progress)); - //Acquiring WakeLock and WifiLock if not held - if (!mWifiLock.isHeld()) { - mWifiLock.acquire(); - //System.out.println("WifiLock acquired"); - } - if (!mWakeLock.isHeld()) { - mWakeLock.acquire(); - //System.out.println("WakeLock acquired"); - } - downloadFile = new Thread(new Runnable() { - - @Override - public void run() { - simpleProgressBar.setVisibility(View.VISIBLE); - try { - //Your code goes here - //s3client.createBucket(bucket, location); - //System.out.println(fkey); - object = s3client.getObject(bucket, prefix+filename); - writeContentToFile(fileuri); - runOnUiThread(new Runnable() { - @Override - public void run() { - //simpleProgressBar.setProgress(100); - //Releasing WifiLock and WakeLock if held - if (mWifiLock.isHeld()) { - mWifiLock.release(); - //System.out.println("WifiLock released"); - } - if (mWakeLock.isHeld()) { - mWakeLock.release(); - //System.out.println("WakeLock released"); - } - simpleProgressBar.setVisibility(View.INVISIBLE); - fileDownload.setText(getResources().getString(R.string.download_success)); - Toast.makeText(getApplicationContext(),getResources().getString(R.string.download_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() { - //Releasing WifiLock and WakeLock if held - if (mWifiLock.isHeld()) { - mWifiLock.release(); - //System.out.println("WifiLock released"); - } - if (mWakeLock.isHeld()) { - mWakeLock.release(); - //System.out.println("WakeLock released"); - } - simpleProgressBar.setVisibility(View.INVISIBLE); - fileDownload.setText(getResources().getString(R.string.download_failed)); - 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(); - } + if (started) { + cancel = true; + downloadFile.interrupt(); + //simpleProgressBar.setVisibility(View.INVISIBLE); + } else { + started = true; + simpleProgressBar.setVisibility(View.VISIBLE); + //fileDownload.setEnabled(false); + fileDownload.setText(getResources().getString(R.string.cancel_download)); + //Acquiring WakeLock and WifiLock if not held + if (!mWifiLock.isHeld()) { + mWifiLock.acquire(); + //System.out.println("WifiLock acquired"); } - }); - downloadFile.start(); + if (!mWakeLock.isHeld()) { + mWakeLock.acquire(); + //System.out.println("WakeLock acquired"); + } + downloadFile = new Thread(new Runnable() { + + @Override + public void run() { + simpleProgressBar.setVisibility(View.VISIBLE); + try { + //Your code goes here + //s3client.createBucket(bucket, location); + //System.out.println(fkey); + object = s3client.getObject(bucket, prefix+filename); + filesize = object.getObjectMetadata().getContentLength(); + writeContentToFile(fileuri); + runOnUiThread(new Runnable() { + @Override + public void run() { + //simpleProgressBar.setProgress(100); + //Releasing WifiLock and WakeLock if held + if (mWifiLock.isHeld()) { + mWifiLock.release(); + //System.out.println("WifiLock released"); + } + if (mWakeLock.isHeld()) { + mWakeLock.release(); + //System.out.println("WakeLock released"); + } + simpleProgressBar.setVisibility(View.INVISIBLE); + fileDownload.setText(getResources().getString(R.string.download_success)); + fileDownload.setEnabled(false); + //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() { + //Releasing WifiLock and WakeLock if held + if (mWifiLock.isHeld()) { + mWifiLock.release(); + //System.out.println("WifiLock released"); + } + if (mWakeLock.isHeld()) { + mWakeLock.release(); + //System.out.println("WakeLock released"); + } + simpleProgressBar.setVisibility(View.INVISIBLE); + if (cancel) { + fileDownload.setText(getResources().getString(R.string.download_canceled)); + } else { + fileDownload.setText(getResources().getString(R.string.download_failed)); + } + fileDownload.setEnabled(false); + } + }); + //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + //finish(); + } + } + }); + downloadProgress = new Thread(new Runnable() { + + @Override + public void run() { + simpleProgressBar.setVisibility(View.VISIBLE); + try { + //Your code goes here + while (!cancel && fileDownload.isEnabled()) { + try { + if (filesize != 0) { + System.out.println("file size: "+Long.toString(filesize)); + } + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } + } + + runOnUiThread(new Runnable() { + @Override + public void run() { + //simpleProgressBar.setProgress(100); + } + }); + //System.out.println("tree "+treelevel); + //System.out.println("prefix "+prefix); + + } catch (Exception e) { + e.printStackTrace(); + //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + //finish(); + } + } + }); + downloadFile.start(); + downloadProgress.start(); + } } }); diff --git a/app/src/main/java/asgardius/page/s3manager/Uploader.java b/app/src/main/java/asgardius/page/s3manager/Uploader.java index cc32bd6..38cff49 100644 --- a/app/src/main/java/asgardius/page/s3manager/Uploader.java +++ b/app/src/main/java/asgardius/page/s3manager/Uploader.java @@ -12,7 +12,6 @@ import android.net.Uri; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.PowerManager; -import android.os.storage.StorageManager; import android.provider.MediaStore; import android.util.Log; import android.view.View; @@ -59,6 +58,7 @@ public class Uploader extends AppCompatActivity { Intent intent; Button fileUpload; Thread uploadFile; + boolean started = false; private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024; private WifiManager.WifiLock mWifiLock; private PowerManager.WakeLock mWakeLock; @@ -97,93 +97,100 @@ public class Uploader extends AppCompatActivity { @Override public void onClick(View view) { //buttonaction - if (fileuri == null && folder == null) { - Toast.makeText(Uploader.this, getResources().getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show(); + if (started) { + started = false; + uploadFile.interrupt(); + //simpleProgressBar.setVisibility(View.INVISIBLE); } else { - //Acquiring WakeLock and WifiLock if not held - if (!mWifiLock.isHeld()) { - mWifiLock.acquire(); - //System.out.println("WifiLock acquired"); - } - if (!mWakeLock.isHeld()) { - mWakeLock.acquire(); - //System.out.println("WakeLock acquired"); - } + started = true; simpleProgressBar.setVisibility(View.VISIBLE); - fileUpload.setEnabled(false); - fileUpload.setText(getResources().getString(R.string.upload_in_progress)); - uploadFile = new Thread(new Runnable() { - - @Override - public void run() { - if (fprefix.getText().toString().endsWith("/") || fprefix.getText().toString().equals("")) { - fkey = fprefix.getText().toString()+getDisplayName(fileuri); - } else { - fkey = fprefix.getText().toString()+"/"+getDisplayName(fileuri); - } - //System.out.println(fkey); - progress = 0; - filesize = 0; - try { - //Your code goes here - //s3client.createBucket(bucket, location); - //System.out.println(fkey); - ufile = readContentToFile(fileuri); - filesize = ufile.length(); - //PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile); - //upload = s3client.putObject(request); - putS3Object(bucket, fkey, ufile); - runOnUiThread(new Runnable() { - - @Override - public void run() { - //Releasing WifiLock and WakeLock if held - if (mWifiLock.isHeld()) { - mWifiLock.release(); - //System.out.println("WifiLock released"); - } - if (mWakeLock.isHeld()) { - mWakeLock.release(); - //System.out.println("WakeLock released"); - } - //simpleProgressBar.setProgress(100); - simpleProgressBar.setVisibility(View.INVISIBLE); - fileUpload.setText(getResources().getString(R.string.upload_success)); - 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() { - //Releasing WifiLock and WakeLock if held - if (mWifiLock.isHeld()) { - mWifiLock.release(); - //System.out.println("WifiLock released"); - } - if (mWakeLock.isHeld()) { - mWakeLock.release(); - //System.out.println("WakeLock released"); - } - simpleProgressBar.setVisibility(View.INVISIBLE); - fileUpload.setEnabled(true); - fileUpload.setText(getResources().getString(R.string.retry)); - 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(); - } + if (fileuri == null && folder == null) { + Toast.makeText(Uploader.this, getResources().getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show(); + } else { + //Acquiring WakeLock and WifiLock if not held + if (!mWifiLock.isHeld()) { + mWifiLock.acquire(); + //System.out.println("WifiLock acquired"); } - }); - //simpleProgressBar.setVisibility(View.VISIBLE); - uploadFile.start(); + if (!mWakeLock.isHeld()) { + mWakeLock.acquire(); + //System.out.println("WakeLock acquired"); + } + //eUpload.setEnabled(false); + fileUpload.setText(getResources().getString(R.string.cancel_upload)); + uploadFile = new Thread(new Runnable() { + + @Override + public void run() { + if (fprefix.getText().toString().endsWith("/") || fprefix.getText().toString().equals("")) { + fkey = fprefix.getText().toString()+getDisplayName(fileuri); + } else { + fkey = fprefix.getText().toString()+"/"+getDisplayName(fileuri); + } + //System.out.println(fkey); + progress = 0; + filesize = 0; + try { + //Your code goes here + //s3client.createBucket(bucket, location); + //System.out.println(fkey); + ufile = readContentToFile(fileuri); + filesize = ufile.length(); + //PutObjectRequest request = new PutObjectRequest(bucket, fkey, ufile); + //upload = s3client.putObject(request); + putS3Object(bucket, fkey, ufile); + runOnUiThread(new Runnable() { + + @Override + public void run() { + //Releasing WifiLock and WakeLock if held + if (mWifiLock.isHeld()) { + mWifiLock.release(); + //System.out.println("WifiLock released"); + } + if (mWakeLock.isHeld()) { + mWakeLock.release(); + //System.out.println("WakeLock released"); + } + //simpleProgressBar.setProgress(100); + simpleProgressBar.setVisibility(View.INVISIBLE); + fileUpload.setText(getResources().getString(R.string.upload_success)); + fileUpload.setEnabled(false); + //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() { + //Releasing WifiLock and WakeLock if held + if (mWifiLock.isHeld()) { + mWifiLock.release(); + //System.out.println("WifiLock released"); + } + if (mWakeLock.isHeld()) { + mWakeLock.release(); + //System.out.println("WakeLock released"); + } + simpleProgressBar.setVisibility(View.INVISIBLE); + //fileUpload.setEnabled(true); + fileUpload.setText(getResources().getString(R.string.retry)); + //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(); /*while (progress <= 99) { System.out.println("Upload in progress"); if (upload != null) { @@ -200,6 +207,7 @@ public class Uploader extends AppCompatActivity { e.printStackTrace(); } }*/ + } } } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 0eecf51..c1fba4e 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -11,7 +11,7 @@ Se requiere un nombre para el bucket Compartir archivo Descargar archivo - Descarga en proceso + Cancelar descarga Archivo descargado exitosamente Subir archivo en este bucket Subir carpeta en este bucket @@ -21,7 +21,7 @@ Prefijo del objeto Favor de seleccionar un archivo Archivo subido exitosamente - Subida en proceso + Cancelar subida Reintentar Descarga fallida Éxito @@ -84,4 +84,5 @@ Tamaño del bucket Archivos Debe establecer una fecha de expiración para compartir archivos + Descarga cancelada \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e0b8061..995cdd6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -27,7 +27,7 @@ Share file Open in Download file - Download in progress + Cancel download File downloaded successfully Upload file to this bucket Upload folder to this bucket @@ -37,9 +37,10 @@ Object prefix Please select a file File uploaded successfully - Upload in progress + Cancel Upload Retry Download failed + Download canceled Success Properties File Size From 38ffd5f5f786d0cf38668e441f21ae1b110701d8 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 24 Sep 2022 16:07:05 -0700 Subject: [PATCH 2/3] download progress --- .../java/asgardius/page/s3manager/Downloader.java | 13 ++++++------- app/src/main/res/layout/activity_downloader.xml | 5 +++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/Downloader.java b/app/src/main/java/asgardius/page/s3manager/Downloader.java index cccb165..2a46594 100644 --- a/app/src/main/java/asgardius/page/s3manager/Downloader.java +++ b/app/src/main/java/asgardius/page/s3manager/Downloader.java @@ -46,7 +46,7 @@ public class Downloader extends AppCompatActivity { boolean started = false; boolean cancel = false; long filesize = 0; - long transfered; + long transfered = 0; private WifiManager.WifiLock mWifiLock; private PowerManager.WakeLock mWakeLock; private PowerManager powerManager; @@ -110,7 +110,7 @@ public class Downloader extends AppCompatActivity { //s3client.createBucket(bucket, location); //System.out.println(fkey); object = s3client.getObject(bucket, prefix+filename); - filesize = object.getObjectMetadata().getContentLength(); + filesize = (object.getObjectMetadata().getContentLength())/1024; writeContentToFile(fileuri); runOnUiThread(new Runnable() { @Override @@ -125,7 +125,7 @@ public class Downloader extends AppCompatActivity { mWakeLock.release(); //System.out.println("WakeLock released"); } - simpleProgressBar.setVisibility(View.INVISIBLE); + simpleProgressBar.setProgress(100); fileDownload.setText(getResources().getString(R.string.download_success)); fileDownload.setEnabled(false); //simpleProgressBar.setVisibility(View.INVISIBLE); @@ -149,7 +149,6 @@ public class Downloader extends AppCompatActivity { mWakeLock.release(); //System.out.println("WakeLock released"); } - simpleProgressBar.setVisibility(View.INVISIBLE); if (cancel) { fileDownload.setText(getResources().getString(R.string.download_canceled)); } else { @@ -167,13 +166,12 @@ public class Downloader extends AppCompatActivity { @Override public void run() { - simpleProgressBar.setVisibility(View.VISIBLE); try { //Your code goes here - while (!cancel && fileDownload.isEnabled()) { + while (fileDownload.isEnabled()) { try { if (filesize != 0) { - System.out.println("file size: "+Long.toString(filesize)); + simpleProgressBar.setProgress((int)((transfered*100)/filesize)); } Thread.sleep(500); } catch (Exception e) { @@ -252,6 +250,7 @@ public class Downloader extends AppCompatActivity { byte[] buffer = new byte[1024]; for (int len; (len = in.read(buffer)) != -1; ) { out.write(buffer, 0, len); + transfered ++; } } } diff --git a/app/src/main/res/layout/activity_downloader.xml b/app/src/main/res/layout/activity_downloader.xml index 71525ad..000f473 100644 --- a/app/src/main/res/layout/activity_downloader.xml +++ b/app/src/main/res/layout/activity_downloader.xml @@ -28,12 +28,13 @@ From 493c17643e8d53d9552532cd17a0637d7593f6a7 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 24 Sep 2022 17:36:31 -0700 Subject: [PATCH 3/3] upload progress --- .../asgardius/page/s3manager/Downloader.java | 9 ---- .../asgardius/page/s3manager/Uploader.java | 49 +++++++++++++++++-- app/src/main/res/layout/activity_uploader.xml | 5 +- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/Downloader.java b/app/src/main/java/asgardius/page/s3manager/Downloader.java index 2a46594..8044323 100644 --- a/app/src/main/java/asgardius/page/s3manager/Downloader.java +++ b/app/src/main/java/asgardius/page/s3manager/Downloader.java @@ -179,15 +179,6 @@ public class Downloader extends AppCompatActivity { } } - runOnUiThread(new Runnable() { - @Override - public void run() { - //simpleProgressBar.setProgress(100); - } - }); - //System.out.println("tree "+treelevel); - //System.out.println("prefix "+prefix); - } catch (Exception e) { e.printStackTrace(); //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/asgardius/page/s3manager/Uploader.java b/app/src/main/java/asgardius/page/s3manager/Uploader.java index 38cff49..73191d1 100644 --- a/app/src/main/java/asgardius/page/s3manager/Uploader.java +++ b/app/src/main/java/asgardius/page/s3manager/Uploader.java @@ -57,8 +57,9 @@ public class Uploader extends AppCompatActivity { File ufile; Intent intent; Button fileUpload; - Thread uploadFile; + Thread uploadFile, uploadProgress; boolean started = false; + long transfered = 0; private static final long MAX_SINGLE_PART_UPLOAD_BYTES = 5 * 1024 * 1024; private WifiManager.WifiLock mWifiLock; private PowerManager.WakeLock mWakeLock; @@ -103,6 +104,8 @@ public class Uploader extends AppCompatActivity { //simpleProgressBar.setVisibility(View.INVISIBLE); } else { started = true; + transfered = 0; + //simpleProgressBar.setProgress(0); simpleProgressBar.setVisibility(View.VISIBLE); if (fileuri == null && folder == null) { Toast.makeText(Uploader.this, getResources().getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show(); @@ -152,9 +155,10 @@ public class Uploader extends AppCompatActivity { mWakeLock.release(); //System.out.println("WakeLock released"); } - //simpleProgressBar.setProgress(100); - simpleProgressBar.setVisibility(View.INVISIBLE); + simpleProgressBar.setProgress(100); + //simpleProgressBar.setVisibility(View.INVISIBLE); fileUpload.setText(getResources().getString(R.string.upload_success)); + started = false; fileUpload.setEnabled(false); //Toast.makeText(getApplicationContext(),getResources().getString(R.string.upload_success), Toast.LENGTH_SHORT).show(); //simpleProgressBar.setVisibility(View.INVISIBLE); @@ -178,7 +182,8 @@ public class Uploader extends AppCompatActivity { mWakeLock.release(); //System.out.println("WakeLock released"); } - simpleProgressBar.setVisibility(View.INVISIBLE); + started = false; + //simpleProgressBar.setVisibility(View.INVISIBLE); //fileUpload.setEnabled(true); fileUpload.setText(getResources().getString(R.string.retry)); //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); @@ -189,8 +194,43 @@ public class Uploader extends AppCompatActivity { } } }); + uploadProgress = new Thread(new Runnable() { + + @Override + public void run() { + try { + //Your code goes here + while (started) { + try { + if (filesize != 0) { + //simpleProgressBar.setProgress((int)((transfered*100)/filesize)); + simpleProgressBar.setProgress((int)((transfered*100)/filesize)); + } + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } + } + + runOnUiThread(new Runnable() { + @Override + public void run() { + //simpleProgressBar.setProgress(100); + } + }); + //System.out.println("tree "+treelevel); + //System.out.println("prefix "+prefix); + + } catch (Exception e) { + e.printStackTrace(); + //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + //finish(); + } + } + }); //simpleProgressBar.setVisibility(View.VISIBLE); uploadFile.start(); + uploadProgress.start(); /*while (progress <= 99) { System.out.println("Upload in progress"); if (upload != null) { @@ -327,6 +367,7 @@ public class Uploader extends AppCompatActivity { partETags.add(uploadResult.getPartETag()); fileOffset += partSize; + transfered = fileOffset; } // Complete the multipart upload. diff --git a/app/src/main/res/layout/activity_uploader.xml b/app/src/main/res/layout/activity_uploader.xml index b74b7ae..44b3194 100644 --- a/app/src/main/res/layout/activity_uploader.xml +++ b/app/src/main/res/layout/activity_uploader.xml @@ -46,12 +46,13 @@