Skip to content

Commit

Permalink
Merge pull request #543 from jorgeblacio/release_0_21_9
Browse files Browse the repository at this point in the history
Final fix before release
  • Loading branch information
danieltigse authored Sep 13, 2019
2 parents d549b38 + d3cd749 commit 66e6c51
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class AuthenticateUserWorker(
else -> UIMessage(resId = R.string.server_bad_status, args = arrayOf(ex.errorCode))
}
}
else -> UIMessage(resId = R.string.login_fail_try_again_error_exception)
else -> UIMessage(resId = R.string.login_fail_try_again_error_with_exception, args = arrayOf(ex.toString()))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,25 @@ import java.util.*


class CloudBackupJobService: Job() {
private var dataSource: CloudBackupDataSource? = null
private var mDriveService: Drive? = null
private val progressListener = JobServiceProgressListener()
private var hasOldFile = false
private var isBackupDone = false
private var oldFileIds: List<String> = listOf()
private var builder: NotificationCompat.Builder? = null

private fun getAccountsSavedData(storage: KeyValueStorage): MutableList<JobIdData> {
val savedJobsString = storage.getString(KeyValueStorage.StringKey.SavedJobs, "")
return if(savedJobsString.isEmpty()) mutableListOf()
else JobIdData.fromJson(savedJobsString)
}

private fun deleteJobForMissingAccount(accountId: Long, storage: KeyValueStorage){
val jobList = getAccountsSavedData(storage)
val job = jobList.find { it.accountId == accountId } ?: return
jobList.remove(job)
cancel(context, accountId)
}

private fun handleNewPushNotification(activeAccount: ActiveAccount, storage: KeyValueStorage,
upTickCounter: Boolean = true){
val data = PushData.JobBackup(
Expand Down Expand Up @@ -199,9 +204,9 @@ class CloudBackupJobService: Job() {

private fun startWorking(accountId: Long){
val db = AppDatabase.getAppDatabase(context)
val account = db.accountDao().getAccountById(accountId)!!
val activeAccount = ActiveAccount.loadFromDB(account)!!
val storage = KeyValueStorage.SharedPrefs(context)
val account = db.accountDao().getAccountById(accountId) ?: return deleteJobForMissingAccount(accountId, storage)
val activeAccount = ActiveAccount.loadFromDB(account)!!

handleNewPushNotification(activeAccount, storage)

Expand Down Expand Up @@ -280,7 +285,6 @@ class CloudBackupJobService: Job() {

companion object {
const val JOB_TAG = "CRIPTEXT_CLOUD_BACKUP_JOB_SERVICE"
const val PROGRESS_MAX = 100

fun cancelJob(storage: KeyValueStorage, accountId: Long){
val savedJobsString = storage.getString(KeyValueStorage.StringKey.SavedJobs, "")
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
<string name="login_network_error_exception">Fallo al autenticar usuario. Por favor, verifica tu conexión de internet.</string>
<string name="login_json_error_exception">Fallo al autenticar usuario. Respuesta del servidor inválida.</string>
<string name="login_fail_try_again_error_exception">Fallo al autenticar usuario. Por favor, intenta más tarde.</string>
<string name="login_fail_try_again_error_with_exception">Fallo al autenticar usuario. Error: %1$s.</string>
<string name="login_failed_body">Tu intento de acceder a esta cuenta fue negado por un dispositivo aprobado.</string>
<string name="login_user">[email protected]</string>
<string name="button_confirm">Confirmar</string>
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
<string name="login_network_error_exception">Failed to authenticate user. Please check your internet connection.</string>
<string name="login_json_error_exception">Failed to authenticate user. Invalid server response.</string>
<string name="login_fail_try_again_error_exception">Failed to authenticate user. Please try again later.</string>
<string name="login_fail_try_again_error_with_exception">Failed to authenticate user. Error: %1$s.</string>
<string name="login_failed_body">Your request to access this account was rejected by a verified device.</string>
<string name="login_user">[email protected]</string>
<string name="button_confirm">Confirm</string>
Expand Down

0 comments on commit 66e6c51

Please sign in to comment.