mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Fix urgent crashes A and E (#1749)
* Create utility class for contribution process * implement method to save five from given URİ * Add file utilities for directory checks * Add ContributionUtils for saving file during upload * Change method call acordingly with handleImagePicked() method * Call method to save file temproarily when a photo to upload is chosen from contributions list. * Call method to save file temproarily when a photo to upload is chosen from nearby list and map * Arrange method call * Write a method to save file temporarily during upload process. It will save the file to a internal path and it will be deleted by another method after upload process is done. * Add a method to save a file to a given path from a content provider Uri * On openAssetFileDescriptor method, use URi from temporarily saved file, instead of Contributions.getLocalUri which was Uri from content provider * Edit uploadContribution method so that it will use FileInputStream from temporarily saved file, insdeat of the Uri from content provider. * Make it work * Code cleanup * Add directory cleaner method * Call temp directory cleaner method at the end of uplpoad process * Use FileInputStream insted * Add directory cleaner method * Add file removal method * Use external directory instead * Make destination file name flexible * Make it work with share action coming from another activity * Make it work for Multiple hare Activity * Code cleanup * Solve camera issue * Fix camera crash * Cleanup * Revert change of commenting out posibly useles code, because I am not sure if it is useless or not. Requires discussion * Use timestamp in temoorary file names, so that we wont never create same file and access old file reference. It was a weird problem though * Code cleanup * Add nullable annotation to handleImagePicked method uri parameter * Add Nullable anotation to method * Code cleanup * Bugfix: use uri.getPath() instead uri.toString * Remove unecesarry file saving operation, which was added accidentally * Fix travis fail * Remove temp file if upload gets failed and file is still there * Code cleanup:Remove unused parameters from removeTempFile method * Empty temp directory on app create, in case some of files are still there * Add null check to array to prevent NPE on first run * Fix multiple uploads bug * Remove file if upload is succeed * Add external storage utility methods * Check external file permission before saving files temporarily * finish activity if permission is not granted * Add log lines * Remove files even if user decides to go back without sharing * Add easy null check * Change storage permission settings in singe upload fragment too * Finish app if permission is not granted * Code optimisation * Remove temp file if upload process never is finalised on activity stop * Bugfix maybe contribution is never created * Fix travis build
This commit is contained in:
parent
22d2b1795c
commit
d29aa2e2e5
18 changed files with 440 additions and 66 deletions
|
|
@ -27,6 +27,7 @@ import fr.free.nrw.commons.data.DBOpenHelper;
|
|||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||
import fr.free.nrw.commons.modifications.ModifierSequenceDao;
|
||||
import fr.free.nrw.commons.upload.FileUtils;
|
||||
import fr.free.nrw.commons.utils.ContributionUtils;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
|
@ -68,7 +69,6 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
ApplicationlessInjection
|
||||
.getInstance(this)
|
||||
.getCommonsApplicationComponent()
|
||||
|
|
@ -81,6 +81,8 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
if (setupLeakCanary() == RefWatcher.DISABLED) {
|
||||
return;
|
||||
}
|
||||
// Empty temp directory in case some temp files are created and never removed.
|
||||
ContributionUtils.emptyTemporaryDirectory();
|
||||
|
||||
Timber.plant(new Timber.DebugTree());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue