Loading app/src/main/java/foundation/e/drive/account/AccountAdder.kt +4 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import foundation.e.drive.utils.AppConstants import foundation.e.drive.utils.DavClientProvider import foundation.e.drive.work.WorkLauncher import timber.log.Timber import androidx.core.content.edit class AccountAdder(private val context: Context) { Loading @@ -48,9 +49,9 @@ class AccountAdder(private val context: Context) { } private fun updateAccountNameOnPreference(name: String) { preferences.edit() .putString(AccountManager.KEY_ACCOUNT_NAME, name) .apply() preferences.edit { putString(AccountManager.KEY_ACCOUNT_NAME, name) } } /** Loading app/src/main/java/foundation/e/drive/account/AccountRemover.kt +8 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import foundation.e.drive.utils.AppConstants.SETUP_COMPLETED import foundation.e.drive.utils.DavClientProvider import timber.log.Timber import java.io.File import androidx.core.content.edit class AccountRemover( private val context: Context, Loading Loading @@ -74,12 +75,13 @@ class AccountRemover( private fun cleanSharedPreferences() { if (!context.applicationContext.deleteSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME)) { //If removal failed, clear all data inside preferences.edit().remove(AccountManager.KEY_ACCOUNT_NAME) preferences.edit { remove(AccountManager.KEY_ACCOUNT_NAME) .remove(AccountManager.KEY_ACCOUNT_TYPE) .remove(SETUP_COMPLETED) .remove(INITIAL_FOLDER_NUMBER) .remove(AppConstants.KEY_LAST_SCAN_TIME) .apply() } } context.applicationContext.deleteSharedPreferences(FailedSyncPrefsManager.PREF_NAME) } Loading app/src/main/java/foundation/e/drive/activity/AccountsActivity.java +5 −9 Original line number Diff line number Diff line Loading @@ -13,9 +13,6 @@ import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_EMAIL; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_NAME; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_TOTAL_QUOTA_KEY; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_USED_QUOTA_KEY; import static foundation.e.drive.widgets.EDriveWidget.buildIntent; import static foundation.e.drive.widgets.EDriveWidget.convertIntoMB; import static foundation.e.drive.widgets.EDriveWidget.dataForWeb; import android.accounts.Account; import android.accounts.AccountManager; Loading Loading @@ -61,7 +58,7 @@ public class AccountsActivity extends AppCompatActivity { binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); binding.settings.setOnClickListener(v -> { final Intent settingsIntent = buildIntent("", "") final Intent settingsIntent = EDriveWidget.buildIntent("", "") .setComponent(new ComponentName( ACCOUNT_MANAGER_PACKAGE_NAME, ACCOUNT_SETTINGS)); startActivity(settingsIntent); Loading Loading @@ -89,8 +86,8 @@ public class AccountsActivity extends AppCompatActivity { binding.name.setText(name); binding.email.setText(email); binding.progress.setMax(convertIntoMB(totalQuota)); binding.progress.setProgress(convertIntoMB(usedQuota)); binding.progress.setMax(EDriveWidget.convertIntoMB(totalQuota)); binding.progress.setProgress(EDriveWidget.convertIntoMB(usedQuota)); binding.progress.setVisibility(View.VISIBLE); String totalShownQuota = "?"; Loading Loading @@ -141,9 +138,8 @@ public class AccountsActivity extends AppCompatActivity { binding.upgrade.setVisibility(View.VISIBLE); binding.upgrade.setOnClickListener(v -> { final Intent upgradeIntent = buildIntent(Intent.ACTION_VIEW, String.format(EDriveWidget.WEBPAGE, email, token, dataForWeb(totalQuota))); final Intent upgradeIntent = EDriveWidget.buildIntent(Intent.ACTION_VIEW, EDriveWidget.buildUpgradeUrl(email, token, totalQuota)); startActivity(upgradeIntent); }); Loading app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt +4 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import foundation.e.drive.utils.AppConstants.KEY_LAST_SCAN_TIME import foundation.e.drive.utils.CommonUtils import foundation.e.drive.utils.DavClientProvider import timber.log.Timber import androidx.core.content.edit class FullScanWorker(private val context: Context, private val workerParams: WorkerParameters) : Worker(context, workerParams) Loading Loading @@ -73,9 +74,9 @@ class FullScanWorker(private val context: Context, private val workerParams: Wor syncRequests.putAll(localSyncRequests) Timber.d("${localSyncRequests.size} request collected from device") prefs.edit() .putLong(KEY_LAST_SCAN_TIME, System.currentTimeMillis()) .apply(); prefs.edit { putLong(KEY_LAST_SCAN_TIME, System.currentTimeMillis()) } if (syncRequests.isEmpty()) { Timber.d("Nothing to sync") Loading app/src/main/java/foundation/e/drive/recovery/RecoveryPreferences.kt +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package foundation.e.drive.recovery import android.content.Context import foundation.e.drive.recovery.RecoveryPreferences.RecoveryStatus.RecoveryCompleted import foundation.e.drive.recovery.RecoveryPreferences.RecoveryStatus.RecoveryNeeded import androidx.core.content.edit object RecoveryPreferences { Loading @@ -44,11 +45,11 @@ object RecoveryPreferences { context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE) when (status) { RecoveryCompleted -> { preferences.edit().putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, true).apply() preferences.edit { putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, true) } } RecoveryNeeded -> { preferences.edit().putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, false).apply() preferences.edit { putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, false) } } } } Loading Loading
app/src/main/java/foundation/e/drive/account/AccountAdder.kt +4 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import foundation.e.drive.utils.AppConstants import foundation.e.drive.utils.DavClientProvider import foundation.e.drive.work.WorkLauncher import timber.log.Timber import androidx.core.content.edit class AccountAdder(private val context: Context) { Loading @@ -48,9 +49,9 @@ class AccountAdder(private val context: Context) { } private fun updateAccountNameOnPreference(name: String) { preferences.edit() .putString(AccountManager.KEY_ACCOUNT_NAME, name) .apply() preferences.edit { putString(AccountManager.KEY_ACCOUNT_NAME, name) } } /** Loading
app/src/main/java/foundation/e/drive/account/AccountRemover.kt +8 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import foundation.e.drive.utils.AppConstants.SETUP_COMPLETED import foundation.e.drive.utils.DavClientProvider import timber.log.Timber import java.io.File import androidx.core.content.edit class AccountRemover( private val context: Context, Loading Loading @@ -74,12 +75,13 @@ class AccountRemover( private fun cleanSharedPreferences() { if (!context.applicationContext.deleteSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME)) { //If removal failed, clear all data inside preferences.edit().remove(AccountManager.KEY_ACCOUNT_NAME) preferences.edit { remove(AccountManager.KEY_ACCOUNT_NAME) .remove(AccountManager.KEY_ACCOUNT_TYPE) .remove(SETUP_COMPLETED) .remove(INITIAL_FOLDER_NUMBER) .remove(AppConstants.KEY_LAST_SCAN_TIME) .apply() } } context.applicationContext.deleteSharedPreferences(FailedSyncPrefsManager.PREF_NAME) } Loading
app/src/main/java/foundation/e/drive/activity/AccountsActivity.java +5 −9 Original line number Diff line number Diff line Loading @@ -13,9 +13,6 @@ import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_EMAIL; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_NAME; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_TOTAL_QUOTA_KEY; import static foundation.e.drive.utils.AppConstants.ACCOUNT_DATA_USED_QUOTA_KEY; import static foundation.e.drive.widgets.EDriveWidget.buildIntent; import static foundation.e.drive.widgets.EDriveWidget.convertIntoMB; import static foundation.e.drive.widgets.EDriveWidget.dataForWeb; import android.accounts.Account; import android.accounts.AccountManager; Loading Loading @@ -61,7 +58,7 @@ public class AccountsActivity extends AppCompatActivity { binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); binding.settings.setOnClickListener(v -> { final Intent settingsIntent = buildIntent("", "") final Intent settingsIntent = EDriveWidget.buildIntent("", "") .setComponent(new ComponentName( ACCOUNT_MANAGER_PACKAGE_NAME, ACCOUNT_SETTINGS)); startActivity(settingsIntent); Loading Loading @@ -89,8 +86,8 @@ public class AccountsActivity extends AppCompatActivity { binding.name.setText(name); binding.email.setText(email); binding.progress.setMax(convertIntoMB(totalQuota)); binding.progress.setProgress(convertIntoMB(usedQuota)); binding.progress.setMax(EDriveWidget.convertIntoMB(totalQuota)); binding.progress.setProgress(EDriveWidget.convertIntoMB(usedQuota)); binding.progress.setVisibility(View.VISIBLE); String totalShownQuota = "?"; Loading Loading @@ -141,9 +138,8 @@ public class AccountsActivity extends AppCompatActivity { binding.upgrade.setVisibility(View.VISIBLE); binding.upgrade.setOnClickListener(v -> { final Intent upgradeIntent = buildIntent(Intent.ACTION_VIEW, String.format(EDriveWidget.WEBPAGE, email, token, dataForWeb(totalQuota))); final Intent upgradeIntent = EDriveWidget.buildIntent(Intent.ACTION_VIEW, EDriveWidget.buildUpgradeUrl(email, token, totalQuota)); startActivity(upgradeIntent); }); Loading
app/src/main/java/foundation/e/drive/periodicScan/FullScanWorker.kt +4 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import foundation.e.drive.utils.AppConstants.KEY_LAST_SCAN_TIME import foundation.e.drive.utils.CommonUtils import foundation.e.drive.utils.DavClientProvider import timber.log.Timber import androidx.core.content.edit class FullScanWorker(private val context: Context, private val workerParams: WorkerParameters) : Worker(context, workerParams) Loading Loading @@ -73,9 +74,9 @@ class FullScanWorker(private val context: Context, private val workerParams: Wor syncRequests.putAll(localSyncRequests) Timber.d("${localSyncRequests.size} request collected from device") prefs.edit() .putLong(KEY_LAST_SCAN_TIME, System.currentTimeMillis()) .apply(); prefs.edit { putLong(KEY_LAST_SCAN_TIME, System.currentTimeMillis()) } if (syncRequests.isEmpty()) { Timber.d("Nothing to sync") Loading
app/src/main/java/foundation/e/drive/recovery/RecoveryPreferences.kt +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package foundation.e.drive.recovery import android.content.Context import foundation.e.drive.recovery.RecoveryPreferences.RecoveryStatus.RecoveryCompleted import foundation.e.drive.recovery.RecoveryPreferences.RecoveryStatus.RecoveryNeeded import androidx.core.content.edit object RecoveryPreferences { Loading @@ -44,11 +45,11 @@ object RecoveryPreferences { context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE) when (status) { RecoveryCompleted -> { preferences.edit().putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, true).apply() preferences.edit { putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, true) } } RecoveryNeeded -> { preferences.edit().putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, false).apply() preferences.edit { putBoolean(KEY_IS_DATA_ALREADY_RECOVERED, false) } } } } Loading