Upload instantly when auto upload enabled and vault unlocked (#181)
This commit is contained in:
parent
e60333865f
commit
8ebee7bfc2
@ -120,6 +120,17 @@ class CryptomatorApp : MultiDexApplication(), HasComponent<ApplicationComponent>
|
|||||||
}, BIND_AUTO_CREATE)
|
}, BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun startAutoUpload() {
|
||||||
|
val sharedPreferencesHandler = SharedPreferencesHandler(applicationContext())
|
||||||
|
if(sharedPreferencesHandler.usePhotoUpload()) {
|
||||||
|
val vault = applicationComponent.vaultRepository().load(sharedPreferencesHandler.photoUploadVault())
|
||||||
|
if(vault.isUnlocked) {
|
||||||
|
val cloud = applicationComponent.cloudRepository().decryptedViewOf(vault)
|
||||||
|
applicationContext().startService(AutoUploadService.startAutoUploadIntent(applicationContext(), cloud))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupLogging() {
|
private fun setupLogging() {
|
||||||
setupLoggingFramework()
|
setupLoggingFramework()
|
||||||
setup()
|
setup()
|
||||||
|
@ -212,7 +212,7 @@ public class AutoUploadService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Timber.tag("AutoUploadService").d("created");
|
Timber.tag("AutoUploadService").d("created");
|
||||||
notification = new AutoUploadNotification(this, 5);
|
notification = new AutoUploadNotification(this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@ import android.net.Uri
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import org.cryptomator.domain.exception.FatalBackendException
|
import org.cryptomator.domain.exception.FatalBackendException
|
||||||
|
import org.cryptomator.presentation.CryptomatorApp
|
||||||
import org.cryptomator.presentation.R
|
import org.cryptomator.presentation.R
|
||||||
import org.cryptomator.presentation.util.FileUtil
|
import org.cryptomator.presentation.util.FileUtil
|
||||||
import org.cryptomator.presentation.util.ResourceHelper
|
import org.cryptomator.presentation.util.ResourceHelper
|
||||||
@ -38,6 +39,8 @@ class PhotoContentJob : JobService() {
|
|||||||
|
|
||||||
runningParams = params
|
runningParams = params
|
||||||
|
|
||||||
|
var filesCaptured = false
|
||||||
|
|
||||||
params.triggeredContentAuthorities?.let {
|
params.triggeredContentAuthorities?.let {
|
||||||
if (params.triggeredContentUris != null) {
|
if (params.triggeredContentUris != null) {
|
||||||
val ids = getIds(params)
|
val ids = getIds(params)
|
||||||
@ -49,6 +52,8 @@ class PhotoContentJob : JobService() {
|
|||||||
fileUtil.addImageToAutoUploads(dir)
|
fileUtil.addImageToAutoUploads(dir)
|
||||||
Timber.tag("PhotoContentJob").i("Added file to UploadList")
|
Timber.tag("PhotoContentJob").i("Added file to UploadList")
|
||||||
Timber.tag("PhotoContentJob").d(String.format("Added file to UploadList %s", dir))
|
Timber.tag("PhotoContentJob").d(String.format("Added file to UploadList %s", dir))
|
||||||
|
|
||||||
|
filesCaptured = true
|
||||||
} catch (e: FatalBackendException) {
|
} catch (e: FatalBackendException) {
|
||||||
Timber.tag("PhotoContentJob").e(e, "Failed to add image to auto upload list")
|
Timber.tag("PhotoContentJob").e(e, "Failed to add image to auto upload list")
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
@ -65,6 +70,10 @@ class PhotoContentJob : JobService() {
|
|||||||
}
|
}
|
||||||
} ?: Timber.tag("PhotoContentJob").w("No photos content")
|
} ?: Timber.tag("PhotoContentJob").w("No photos content")
|
||||||
|
|
||||||
|
if(filesCaptured && SharedPreferencesHandler(applicationContext).usePhotoUploadInstant()) {
|
||||||
|
(application as CryptomatorApp).startAutoUpload()
|
||||||
|
}
|
||||||
|
|
||||||
handler.post(worker)
|
handler.post(worker)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,8 @@
|
|||||||
<string name="screen_settings_section_auto_photo_upload_vault">Choose vault for upload</string>
|
<string name="screen_settings_section_auto_photo_upload_vault">Choose vault for upload</string>
|
||||||
<string name="screen_settings_section_auto_photo_upload_toggle">Activate</string>
|
<string name="screen_settings_section_auto_photo_upload_toggle">Activate</string>
|
||||||
<string name="screen_settings_section_auto_photo_upload_toggle_summary">Capture images in the background and once the selected vault is unlocked, start upload</string>
|
<string name="screen_settings_section_auto_photo_upload_toggle_summary">Capture images in the background and once the selected vault is unlocked, start upload</string>
|
||||||
|
<string name="screen_settings_section_auto_photo_upload_toggle_instant_upload">Upload instant</string>
|
||||||
|
<string name="screen_settings_section_auto_photo_upload_toggle_instant_upload_summary">Upload directly if the vault is unlocked</string>
|
||||||
<string name="screen_settings_section_auto_photo_upload_only_wifi_toggle">Upload only using WIFI</string>
|
<string name="screen_settings_section_auto_photo_upload_only_wifi_toggle">Upload only using WIFI</string>
|
||||||
<string name="screen_settings_section_auto_photo_upload_including_videos">Upload videos</string>
|
<string name="screen_settings_section_auto_photo_upload_including_videos">Upload videos</string>
|
||||||
|
|
||||||
|
@ -105,6 +105,12 @@
|
|||||||
android:summary="@string/screen_settings_section_auto_photo_upload_toggle_summary"
|
android:summary="@string/screen_settings_section_auto_photo_upload_toggle_summary"
|
||||||
android:title="@string/screen_settings_section_auto_photo_upload_toggle" />
|
android:title="@string/screen_settings_section_auto_photo_upload_toggle" />
|
||||||
|
|
||||||
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="photoUploadInstant"
|
||||||
|
android:summary="@string/screen_settings_section_auto_photo_upload_toggle_instant_upload_summary"
|
||||||
|
android:title="@string/screen_settings_section_auto_photo_upload_toggle_instant_upload" />
|
||||||
|
|
||||||
<androidx.preference.SwitchPreferenceCompat
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="photoUploadOnlyUsingWifi"
|
android:key="photoUploadOnlyUsingWifi"
|
||||||
|
@ -129,14 +129,18 @@ constructor(context: Context) : SharedPreferences.OnSharedPreferenceChangeListen
|
|||||||
defaultSharedPreferences.clear()
|
defaultSharedPreferences.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun autoPhotoUploadOnlyUsingWifi(): Boolean {
|
|
||||||
return defaultSharedPreferences.getValue(PHOTO_UPLOAD_ONLY_USING_WIFI)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun usePhotoUpload(): Boolean {
|
fun usePhotoUpload(): Boolean {
|
||||||
return defaultSharedPreferences.getValue(PHOTO_UPLOAD, false)
|
return defaultSharedPreferences.getValue(PHOTO_UPLOAD, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun usePhotoUploadInstant(): Boolean {
|
||||||
|
return defaultSharedPreferences.getValue(PHOTO_UPLOAD_INSTANT, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun autoPhotoUploadOnlyUsingWifi(): Boolean {
|
||||||
|
return defaultSharedPreferences.getValue(PHOTO_UPLOAD_ONLY_USING_WIFI)
|
||||||
|
}
|
||||||
|
|
||||||
fun photoUploadVault(): Long {
|
fun photoUploadVault(): Long {
|
||||||
return defaultSharedPreferences.getValue(PHOTO_UPLOAD_VAULT, 0)
|
return defaultSharedPreferences.getValue(PHOTO_UPLOAD_VAULT, 0)
|
||||||
}
|
}
|
||||||
@ -249,6 +253,7 @@ constructor(context: Context) : SharedPreferences.OnSharedPreferenceChangeListen
|
|||||||
const val SECURE_SCREEN = "secureScreen"
|
const val SECURE_SCREEN = "secureScreen"
|
||||||
const val SCREEN_STYLE_MODE = "screenStyleMode"
|
const val SCREEN_STYLE_MODE = "screenStyleMode"
|
||||||
const val PHOTO_UPLOAD = "photoUpload"
|
const val PHOTO_UPLOAD = "photoUpload"
|
||||||
|
const val PHOTO_UPLOAD_INSTANT = "photoUploadInstant"
|
||||||
const val PHOTO_UPLOAD_ONLY_USING_WIFI = "photoUploadOnlyUsingWifi"
|
const val PHOTO_UPLOAD_ONLY_USING_WIFI = "photoUploadOnlyUsingWifi"
|
||||||
const val PHOTO_UPLOAD_VAULT = "photoUploadVault"
|
const val PHOTO_UPLOAD_VAULT = "photoUploadVault"
|
||||||
const val PHOTO_UPLOAD_FOLDER = "photoUploadFolder"
|
const val PHOTO_UPLOAD_FOLDER = "photoUploadFolder"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user