mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Merge pull request #6209 from nextcloud/dependabot/gradle/com.pinterest-ktlint-0.37.0
Bump ktlint from 0.36.0 to 0.37.0
This commit is contained in:
commit
663537f304
27 changed files with 487 additions and 307 deletions
|
@ -341,7 +341,7 @@ dependencies {
|
|||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
ktlint "com.pinterest:ktlint:0.37.2"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.4.0'
|
||||
|
||||
// Shimmer animation
|
||||
|
|
|
@ -41,9 +41,11 @@ class EtmActivityTest : AbstractIT() {
|
|||
@Before
|
||||
fun before() {
|
||||
// tests only on NC 18
|
||||
Assume.assumeTrue(storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0)
|
||||
Assume.assumeTrue(
|
||||
storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -243,10 +243,7 @@ class MigrationsManagerTest {
|
|||
// pending migrations
|
||||
// mandatory migrations are passing
|
||||
// one migration is optional and fails
|
||||
assertEquals("Fixture should provide 1 optional, failing migration",
|
||||
1,
|
||||
migrations.count { !it.mandatory }
|
||||
)
|
||||
assertEquals("Fixture should provide 1 optional, failing migration", 1, migrations.count { !it.mandatory })
|
||||
val optionalFailingMigration = migrations.first { !it.mandatory }
|
||||
whenever(optionalFailingMigration.run()).thenThrow(RuntimeException())
|
||||
|
||||
|
|
|
@ -77,20 +77,24 @@ class FileUploaderIT : AbstractIT() {
|
|||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
@ -99,19 +103,23 @@ class FileUploaderIT : AbstractIT() {
|
|||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
@ -137,7 +145,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
|
@ -154,7 +163,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE)
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
|
@ -174,20 +184,24 @@ class FileUploaderIT : AbstractIT() {
|
|||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
@ -197,22 +211,26 @@ class FileUploaderIT : AbstractIT() {
|
|||
val file2 = File(getSavePath(account.name) + "/empty.txt")
|
||||
val ocUpload2 = OCUpload(file2.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.RENAME,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.addRenameUploadListener {
|
||||
renameListenerWasTriggered = true
|
||||
}
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.RENAME,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.addRenameUploadListener {
|
||||
renameListenerWasTriggered = true
|
||||
}
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
@ -244,7 +262,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
|
@ -261,7 +280,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.RENAME)
|
||||
FileUploader.NameCollisionPolicy.RENAME
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
|
@ -284,20 +304,24 @@ class FileUploaderIT : AbstractIT() {
|
|||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
@ -306,19 +330,22 @@ class FileUploaderIT : AbstractIT() {
|
|||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
|
||||
assertFalse(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.CANCEL,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertFalse(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.CANCEL,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.execute(client, storageManager).isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
@ -344,7 +371,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
|
@ -361,7 +389,8 @@ class FileUploaderIT : AbstractIT() {
|
|||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.CANCEL)
|
||||
FileUploader.NameCollisionPolicy.CANCEL
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
|
|
|
@ -93,9 +93,11 @@ class OCFileListFragmentIT : AbstractIT() {
|
|||
fun showRichWorkspace() {
|
||||
assertTrue(CreateFolderOperation("/test/", account, targetContext).execute(client, storageManager).isSuccess)
|
||||
|
||||
val ocUpload = OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
val ocUpload = OCUpload(
|
||||
FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
"/test/Readme.md",
|
||||
account.name)
|
||||
account.name
|
||||
)
|
||||
val newUpload = UploadFileOperation(
|
||||
UploadsStorageManager(UserAccountManagerImpl.fromContext(targetContext), targetContext.contentResolver),
|
||||
connectivityServiceMock,
|
||||
|
@ -107,20 +109,27 @@ class OCFileListFragmentIT : AbstractIT() {
|
|||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
false
|
||||
)
|
||||
|
||||
newUpload.addRenameUploadListener {}
|
||||
newUpload.setRemoteFolderToBeCreated()
|
||||
|
||||
assertTrue(newUpload.execute(client, storageManager).isSuccess)
|
||||
|
||||
assertTrue(RefreshFolderOperation(storageManager.getFileByPath("/test/"),
|
||||
System.currentTimeMillis() / SECOND_IN_MILLIS,
|
||||
false,
|
||||
true,
|
||||
storageManager,
|
||||
account,
|
||||
targetContext).execute(client).isSuccess)
|
||||
assertTrue(
|
||||
RefreshFolderOperation(
|
||||
storageManager.getFileByPath("/test/"),
|
||||
System.currentTimeMillis() / SECOND_IN_MILLIS,
|
||||
false,
|
||||
true,
|
||||
storageManager,
|
||||
account,
|
||||
targetContext
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut = ActivityScenario.launch(FileDisplayActivity::class.java)
|
||||
shortSleep()
|
||||
|
@ -170,18 +179,24 @@ class OCFileListFragmentIT : AbstractIT() {
|
|||
@ScreenshotTest
|
||||
fun createAndShowShareToUser() {
|
||||
val path = "/shareToAdmin/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder to user "admin"
|
||||
TestCase.assertTrue(CreateShareRemoteOperation(path,
|
||||
ShareType.USER,
|
||||
"admin",
|
||||
false,
|
||||
"",
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
|
||||
.execute(client).isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
path,
|
||||
ShareType.USER,
|
||||
"admin",
|
||||
false,
|
||||
"",
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
)
|
||||
.execute(client).isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
|
@ -195,18 +210,25 @@ class OCFileListFragmentIT : AbstractIT() {
|
|||
@ScreenshotTest
|
||||
fun createAndShowShareToGroup() {
|
||||
val path = "/shareToGroup/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder to group
|
||||
assertTrue(CreateShareRemoteOperation("/shareToGroup/",
|
||||
ShareType.GROUP,
|
||||
"users",
|
||||
false,
|
||||
"",
|
||||
OCShare.DEFAULT_PERMISSION)
|
||||
.execute(client).isSuccess)
|
||||
assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
"/shareToGroup/",
|
||||
ShareType.GROUP,
|
||||
"users",
|
||||
false,
|
||||
"",
|
||||
OCShare.DEFAULT_PERMISSION
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
|
@ -252,18 +274,25 @@ class OCFileListFragmentIT : AbstractIT() {
|
|||
@ScreenshotTest
|
||||
fun createAndShowShareViaLink() {
|
||||
val path = "/shareViaLink/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder via public link
|
||||
TestCase.assertTrue(CreateShareRemoteOperation("/shareViaLink/",
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
true,
|
||||
"",
|
||||
OCShare.READ_PERMISSION_FLAG)
|
||||
.execute(client).isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
"/shareViaLink/",
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
true,
|
||||
"",
|
||||
OCShare.READ_PERMISSION_FLAG
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
|
|
|
@ -40,9 +40,11 @@ internal class Task<T>(
|
|||
try {
|
||||
val result = taskBody.invoke()
|
||||
if (!cancelled.get()) {
|
||||
postResult.invoke(Runnable {
|
||||
onSuccess?.invoke(result)
|
||||
})
|
||||
postResult.invoke(
|
||||
Runnable {
|
||||
onSuccess?.invoke(result)
|
||||
}
|
||||
)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
if (!cancelled.get()) {
|
||||
|
|
|
@ -49,7 +49,8 @@ class ShowErrorActivity : AppCompatActivity() {
|
|||
|
||||
val snackbar = DisplayUtils.createSnackbar(
|
||||
error_page_container,
|
||||
R.string.error_report_issue_text, Snackbar.LENGTH_INDEFINITE)
|
||||
R.string.error_report_issue_text, Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.setAction(R.string.error_report_issue_action) { reportIssue() }
|
||||
|
||||
snackbar.show()
|
||||
|
|
|
@ -51,9 +51,12 @@ class EtmActivity : ToolbarActivity(), Injectable {
|
|||
setupToolbar()
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.etm_title))
|
||||
vm = ViewModelProvider(this, viewModelFactory).get(EtmViewModel::class.java)
|
||||
vm.currentPage.observe(this, Observer {
|
||||
onPageChanged(it)
|
||||
})
|
||||
vm.currentPage.observe(
|
||||
this,
|
||||
Observer {
|
||||
onPageChanged(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
|
|
|
@ -67,10 +67,10 @@ class EtmBackgroundJobsFragment : EtmBaseFragment() {
|
|||
|
||||
private val dateFormat = SimpleDateFormat("YYYY-MM-dd HH:MM:ssZ", Locale.getDefault())
|
||||
var backgroundJobs: List<JobInfo> = emptyList()
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = inflater.inflate(R.layout.etm_background_job_list_item, parent, false)
|
||||
|
|
|
@ -140,24 +140,29 @@ class AccountRemovalWork(
|
|||
user: User,
|
||||
arbitraryDataProvider: ArbitraryDataProvider
|
||||
) {
|
||||
val arbitraryDataPushString = arbitraryDataProvider.getValue(user.toPlatformAccount(),
|
||||
PushUtils.KEY_PUSH)
|
||||
val arbitraryDataPushString = arbitraryDataProvider.getValue(user.toPlatformAccount(), PushUtils.KEY_PUSH)
|
||||
val pushServerUrl = context.resources.getString(R.string.push_server_url)
|
||||
if (!TextUtils.isEmpty(arbitraryDataPushString) && !TextUtils.isEmpty(pushServerUrl)) {
|
||||
val gson = Gson()
|
||||
val pushArbitraryData = gson.fromJson(arbitraryDataPushString,
|
||||
PushConfigurationState::class.java)
|
||||
val pushArbitraryData = gson.fromJson(
|
||||
arbitraryDataPushString,
|
||||
PushConfigurationState::class.java
|
||||
)
|
||||
pushArbitraryData.isShouldBeDeleted = true
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.accountName, PushUtils.KEY_PUSH,
|
||||
gson.toJson(pushArbitraryData))
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||
user.accountName, PushUtils.KEY_PUSH,
|
||||
gson.toJson(pushArbitraryData)
|
||||
)
|
||||
PushUtils.pushRegistrationToServer(userAccountManager, pushArbitraryData.getPushToken())
|
||||
}
|
||||
}
|
||||
|
||||
private fun remoceSyncedFolders(context: Context, account: Account, clock: Clock) {
|
||||
val syncedFolderProvider = SyncedFolderProvider(context.contentResolver,
|
||||
val syncedFolderProvider = SyncedFolderProvider(
|
||||
context.contentResolver,
|
||||
AppPreferencesImpl.fromContext(context),
|
||||
clock)
|
||||
clock
|
||||
)
|
||||
val syncedFolders = syncedFolderProvider.syncedFolders
|
||||
val syncedFolderIds: MutableList<Long> = ArrayList()
|
||||
for (syncedFolder in syncedFolders) {
|
||||
|
|
|
@ -285,7 +285,8 @@ internal class BackgroundJobManagerImpl(
|
|||
val request = periodicRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobName = JOB_PERIODIC_FILES_SYNC,
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES).build()
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES
|
||||
).build()
|
||||
workManager.enqueueUniquePeriodicWork(JOB_PERIODIC_FILES_SYNC, ExistingPeriodicWorkPolicy.REPLACE, request)
|
||||
}
|
||||
|
||||
|
@ -297,7 +298,8 @@ internal class BackgroundJobManagerImpl(
|
|||
|
||||
val request = oneTimeRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobName = JOB_IMMEDIATE_FILES_SYNC)
|
||||
jobName = JOB_IMMEDIATE_FILES_SYNC
|
||||
)
|
||||
.setInputData(arguments)
|
||||
.build()
|
||||
|
||||
|
|
|
@ -87,8 +87,10 @@ class ContactsBackupWork(
|
|||
return Result.failure()
|
||||
}
|
||||
val user = optionalUser.get()
|
||||
val lastExecution = arbitraryDataProvider.getLongValue(user.toPlatformAccount(),
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP)
|
||||
val lastExecution = arbitraryDataProvider.getLongValue(
|
||||
user.toPlatformAccount(),
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP
|
||||
)
|
||||
val force = inputData.getBoolean(FORCE, false)
|
||||
if (force || lastExecution + JOB_INTERVAL_MS < Calendar.getInstance().timeInMillis) {
|
||||
Log_OC.d(TAG, "start contacts backup job")
|
||||
|
@ -121,8 +123,10 @@ class ContactsBackupWork(
|
|||
|
||||
private fun backupContact(user: User, backupFolder: String) {
|
||||
val vCard = ArrayList<String>()
|
||||
val cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null,
|
||||
null, null, null)
|
||||
val cursor = contentResolver.query(
|
||||
ContactsContract.Contacts.CONTENT_URI, null,
|
||||
null, null, null
|
||||
)
|
||||
if (cursor != null && cursor.count > 0) {
|
||||
cursor.moveToFirst()
|
||||
for (i in 0 until cursor.count) {
|
||||
|
@ -168,8 +172,10 @@ class ContactsBackupWork(
|
|||
|
||||
private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) { // -1 disables expiration
|
||||
if (daysToExpire > -1) {
|
||||
val storageManager = FileDataStorageManager(user.toPlatformAccount(),
|
||||
applicationContext.getContentResolver())
|
||||
val storageManager = FileDataStorageManager(
|
||||
user.toPlatformAccount(),
|
||||
applicationContext.getContentResolver()
|
||||
)
|
||||
val backupFolder: OCFile = storageManager.getFileByPath(backupFolderString)
|
||||
val cal = Calendar.getInstance()
|
||||
cal.add(Calendar.DAY_OF_YEAR, -daysToExpire)
|
||||
|
|
|
@ -86,8 +86,11 @@ class FilesSyncWork(
|
|||
var wakeLock: WakeLock? = null
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG)
|
||||
wakeLock = powerManager.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK,
|
||||
MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG
|
||||
)
|
||||
wakeLock.acquire(WAKELOCK_ACQUIRE_TIMEOUT_MS)
|
||||
}
|
||||
val overridePowerSaving = inputData.getBoolean(OVERRIDE_POWER_SAVING, false)
|
||||
|
@ -99,10 +102,12 @@ class FilesSyncWork(
|
|||
val resources = context.resources
|
||||
val lightVersion = resources.getBoolean(R.bool.syncedFolder_light)
|
||||
val skipCustom = inputData.getBoolean(SKIP_CUSTOM, false)
|
||||
FilesSyncHelper.restartJobsIfNeeded(uploadsStorageManager,
|
||||
FilesSyncHelper.restartJobsIfNeeded(
|
||||
uploadsStorageManager,
|
||||
userAccountManager,
|
||||
connectivityService,
|
||||
powerManagementService)
|
||||
powerManagementService
|
||||
)
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom)
|
||||
// Create all the providers we'll needq
|
||||
val filesystemDataProvider = FilesystemDataProvider(contentResolver)
|
||||
|
@ -112,8 +117,10 @@ class FilesSyncWork(
|
|||
dateFormat.timeZone = TimeZone.getTimeZone(TimeZone.getDefault().id)
|
||||
for (syncedFolder in syncedFolderProvider.syncedFolders) {
|
||||
if (syncedFolder.isEnabled && (!skipCustom || MediaFolderType.CUSTOM != syncedFolder.type)) {
|
||||
syncFolder(context, resources, lightVersion, filesystemDataProvider, currentLocale, dateFormat,
|
||||
syncedFolder)
|
||||
syncFolder(
|
||||
context, resources, lightVersion, filesystemDataProvider, currentLocale, dateFormat,
|
||||
syncedFolder
|
||||
)
|
||||
}
|
||||
}
|
||||
wakeLock?.release()
|
||||
|
@ -157,8 +164,10 @@ class FilesSyncWork(
|
|||
val mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.absolutePath)
|
||||
if (lightVersion) {
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging)
|
||||
needsWifi = arbitraryDataProvider!!.getBooleanValue(accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI)
|
||||
needsWifi = arbitraryDataProvider!!.getBooleanValue(
|
||||
accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI
|
||||
)
|
||||
val uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour)
|
||||
uploadAction = getUploadAction(uploadActionString)
|
||||
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders)
|
||||
|
@ -190,8 +199,10 @@ class FilesSyncWork(
|
|||
needsCharging,
|
||||
FileUploader.NameCollisionPolicy.ASK_USER
|
||||
)
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
|
||||
java.lang.Long.toString(syncedFolder.id))
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(
|
||||
path,
|
||||
java.lang.Long.toString(syncedFolder.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,38 +123,51 @@ class MediaFoldersDetectionWork constructor(
|
|||
val allUsers = userAccountManager.allUsers
|
||||
val activeUsers: MutableList<User> = ArrayList()
|
||||
for (account in allUsers) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(account.toPlatformAccount(),
|
||||
ManageAccountsActivity.PENDING_FOR_REMOVAL)) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(
|
||||
account.toPlatformAccount(),
|
||||
ManageAccountsActivity.PENDING_FOR_REMOVAL
|
||||
)
|
||||
) {
|
||||
activeUsers.add(account)
|
||||
}
|
||||
}
|
||||
for (user in activeUsers) {
|
||||
for (imageMediaFolder in imageMediaFolderPaths) {
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder,
|
||||
user.toPlatformAccount())
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(
|
||||
imageMediaFolder,
|
||||
user.toPlatformAccount()
|
||||
)
|
||||
if (folder == null) {
|
||||
val contentTitle = String.format(
|
||||
resources.getString(R.string.new_media_folder_detected),
|
||||
resources.getString(R.string.new_media_folder_photos)
|
||||
)
|
||||
sendNotification(contentTitle,
|
||||
sendNotification(
|
||||
contentTitle,
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
imageMediaFolder,
|
||||
1)
|
||||
1
|
||||
)
|
||||
}
|
||||
}
|
||||
for (videoMediaFolder in videoMediaFolderPaths) {
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder,
|
||||
user.toPlatformAccount())
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(
|
||||
videoMediaFolder,
|
||||
user.toPlatformAccount()
|
||||
)
|
||||
if (folder == null) {
|
||||
val contentTitle = String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos))
|
||||
sendNotification(contentTitle,
|
||||
val contentTitle = String.format(
|
||||
context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos)
|
||||
)
|
||||
sendNotification(
|
||||
contentTitle,
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
videoMediaFolder,
|
||||
2)
|
||||
2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +175,10 @@ class MediaFoldersDetectionWork constructor(
|
|||
}
|
||||
} else {
|
||||
mediaFoldersModel = MediaFoldersModel(imageMediaFolderPaths, videoMediaFolderPaths)
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS,
|
||||
gson.toJson(mediaFoldersModel))
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||
ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS,
|
||||
gson.toJson(mediaFoldersModel)
|
||||
)
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
|
@ -180,7 +195,8 @@ class MediaFoldersDetectionWork constructor(
|
|||
intent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, true)
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
||||
val notificationBuilder = NotificationCompat.Builder(
|
||||
context, NotificationUtils.NOTIFICATION_CHANNEL_GENERAL)
|
||||
context, NotificationUtils.NOTIFICATION_CHANNEL_GENERAL
|
||||
)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor(context))
|
||||
|
|
|
@ -99,17 +99,21 @@ class NotificationWork constructor(
|
|||
val base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT)
|
||||
val privateKey = PushUtils.readKeyFromFile(false) as PrivateKey
|
||||
try {
|
||||
val signatureVerification = PushUtils.verifySignature(context,
|
||||
val signatureVerification = PushUtils.verifySignature(
|
||||
context,
|
||||
accountManager,
|
||||
base64DecodedSignature,
|
||||
base64DecodedSubject)
|
||||
base64DecodedSubject
|
||||
)
|
||||
if (signatureVerification != null && signatureVerification.isSignatureValid) {
|
||||
val cipher = Cipher.getInstance("RSA/None/PKCS1Padding")
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey)
|
||||
val decryptedSubject = cipher.doFinal(base64DecodedSubject)
|
||||
val gson = Gson()
|
||||
val decryptedPushMessage = gson.fromJson(String(decryptedSubject),
|
||||
DecryptedPushMessage::class.java)
|
||||
val decryptedPushMessage = gson.fromJson(
|
||||
String(decryptedSubject),
|
||||
DecryptedPushMessage::class.java
|
||||
)
|
||||
if (decryptedPushMessage.delete) {
|
||||
notificationManager.cancel(decryptedPushMessage.nid)
|
||||
} else if (decryptedPushMessage.deleteAll) {
|
||||
|
@ -174,10 +178,16 @@ class NotificationWork constructor(
|
|||
disableDetection.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId())
|
||||
disableDetection.putExtra(PUSH_NOTIFICATION_ID, pushNotificationId)
|
||||
disableDetection.putExtra(KEY_NOTIFICATION_ACCOUNT, user.accountName)
|
||||
val disableIntent = PendingIntent.getBroadcast(context, pushNotificationId, disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
notificationBuilder.addAction(NotificationCompat.Action(R.drawable.ic_close,
|
||||
context.getString(R.string.remove_push_notification), disableIntent))
|
||||
val disableIntent = PendingIntent.getBroadcast(
|
||||
context, pushNotificationId, disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
)
|
||||
notificationBuilder.addAction(
|
||||
NotificationCompat.Action(
|
||||
R.drawable.ic_close,
|
||||
context.getString(R.string.remove_push_notification), disableIntent
|
||||
)
|
||||
)
|
||||
} else { // Actions
|
||||
for (action in notification.getActions()) {
|
||||
val actionIntent = Intent(context, NotificationReceiver::class.java)
|
||||
|
@ -186,9 +196,11 @@ class NotificationWork constructor(
|
|||
actionIntent.putExtra(KEY_NOTIFICATION_ACCOUNT, user.accountName)
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_LINK, action.link)
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_TYPE, action.type)
|
||||
val actionPendingIntent = PendingIntent.getBroadcast(context, randomId.nextInt(),
|
||||
val actionPendingIntent = PendingIntent.getBroadcast(
|
||||
context, randomId.nextInt(),
|
||||
actionIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
)
|
||||
var icon: Int
|
||||
icon = if (action.primary) {
|
||||
R.drawable.ic_check_circle
|
||||
|
@ -209,7 +221,8 @@ class NotificationWork constructor(
|
|||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||
.setAutoCancel(true)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setContentIntent(pendingIntent).build())
|
||||
.setContentIntent(pendingIntent).build()
|
||||
)
|
||||
val notificationManager = NotificationManagerCompat.from(context)
|
||||
notificationManager.notify(notification.getNotificationId(), notificationBuilder.build())
|
||||
}
|
||||
|
@ -255,51 +268,54 @@ class NotificationWork constructor(
|
|||
val numericNotificationId = intent.getIntExtra(NUMERIC_NOTIFICATION_ID, 0)
|
||||
val accountName = intent.getStringExtra(KEY_NOTIFICATION_ACCOUNT)
|
||||
if (numericNotificationId != 0) {
|
||||
Thread(Runnable {
|
||||
val notificationManager = context.getSystemService(
|
||||
Activity.NOTIFICATION_SERVICE) as NotificationManager
|
||||
var oldNotification: android.app.Notification? = null
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
|
||||
for (statusBarNotification in notificationManager.activeNotifications) {
|
||||
if (numericNotificationId == statusBarNotification.id) {
|
||||
oldNotification = statusBarNotification.notification
|
||||
break
|
||||
}
|
||||
}
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
try {
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (optionalUser.isPresent) {
|
||||
val user = optionalUser.get()
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), context)
|
||||
val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE)
|
||||
val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK)
|
||||
val success: Boolean
|
||||
success = if (!TextUtils.isEmpty(actionType) && !TextUtils.isEmpty(actionLink)) {
|
||||
val resultCode = executeAction(actionType, actionLink, client)
|
||||
resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED
|
||||
} else {
|
||||
DeleteNotificationRemoteOperation(numericNotificationId)
|
||||
.execute(client).isSuccess
|
||||
}
|
||||
if (success) {
|
||||
if (oldNotification == null) {
|
||||
cancel(context, numericNotificationId)
|
||||
Thread(
|
||||
Runnable {
|
||||
val notificationManager = context.getSystemService(
|
||||
Activity.NOTIFICATION_SERVICE
|
||||
) as NotificationManager
|
||||
var oldNotification: android.app.Notification? = null
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
|
||||
for (statusBarNotification in notificationManager.activeNotifications) {
|
||||
if (numericNotificationId == statusBarNotification.id) {
|
||||
oldNotification = statusBarNotification.notification
|
||||
break
|
||||
}
|
||||
} else {
|
||||
notificationManager.notify(numericNotificationId, oldNotification)
|
||||
}
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
try {
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (optionalUser.isPresent) {
|
||||
val user = optionalUser.get()
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), context)
|
||||
val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE)
|
||||
val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK)
|
||||
val success: Boolean
|
||||
success = if (!TextUtils.isEmpty(actionType) && !TextUtils.isEmpty(actionLink)) {
|
||||
val resultCode = executeAction(actionType, actionLink, client)
|
||||
resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED
|
||||
} else {
|
||||
DeleteNotificationRemoteOperation(numericNotificationId)
|
||||
.execute(client).isSuccess
|
||||
}
|
||||
if (success) {
|
||||
if (oldNotification == null) {
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
} else {
|
||||
notificationManager.notify(numericNotificationId, oldNotification)
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: OperationCanceledException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: AuthenticatorException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: OperationCanceledException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: AuthenticatorException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
}
|
||||
}).start()
|
||||
).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,10 @@ class OfflineSyncWork constructor(
|
|||
val ocFolder = storageManager.getFileByPath(folderName)
|
||||
Log_OC.d(TAG, folderName + ": currentEtag: " + ocFolder.etag)
|
||||
// check for etag change, if false, skip
|
||||
val checkEtagOperation = CheckEtagRemoteOperation(ocFolder.encryptedFileName,
|
||||
ocFolder.etagOnServer)
|
||||
val checkEtagOperation = CheckEtagRemoteOperation(
|
||||
ocFolder.encryptedFileName,
|
||||
ocFolder.etagOnServer
|
||||
)
|
||||
val result = checkEtagOperation.execute(user.toPlatformAccount(), context)
|
||||
when (result.code) {
|
||||
ResultCode.ETAG_UNCHANGED -> {
|
||||
|
@ -116,10 +118,12 @@ class OfflineSyncWork constructor(
|
|||
if (files != null) {
|
||||
for (file in files) {
|
||||
val ocFile = storageManager.getFileByLocalPath(file.path)
|
||||
val synchronizeFileOperation = SynchronizeFileOperation(ocFile.remotePath,
|
||||
val synchronizeFileOperation = SynchronizeFileOperation(
|
||||
ocFile.remotePath,
|
||||
user,
|
||||
true,
|
||||
context)
|
||||
context
|
||||
)
|
||||
synchronizeFileOperation.execute(storageManager, context)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ data class LogEntry(val timestamp: Date, val level: Level, val tag: String, val
|
|||
* 1970-01-01T00:00:00.000Z;D;tag;some message
|
||||
*/
|
||||
private val ENTRY_PARSE_REGEXP = Regex(
|
||||
pattern = """(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z);([ADEIVW]);([^;]+);(.*)"""
|
||||
pattern =
|
||||
"""(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z);([ADEIVW]);([^;]+);(.*)"""
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -114,11 +114,13 @@ class LogsViewModel @Inject constructor(
|
|||
val sizeKb = logsSize / KILOBYTE
|
||||
return when {
|
||||
isLoading.value == true -> context.getString(R.string.logs_status_loading)
|
||||
isFiltered -> context.getString(R.string.logs_status_filtered,
|
||||
isFiltered -> context.getString(
|
||||
R.string.logs_status_filtered,
|
||||
sizeKb,
|
||||
displayedEntries,
|
||||
allEntries.size,
|
||||
filterDurationMs)
|
||||
filterDurationMs
|
||||
)
|
||||
!isFiltered -> context.getString(R.string.logs_status_not_filtered, sizeKb)
|
||||
else -> ""
|
||||
}
|
||||
|
|
|
@ -104,8 +104,10 @@ class Migrations @Inject constructor(
|
|||
logger.i(TAG, "$description: no users to migrate")
|
||||
} else {
|
||||
users.forEach {
|
||||
val backupEnabled = arbitraryDataProvider.getBooleanValue(it.accountName,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP)
|
||||
val backupEnabled = arbitraryDataProvider.getBooleanValue(
|
||||
it.accountName,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP
|
||||
)
|
||||
if (backupEnabled) {
|
||||
jobManager.schedulePeriodicContactsBackup(it)
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ class ChooseAccountDialogFragment : DialogFragment(), AvatarGenerationListener,
|
|||
resources.getDimension(R.dimen.list_item_avatar_icon_radius),
|
||||
resources,
|
||||
user_icon,
|
||||
context)
|
||||
context
|
||||
)
|
||||
|
||||
// Defining user texts, accounts, etc.
|
||||
user_name.text = user.toOwnCloudAccount().displayName
|
||||
|
@ -88,17 +89,21 @@ class ChooseAccountDialogFragment : DialogFragment(), AvatarGenerationListener,
|
|||
account.text = user.accountName
|
||||
|
||||
// Defining user right indicator
|
||||
val icon = ThemeUtils.tintDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
|
||||
ThemeUtils.primaryColor(requireContext(), true))
|
||||
val icon = ThemeUtils.tintDrawable(
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
|
||||
ThemeUtils.primaryColor(requireContext(), true)
|
||||
)
|
||||
account_menu.setImageDrawable(icon)
|
||||
|
||||
// Creating adapter for accounts list
|
||||
val adapter = UserListAdapter(activity as BaseActivity,
|
||||
val adapter = UserListAdapter(
|
||||
activity as BaseActivity,
|
||||
accountManager,
|
||||
getAccountListItems(),
|
||||
this,
|
||||
false,
|
||||
false)
|
||||
false
|
||||
)
|
||||
accounts_list.adapter = adapter
|
||||
|
||||
// Creating listeners for quick-actions
|
||||
|
|
|
@ -115,11 +115,17 @@ class ManualAsyncRunnerTest {
|
|||
// WHEN
|
||||
// one task is scheduled
|
||||
// task callback schedules another task
|
||||
runner.post(task, {
|
||||
runner.post(task, {
|
||||
runner.post(task)
|
||||
})
|
||||
})
|
||||
runner.post(
|
||||
task,
|
||||
{
|
||||
runner.post(
|
||||
task,
|
||||
{
|
||||
runner.post(task)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
assertEquals(ONE_TASK, runner.size)
|
||||
|
||||
// WHEN
|
||||
|
|
|
@ -79,9 +79,12 @@ class ThreadPoolAsyncRunnerTest {
|
|||
}.whenever(handler).post(any())
|
||||
|
||||
val onResult: OnResultCallback<String> = mock()
|
||||
r.post({
|
||||
"result"
|
||||
}, onResult = onResult)
|
||||
r.post(
|
||||
{
|
||||
"result"
|
||||
},
|
||||
onResult = onResult
|
||||
)
|
||||
assertAwait(afterPostLatch)
|
||||
verify(onResult).invoke(eq("result"))
|
||||
}
|
||||
|
@ -96,9 +99,12 @@ class ThreadPoolAsyncRunnerTest {
|
|||
|
||||
val onResult: OnResultCallback<String> = mock()
|
||||
val onError: OnErrorCallback = mock()
|
||||
r.post({
|
||||
throw IllegalArgumentException("whatever")
|
||||
}, onResult = onResult, onError = onError)
|
||||
r.post(
|
||||
{
|
||||
throw IllegalArgumentException("whatever")
|
||||
},
|
||||
onResult = onResult, onError = onError
|
||||
)
|
||||
assertAwait(afterPostLatch)
|
||||
verify(onResult, never()).invoke(any())
|
||||
verify(onError).invoke(argThat { this is java.lang.IllegalArgumentException })
|
||||
|
@ -108,11 +114,14 @@ class ThreadPoolAsyncRunnerTest {
|
|||
fun `cancelled task does not return result`() {
|
||||
val taskIsCancelled = CountDownLatch(INIT_COUNT)
|
||||
val taskIsRunning = CountDownLatch(INIT_COUNT)
|
||||
val t = r.post({
|
||||
taskIsRunning.countDown()
|
||||
taskIsCancelled.await()
|
||||
"result"
|
||||
}, onResult = {}, onError = {})
|
||||
val t = r.post(
|
||||
{
|
||||
taskIsRunning.countDown()
|
||||
taskIsCancelled.await()
|
||||
"result"
|
||||
},
|
||||
onResult = {}, onError = {}
|
||||
)
|
||||
assertAwait(taskIsRunning)
|
||||
t.cancel()
|
||||
taskIsCancelled.countDown()
|
||||
|
@ -124,11 +133,14 @@ class ThreadPoolAsyncRunnerTest {
|
|||
fun `cancelled task does not return error`() {
|
||||
val taskIsCancelled = CountDownLatch(INIT_COUNT)
|
||||
val taskIsRunning = CountDownLatch(INIT_COUNT)
|
||||
val t = r.post({
|
||||
taskIsRunning.countDown()
|
||||
taskIsCancelled.await()
|
||||
throw IllegalStateException("whatever")
|
||||
}, onResult = {}, onError = {})
|
||||
val t = r.post(
|
||||
{
|
||||
taskIsRunning.countDown()
|
||||
taskIsCancelled.await()
|
||||
throw IllegalStateException("whatever")
|
||||
},
|
||||
onResult = {}, onError = {}
|
||||
)
|
||||
assertAwait(taskIsRunning)
|
||||
t.cancel()
|
||||
taskIsCancelled.countDown()
|
||||
|
|
|
@ -92,7 +92,8 @@ class LogEntryTest {
|
|||
val entry = LogEntry(
|
||||
timestamp = Date(0),
|
||||
level = Level.DEBUG,
|
||||
tag = """靖康緗素雜記""",
|
||||
tag =
|
||||
"""靖康緗素雜記""",
|
||||
message = "夏炉冬扇"
|
||||
)
|
||||
assertEquals("1970-01-01T00:00:00.000Z;D;靖康緗素雜記;夏炉冬扇", entry.toString())
|
||||
|
|
|
@ -146,9 +146,11 @@ class LoggerTest {
|
|||
assertTrue("Expected open(), write() and close() calls on bg thread", called)
|
||||
val inOrder = inOrder(logHandler)
|
||||
inOrder.verify(logHandler).open()
|
||||
inOrder.verify(logHandler).write(argThat {
|
||||
tag in this && message in this
|
||||
})
|
||||
inOrder.verify(logHandler).write(
|
||||
argThat {
|
||||
tag in this && message in this
|
||||
}
|
||||
)
|
||||
inOrder.verify(logHandler).close()
|
||||
assertFalse(logger.lostEntries)
|
||||
}
|
||||
|
@ -258,9 +260,12 @@ class LoggerTest {
|
|||
logger.load(listener)
|
||||
assertTrue("Logs not loaded", posted.await(1, TimeUnit.SECONDS))
|
||||
|
||||
verify(listener).invoke(argThat {
|
||||
"Logger queue overflow" in last().message
|
||||
}, any())
|
||||
verify(listener).invoke(
|
||||
argThat {
|
||||
"Logger queue overflow" in last().message
|
||||
},
|
||||
any()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -236,9 +236,11 @@ class LogsViewModelTest {
|
|||
|
||||
assertEquals("Status should contain size in kB", TEST_LOG_SIZE_KILOBYTES, statusArgs[1])
|
||||
assertEquals("Status should show matched entries count", vm.entries.value?.size, statusArgs[2])
|
||||
assertEquals("Status should contain total entries count",
|
||||
assertEquals(
|
||||
"Status should contain total entries count",
|
||||
TEST_LOG_ENTRIES.size,
|
||||
statusArgs[TOTAL_ENTRY_COUNT])
|
||||
statusArgs[TOTAL_ENTRY_COUNT]
|
||||
)
|
||||
assertTrue("Status should contain query time in ms", statusArgs[QUERY_TIME] is Long)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,14 +191,18 @@ class ConnectivityServiceTest {
|
|||
whenever(networkInfo.isConnectedOrConnecting).thenReturn(true)
|
||||
whenever(networkInfo.type).thenReturn(ConnectivityManager.TYPE_WIFI)
|
||||
whenever(user.server).thenReturn(legacyServer)
|
||||
assertTrue("Precondition failed", connectivityService.connectivity.let {
|
||||
it.isConnected && it.isWifi
|
||||
})
|
||||
assertTrue(
|
||||
"Precondition failed",
|
||||
connectivityService.connectivity.let {
|
||||
it.isConnected && it.isWifi
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun mockResponse(maintenance: Boolean = true, httpStatus: Int = HttpStatus.SC_OK) {
|
||||
whenever(client.executeMethod(getRequest)).thenReturn(httpStatus)
|
||||
val body = """{"maintenance":$maintenance}"""
|
||||
val body =
|
||||
"""{"maintenance":$maintenance}"""
|
||||
whenever(getRequest.responseContentLength).thenReturn(body.length.toLong())
|
||||
whenever(getRequest.responseBodyAsString).thenReturn(body)
|
||||
}
|
||||
|
@ -238,9 +242,12 @@ class ConnectivityServiceTest {
|
|||
whenever(networkInfo.isConnectedOrConnecting).thenReturn(true)
|
||||
whenever(networkInfo.type).thenReturn(ConnectivityManager.TYPE_WIFI)
|
||||
whenever(accountManager.getServerVersion(any())).thenReturn(OwnCloudVersion.nextcloud_14)
|
||||
assertTrue("Precondition failed", connectivityService.connectivity.let {
|
||||
it.isConnected && it.isWifi
|
||||
})
|
||||
assertTrue(
|
||||
"Precondition failed",
|
||||
connectivityService.connectivity.let {
|
||||
it.isConnected && it.isWifi
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -36,12 +36,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = false
|
||||
val dateTaken = 123123123L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/subfolder/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -55,12 +57,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = false
|
||||
val dateTaken = 123123123L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -74,12 +78,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = true
|
||||
val dateTaken = 0L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -93,12 +99,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = false
|
||||
val dateTaken = 123123123L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -112,12 +120,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = true
|
||||
val dateTaken = 1569918628000L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/2019/10/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -131,12 +141,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = false
|
||||
val dateTaken = 123123123L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/subfolder/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
@ -150,12 +162,14 @@ class FileStorageUtilsTest {
|
|||
val subFolderByDate = true
|
||||
val dateTaken = 1569918628000L
|
||||
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(file,
|
||||
val result = FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
Locale.ROOT,
|
||||
syncedFolderRemotePath,
|
||||
syncedFolderLocalPath,
|
||||
dateTaken,
|
||||
subFolderByDate)
|
||||
subFolderByDate
|
||||
)
|
||||
val expected = "/Camera/2019/10/subfolder/file.jpg"
|
||||
|
||||
assertEquals(expected, result)
|
||||
|
|
Loading…
Reference in a new issue