|
@ -12,14 +12,6 @@ import android.net.Uri; |
|
|
import android.os.AsyncTask; |
|
|
import android.os.AsyncTask; |
|
|
import android.os.Build; |
|
|
import android.os.Build; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
import androidx.annotation.NonNull; |
|
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton; |
|
|
|
|
|
import androidx.core.content.FileProvider; |
|
|
|
|
|
import androidx.appcompat.app.AlertDialog; |
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources; |
|
|
|
|
|
import androidx.preference.PreferenceManager; |
|
|
|
|
|
import androidx.appcompat.widget.AppCompatButton; |
|
|
|
|
|
import androidx.appcompat.widget.AppCompatImageButton; |
|
|
|
|
|
import android.text.Editable; |
|
|
import android.text.Editable; |
|
|
import android.text.Spannable; |
|
|
import android.text.Spannable; |
|
|
import android.text.TextWatcher; |
|
|
import android.text.TextWatcher; |
|
@ -37,6 +29,16 @@ import android.widget.ProgressBar; |
|
|
import android.widget.TextView; |
|
|
import android.widget.TextView; |
|
|
import android.widget.Toast; |
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
|
import androidx.appcompat.app.AlertDialog; |
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources; |
|
|
|
|
|
import androidx.appcompat.widget.AppCompatButton; |
|
|
|
|
|
import androidx.appcompat.widget.AppCompatImageButton; |
|
|
|
|
|
import androidx.core.content.FileProvider; |
|
|
|
|
|
import androidx.preference.PreferenceManager; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton; |
|
|
|
|
|
|
|
|
import net.gotev.uploadservice.MultipartUploadRequest; |
|
|
import net.gotev.uploadservice.MultipartUploadRequest; |
|
|
import net.gotev.uploadservice.UploadNotificationAction; |
|
|
import net.gotev.uploadservice.UploadNotificationAction; |
|
|
import net.gotev.uploadservice.UploadNotificationConfig; |
|
|
import net.gotev.uploadservice.UploadNotificationConfig; |
|
@ -91,9 +93,10 @@ public class UploadActivity extends BaseActivity { |
|
|
private static final int AFR_REQUEST_CODE_FIELDS_BUILDER = 74; //Arbitrary, application specific
|
|
|
private static final int AFR_REQUEST_CODE_FIELDS_BUILDER = 74; //Arbitrary, application specific
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Request code to gain read/write permission |
|
|
* Request codes to gain camera and read/write permission |
|
|
*/ |
|
|
*/ |
|
|
private static final int UPLOAD_REQUEST_CODE = 42; //Arbitrary, application specific
|
|
|
private static final int UPLOAD_REQUEST_CAMERA_CODE = 42; //Arbitrary, application specific
|
|
|
|
|
|
private static final int UPLOAD_REQUEST_STORAGE_CODE = 12; //Arbitrary, application specific
|
|
|
|
|
|
|
|
|
private static final int MAX_FILE_SIZE_SUPPORTED = 45000000; |
|
|
private static final int MAX_FILE_SIZE_SUPPORTED = 45000000; |
|
|
|
|
|
|
|
@ -111,6 +114,8 @@ public class UploadActivity extends BaseActivity { |
|
|
private CustomTextWatcher textWatcher; |
|
|
private CustomTextWatcher textWatcher; |
|
|
private boolean hasModifiedFilename = false; |
|
|
private boolean hasModifiedFilename = false; |
|
|
|
|
|
|
|
|
|
|
|
private ZipTask zipTask; |
|
|
|
|
|
|
|
|
//UI elements
|
|
|
//UI elements
|
|
|
private MaterialProgressBar progressBar; |
|
|
private MaterialProgressBar progressBar; |
|
|
private LinearLayout categoriesSpinners; |
|
|
private LinearLayout categoriesSpinners; |
|
@ -280,7 +285,7 @@ public class UploadActivity extends BaseActivity { |
|
|
if (checkPerms()) |
|
|
if (checkPerms()) |
|
|
takePhoto(); |
|
|
takePhoto(); |
|
|
else |
|
|
else |
|
|
requestPerms(UPLOAD_REQUEST_CODE); |
|
|
requestPerms(UPLOAD_REQUEST_CAMERA_CODE); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
FloatingActionButton uploadFAB = findViewById(R.id.upload_fab); |
|
|
FloatingActionButton uploadFAB = findViewById(R.id.upload_fab); |
|
@ -386,10 +391,18 @@ public class UploadActivity extends BaseActivity { |
|
|
filesListArray[i] = filesList.get(i).getFileUri(); |
|
|
filesListArray[i] = filesList.get(i).getFileUri(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
new ZipTask(this, editTextFilename, categorySelected, |
|
|
zipTask = new ZipTask(this, editTextFilename, categorySelected, |
|
|
uploadTitleText, uploadDescriptionText[0], fileIcon, |
|
|
uploadTitleText, uploadDescriptionText[0], fileIcon, |
|
|
uploaderProfileIndex).execute(filesListArray); |
|
|
uploaderProfileIndex); |
|
|
finish(); |
|
|
|
|
|
|
|
|
if (checkPerms()) { |
|
|
|
|
|
zipTask.execute(filesListArray); |
|
|
|
|
|
finish(); |
|
|
|
|
|
} else { |
|
|
|
|
|
requestPerms(UPLOAD_REQUEST_STORAGE_CODE); |
|
|
|
|
|
dialog.cancel(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -590,10 +603,22 @@ public class UploadActivity extends BaseActivity { |
|
|
public void onRequestPermissionsResult(int permsRequestCode, @NonNull String[] permissions |
|
|
public void onRequestPermissionsResult(int permsRequestCode, @NonNull String[] permissions |
|
|
, @NonNull int[] grantResults) { |
|
|
, @NonNull int[] grantResults) { |
|
|
switch (permsRequestCode) { |
|
|
switch (permsRequestCode) { |
|
|
case UPLOAD_REQUEST_CODE: |
|
|
case UPLOAD_REQUEST_CAMERA_CODE: |
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) |
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) |
|
|
takePhoto(); |
|
|
takePhoto(); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case UPLOAD_REQUEST_STORAGE_CODE: |
|
|
|
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && |
|
|
|
|
|
zipTask != null) { |
|
|
|
|
|
Uri[] filesListArray = new Uri[filesList.size()]; |
|
|
|
|
|
for (int i = 0; i < filesList.size(); ++i) { |
|
|
|
|
|
filesListArray[i] = filesList.get(i).getFileUri(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
zipTask.execute(filesListArray); |
|
|
|
|
|
finish(); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|