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