|
@ -6,6 +6,7 @@ import android.content.Context; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
|
import android.content.SharedPreferences; |
|
|
import android.content.SharedPreferences; |
|
|
import android.content.pm.PackageManager; |
|
|
import android.content.pm.PackageManager; |
|
|
|
|
|
import android.graphics.Typeface; |
|
|
import android.graphics.drawable.Drawable; |
|
|
import android.graphics.drawable.Drawable; |
|
|
import android.net.Uri; |
|
|
import android.net.Uri; |
|
|
import android.os.AsyncTask; |
|
|
import android.os.AsyncTask; |
|
@ -73,6 +74,7 @@ import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUND |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_DESCRIPTION; |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_DESCRIPTION; |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_FILENAME; |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_FILENAME; |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_TITLE; |
|
|
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_TITLE; |
|
|
|
|
|
import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; |
|
|
|
|
|
|
|
|
public class UploadActivity extends BaseActivity { |
|
|
public class UploadActivity extends BaseActivity { |
|
|
/** |
|
|
/** |
|
@ -391,8 +393,9 @@ public class UploadActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String uploadID = UUID.randomUUID().toString(); |
|
|
String uploadID = UUID.randomUUID().toString(); |
|
|
if (uploadFile(this, uploadID, getConfigForUpload(this, uploadID), categorySelected, |
|
|
if (uploadFile(this, uploadID, getConfigForUpload(this, uploadID, |
|
|
uploadTitleText, uploadDescriptionText[0], fileIcon, uploaderProfileIndex, |
|
|
editTextFilename), categorySelected, uploadTitleText, |
|
|
|
|
|
uploadDescriptionText[0], fileIcon, uploaderProfileIndex, |
|
|
tempFileUri == null |
|
|
tempFileUri == null |
|
|
? filesList.get(0).getFileUri() |
|
|
? filesList.get(0).getFileUri() |
|
|
: tempFileUri)) { |
|
|
: tempFileUri)) { |
|
@ -449,12 +452,8 @@ public class UploadActivity extends BaseActivity { |
|
|
@Override |
|
|
@Override |
|
|
protected void onDestroy() { |
|
|
protected void onDestroy() { |
|
|
super.onDestroy(); |
|
|
super.onDestroy(); |
|
|
if (parseUploadPageTask != null && parseUploadPageTask.getStatus() != AsyncTask.Status.RUNNING) |
|
|
if (parseUploadPageTask != null && parseUploadPageTask.getStatus() != AsyncTask.Status.RUNNING) { |
|
|
parseUploadPageTask.cancel(true); |
|
|
parseUploadPageTask.cancel(true); |
|
|
|
|
|
|
|
|
//Deletes any photo file previously created, as it is not going to be used
|
|
|
|
|
|
if (photoFileCreated != null) { |
|
|
|
|
|
storage.deleteFile(photoFileCreated.getAbsolutePath()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -644,9 +643,9 @@ public class UploadActivity extends BaseActivity { |
|
|
inflate(R.layout.activity_upload_file_list_row, null); |
|
|
inflate(R.layout.activity_upload_file_list_row, null); |
|
|
|
|
|
|
|
|
TextView itemText = newFileRow.findViewById(R.id.upload_file_item_text); |
|
|
TextView itemText = newFileRow.findViewById(R.id.upload_file_item_text); |
|
|
Drawable filenameDrawable = AppCompatResources.getDrawable(this, R.drawable.ic_attach_file_white_24dp); |
|
|
itemText.setTypeface(Typeface.createFromAsset(this.getAssets() |
|
|
itemText.setCompoundDrawablesRelativeWithIntrinsicBounds(filenameDrawable, null, null, null); |
|
|
, "fonts/fontawesome-webfont.ttf")); |
|
|
itemText.setText(filename); |
|
|
itemText.setText(faIconFromFilename(this, filename) + " " + filename); |
|
|
|
|
|
|
|
|
newFileRow.findViewById(R.id.upload_file_item_remove). |
|
|
newFileRow.findViewById(R.id.upload_file_item_remove). |
|
|
setOnClickListener(view -> { |
|
|
setOnClickListener(view -> { |
|
@ -669,9 +668,10 @@ public class UploadActivity extends BaseActivity { |
|
|
filesListView.setVisibility(View.VISIBLE); |
|
|
filesListView.setVisibility(View.VISIBLE); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static UploadNotificationConfig getConfigForUpload(Context context, String uploadID) { |
|
|
private static UploadNotificationConfig getConfigForUpload(Context context, String uploadID, String filename) { |
|
|
UploadNotificationConfig uploadNotificationConfig = new UploadNotificationConfig(); |
|
|
UploadNotificationConfig uploadNotificationConfig = new UploadNotificationConfig(); |
|
|
uploadNotificationConfig.setIconForAllStatuses(android.R.drawable.stat_sys_upload); |
|
|
uploadNotificationConfig.setIconForAllStatuses(android.R.drawable.stat_sys_upload); |
|
|
|
|
|
uploadNotificationConfig.setTitleForAllStatuses("Uploading " + filename); |
|
|
|
|
|
|
|
|
uploadNotificationConfig.getProgress().iconResourceID = android.R.drawable.stat_sys_upload; |
|
|
uploadNotificationConfig.getProgress().iconResourceID = android.R.drawable.stat_sys_upload; |
|
|
uploadNotificationConfig.getCompleted().iconResourceID = android.R.drawable.stat_sys_upload_done; |
|
|
uploadNotificationConfig.getCompleted().iconResourceID = android.R.drawable.stat_sys_upload_done; |
|
@ -680,7 +680,6 @@ public class UploadActivity extends BaseActivity { |
|
|
uploadNotificationConfig.getCancelled().iconColorResourceID = android.R.drawable.stat_sys_upload_done; |
|
|
uploadNotificationConfig.getCancelled().iconColorResourceID = android.R.drawable.stat_sys_upload_done; |
|
|
|
|
|
|
|
|
Intent combinedActionsIntent = new Intent(UploadsReceiver.ACTION_COMBINED_UPLOAD); |
|
|
Intent combinedActionsIntent = new Intent(UploadsReceiver.ACTION_COMBINED_UPLOAD); |
|
|
//combinedActionsIntent.setAction(UploadsReceiver.ACTION_COMBINED_UPLOAD);
|
|
|
|
|
|
combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); |
|
|
combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); |
|
|
|
|
|
|
|
|
uploadNotificationConfig.setClickIntentForAllStatuses(PendingIntent.getBroadcast(context, |
|
|
uploadNotificationConfig.setClickIntentForAllStatuses(PendingIntent.getBroadcast(context, |
|
@ -1009,7 +1008,7 @@ public class UploadActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
String uploadID = UUID.randomUUID().toString(); |
|
|
String uploadID = UUID.randomUUID().toString(); |
|
|
if (!uploadFile(weakActivity.get(), uploadID, |
|
|
if (!uploadFile(weakActivity.get(), uploadID, |
|
|
getConfigForUpload(weakActivity.get(), uploadID), categorySelected, |
|
|
getConfigForUpload(weakActivity.get(), uploadID, zipFilename), categorySelected, |
|
|
uploadTitleText, uploadDescriptionText, fileIcon, uploaderProfileIndex, |
|
|
uploadTitleText, uploadDescriptionText, fileIcon, uploaderProfileIndex, |
|
|
zipFileUri)) { |
|
|
zipFileUri)) { |
|
|
Toast.makeText(weakActivity.get(), "Couldn't initiate upload.", Toast.LENGTH_SHORT).show(); |
|
|
Toast.makeText(weakActivity.get(), "Couldn't initiate upload.", Toast.LENGTH_SHORT).show(); |
|
|