Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Tobias Kaminsky 2023-05-31 02:31:43 +02:00
commit 002206af59
27 changed files with 121 additions and 50 deletions

View file

@ -17,7 +17,7 @@ buildscript {
}
plugins {
id "com.diffplug.spotless" version "6.18.0"
id "com.diffplug.spotless" version "6.19.0"
}
apply plugin: 'com.android.application'

View file

@ -76,8 +76,8 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
val file1 = rootDir.createFile(type1, name1)!!
// check assumptions
@Suppress("ForbiddenComment")
file1.assertRegularFile(name1, 0L, null/* FIXME: type1 */, rootDir)
/* FIXME: mimeType */
file1.assertRegularFile(name1, 0L, null, rootDir)
file1.assertRecentlyModified()
// file1 is found in root

View file

@ -352,7 +352,8 @@ class FileDetailSharingFragmentIT : AbstractIT() {
val secondary = FileDetailFragment.newInstance(file, parentFolder, user)
activity.addSecondaryFragment(secondary, FileDisplayActivity.TAG_LIST_OF_FILES)
activity.addView(
FloatingActionButton(activity).apply { // needed for some reason
FloatingActionButton(activity).apply {
// needed for some reason
visibility = View.GONE
id = R.id.fab_main
}

View file

@ -210,9 +210,7 @@ class DocumentScanViewModel @Inject constructor(
}
}
private
companion object {
private companion object {
private const val TAG = "DocumentScanViewModel"
}

View file

@ -81,11 +81,13 @@ class AccountRemovalWork(
@Suppress("ReturnCount") // legacy code
override fun doWork(): Result {
val accountName = inputData.getString(ACCOUNT) ?: ""
if (TextUtils.isEmpty(accountName)) { // didn't receive account to delete
if (TextUtils.isEmpty(accountName)) {
// didn't receive account to delete
return Result.failure()
}
val optionalUser = userAccountManager.getUser(accountName)
if (!optionalUser.isPresent) { // trying to delete non-existing user
if (!optionalUser.isPresent) {
// trying to delete non-existing user
return Result.failure()
}
val remoteWipe = inputData.getBoolean(REMOTE_WIPE, false)

View file

@ -52,7 +52,8 @@ class CalendarBackupWork(
override fun doWork(): Result {
val accountName = inputData.getString(ACCOUNT) ?: ""
val optionalUser = accountManager.getUser(accountName)
if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) { // no account provided
if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) {
// no account provided
Log_OC.d(TAG, "User not present")
return Result.failure()
}

View file

@ -81,7 +81,8 @@ class ContactsBackupWork(
@Suppress("ReturnCount") // pre-existing issue
override fun doWork(): Result {
val accountName = inputData.getString(KEY_ACCOUNT) ?: ""
if (TextUtils.isEmpty(accountName)) { // no account provided
if (TextUtils.isEmpty(accountName)) {
// no account provided
return Result.failure()
}
val optionalUser = accountManager.getUser(accountName)
@ -175,7 +176,8 @@ class ContactsBackupWork(
connection.enqueue(request)
}
private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) { // -1 disables expiration
private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) {
// -1 disables expiration
if (daysToExpire > -1) {
val storageManager = FileDataStorageManager(
user,

View file

@ -198,7 +198,8 @@ class NotificationWork constructor(
disableIntent
)
)
} else { // Actions
} else {
// Actions
for (action in notification.getActions()) {
val actionIntent = Intent(context, NotificationReceiver::class.java)
actionIntent.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId())

View file

@ -184,7 +184,9 @@ internal class PlayerStateMachine(initialState: State, private val delegate: Del
.onExit(Action { delegate.onAudioDuck(false) })
stateMachine = StateMachine(initialState, config)
stateMachine.onUnhandledTrigger { _, _ -> /* ignore unhandled event */ }
stateMachine.onUnhandledTrigger { _, _ ->
/* ignore unhandled event */
}
}
private fun immediateTransition() {

View file

@ -28,13 +28,39 @@ import android.os.Bundle
* a mix-in.
*/
interface ActivityMixin {
fun onNewIntent(intent: Intent) { /* no-op */ }
fun onSaveInstanceState(outState: Bundle) { /* no-op */ }
fun onCreate(savedInstanceState: Bundle?) { /* no-op */ }
fun onRestart() { /* no-op */ }
fun onStart() { /* no-op */ }
fun onResume() { /* no-op */ }
fun onPause() { /* no-op */ }
fun onStop() { /* no-op */ }
fun onDestroy() { /* no-op */ }
fun onNewIntent(intent: Intent) {
/* no-op */
}
fun onSaveInstanceState(outState: Bundle) {
/* no-op */
}
fun onCreate(savedInstanceState: Bundle?) {
/* no-op */
}
fun onRestart() {
/* no-op */
}
fun onStart() {
/* no-op */
}
fun onResume() {
/* no-op */
}
fun onPause() {
/* no-op */
}
fun onStop() {
/* no-op */
}
fun onDestroy() {
/* no-op */
}
}

View file

@ -91,8 +91,12 @@ object ContentResolverHelper {
}
@RequiresApi(Build.VERSION_CODES.R)
private fun
getQueryArgsBundle(selection: String?, sortColumn: String?, sortDirection: String?, limit: Int?): Bundle {
private fun getQueryArgsBundle(
selection: String?,
sortColumn: String?,
sortDirection: String?,
limit: Int?
): Bundle {
return Bundle().apply {
if (selection != null) {
putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selection)

View file

@ -332,13 +332,15 @@ public class FileUploader extends Service
boolean onWifiOnly = intent.getBooleanExtra(KEY_WHILE_ON_WIFI_ONLY, false);
boolean whileChargingOnly = intent.getBooleanExtra(KEY_WHILE_CHARGING_ONLY, false);
if (retry) { // Retry uploads
if (retry) {
// Retry uploads
if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_RETRY_UPLOAD)) {
Log_OC.e(TAG, "Not enough information provided in intent: no KEY_RETRY_UPLOAD_KEY");
return START_NOT_STICKY;
}
retryUploads(intent, user, requestedUploads);
} else { // Start new uploads
} else {
// Start new uploads
if (!(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
Log_OC.e(TAG, "Not enough information provided in intent");
return Service.START_NOT_STICKY;
@ -793,7 +795,8 @@ public class FileUploader extends Service
boolean needsToUpdateCredentials = uploadResult.getCode() == ResultCode.UNAUTHORIZED;
if (needsToUpdateCredentials) {
tickerId = R.string.uploader_upload_failed_credentials_error;
} else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) { // check file conflict
} else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
// check file conflict
tickerId = R.string.uploader_upload_failed_sync_conflict_error;
}

View file

@ -336,7 +336,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
saveFolderInDB();
}
}
} else { // Create directory on DB
} else {
// Create directory on DB
OCFile newDir = new OCFile(remotePath);
newDir.setMimeType(MimeType.DIRECTORY);
long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(remotePath)).getFileId();

View file

@ -260,7 +260,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
Handler handler = new Handler(context.getMainLooper());
try {
return ParcelFileDescriptor.open(file, accessMode, handler, error -> {
if (error == null) { // no error
if (error == null) {
// no error
// As we can't upload the file synchronously, let's at least update its metadata here already.
ocFile.setFileLength(file.length());
ocFile.setModificationTimestamp(System.currentTimeMillis());
@ -275,7 +276,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
LOCAL_BEHAVIOUR_DELETE,
NameCollisionPolicy.OVERWRITE,
false);
} else { // error, no upload needed
} else {
// error, no upload needed
Log_OC.e(TAG, "File was closed with an error: " + ocFile.getFileName(), error);
}
});

View file

@ -823,7 +823,8 @@ public abstract class FileActivity extends DrawerActivity
// Was tried without password, but not sure that it's optional.
// Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
if (sharingFragment != null && sharingFragment.isAdded()) { // only if added to the view hierarchy
if (sharingFragment != null && sharingFragment.isAdded()) {
// only if added to the view hierarchy
sharingFragment.requestPasswordForShareViaLink(true,
getCapabilities().getFilesSharingPublicAskForOptionalPassword()

View file

@ -320,7 +320,8 @@ open class FolderPickerActivity :
fun browseToRoot() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) { // should never be null, indeed
if (listOfFiles != null) {
// should never be null, indeed
val root = storageManager.getFileByPath(OCFile.ROOT_PATH)
listOfFiles.listDirectory(root, false, false)
file = listOfFiles.currentFile
@ -331,7 +332,8 @@ open class FolderPickerActivity :
override fun onBackPressed() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) { // should never be null, indeed
if (listOfFiles != null) {
// should never be null, indeed
val levelsUp = listOfFiles.onBrowseUp()
if (levelsUp == 0) {
finish()

View file

@ -497,7 +497,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
String remotePath = item.getRemotePath();
OCFile ocFile = storageManager.getFileByPath(remotePath);
if (ocFile == null) { // Remote file doesn't exist, try to refresh folder
if (ocFile == null) {
// Remote file doesn't exist, try to refresh folder
OCFile folder = storageManager.getFileByPath(new File(remotePath).getParent() + "/");
if (folder != null && folder.isFolder()) {
this.refreshFolder(itemViewHolder, user, folder, (caller, result) -> {

View file

@ -328,7 +328,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
mFabMain = requireActivity().findViewById(R.id.fab_main);
if (mFabMain != null) { // is not available in FolderPickerActivity
if (mFabMain != null) {
// is not available in FolderPickerActivity
viewThemeUtils.material.themeFAB(mFabMain);
}
@ -387,7 +388,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
registerFabListener();
}
if (!searchFragment) { // do not touch search event if previously searched
if (!searchFragment) {
// do not touch search event if previously searched
if (getArguments() == null) {
searchEvent = null;
} else {
@ -478,7 +480,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
public void registerFabListener() {
FileActivity activity = (FileActivity) getActivity();
if (mFabMain != null) { // is not available in FolderPickerActivity
if (mFabMain != null) {
// is not available in FolderPickerActivity
viewThemeUtils.material.themeFAB(mFabMain);
mFabMain.setOnClickListener(v -> {
final OCFileListBottomSheetDialog dialog =
@ -1028,7 +1031,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
intent.putExtra(FolderPickerActivity.EXTRA_FILES, file);
getActivity().setResult(Activity.RESULT_OK, intent);
getActivity().finish();
} else if (!mOnlyFoldersClickable) { // Click on a file
} else if (!mOnlyFoldersClickable) {
// Click on a file
if (PreviewImageFragment.canBePreviewed(file)) {
// preview image - it handles the download, if needed
if (searchFragment) {

View file

@ -37,6 +37,7 @@ import com.nextcloud.utils.MenuUtils
import com.owncloud.android.R
import com.owncloud.android.databinding.PreviewPdfFragmentBinding
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.ui.activity.FileDisplayActivity
import com.owncloud.android.ui.preview.PreviewBitmapActivity
import com.owncloud.android.utils.DisplayUtils
@ -75,7 +76,13 @@ class PreviewPdfFragment : Fragment(), Injectable {
setupObservers()
file = requireArguments().getParcelable(ARG_FILE)!!
try {
viewModel.process(file)
} catch (e: SecurityException) {
Log_OC.e(this, "onViewCreated: trying to open password protected PDF", e)
parentFragmentManager.popBackStack()
DisplayUtils.showSnackMessage(binding.root, R.string.pdf_password_protected)
}
}
private fun setupObservers() {

View file

@ -66,6 +66,9 @@ class PreviewPdfViewModel @Inject constructor(val appPreferences: AppPreferences
}
}
/**
* @throws SecurityException if file points to a password-protected document
*/
fun process(file: OCFile) {
closeRenderer()
_pdfRenderer.value =

View file

@ -583,7 +583,8 @@ public final class FileStorageUtils {
}
FileStorageUtils.StandardDirectory standardDirectory = FileStorageUtils.StandardDirectory.fromPath(storageFolder);
if (standardDirectory != null) { // Friendly name of standard directory
if (standardDirectory != null) {
// Friendly name of standard directory
storageFolder = " " + resources.getString(standardDirectory.getDisplayName());
}

View file

@ -433,13 +433,15 @@ public class ProcessVEvent {
// - Check the calendars max number of alarms
if (t.getDateTime() != null) {
alarmMs = t.getDateTime().getTime(); // Absolute
} else if (t.getDuration() != null && t.getDuration().isNegative()) { //alarm trigger before start of event
} else if (t.getDuration() != null && t.getDuration().isNegative()) {
//alarm trigger before start of event
Related rel = (Related) t.getParameter(Parameter.RELATED);
if (rel != null && rel == Related.END) {
alarmStartMs = e.getEndDate().getDate().getTime();
}
alarmMs = alarmStartMs - durationToMs(t.getDuration()); // Relative "-"
} else if (t.getDuration() != null && !t.getDuration().isNegative()) { //alarm trigger after start of event
} else if (t.getDuration() != null && !t.getDuration().isNegative()) {
//alarm trigger after start of event
Related rel = (Related) t.getParameter(Parameter.RELATED);
if (rel != null && rel == Related.END) {
alarmStartMs = e.getEndDate().getDate().getTime();

View file

@ -113,7 +113,7 @@
<string name="common_error">Error</string>
<string name="common_error_out_memory">Memòria insuficient</string>
<string name="common_error_unknown">Error desconegut</string>
<string name="common_loading">S\'està carregant...</string>
<string name="common_loading">S\'està carregant</string>
<string name="common_next">Següent</string>
<string name="common_no">No</string>
<string name="common_ok">D\'acord</string>
@ -242,7 +242,7 @@
<string name="e2e_not_yet_setup">E2E encara no està configurat</string>
<string name="encrypted">Activa el xifrat</string>
<string name="end_to_end_encryption_confirm_button">Arranjament de xifrat</string>
<string name="end_to_end_encryption_decrypting">S\'està desxifrant...</string>
<string name="end_to_end_encryption_decrypting">S\'està desxifrant</string>
<string name="end_to_end_encryption_dialog_close">Tanca</string>
<string name="end_to_end_encryption_enter_password">Si us plau, introduïu la contrasenya per desxifrar la clau privada.</string>
<string name="end_to_end_encryption_folder_not_empty">Aquesta carpeta no és buida.</string>
@ -873,7 +873,7 @@
<string name="uploads_view_upload_status_failed_localfile_error">No s\'ha trobat el fitxer local</string>
<string name="uploads_view_upload_status_failed_permission_error">Error de permisos</string>
<string name="uploads_view_upload_status_failed_ssl_certificate_not_trusted">Certificat de servidor no fiable</string>
<string name="uploads_view_upload_status_fetching_server_version">Obtenint la versió del servidor...</string>
<string name="uploads_view_upload_status_fetching_server_version">Obtenint la versió del servidor</string>
<string name="uploads_view_upload_status_service_interrupted">L\'aplicació s\'ha tancat</string>
<string name="uploads_view_upload_status_succeeded">Completat</string>
<string name="uploads_view_upload_status_unknown_fail">Error desconegut</string>

View file

@ -32,6 +32,7 @@
<string name="activity_icon">События</string>
<string name="add_another_public_share_link">Добавить другую ссылку</string>
<string name="add_new_public_share">Добавить новую общедоступную ссылку</string>
<string name="add_new_secure_file_drop">Добавить новый защищенный очиститель файлов</string>
<string name="add_to_cloud">Добавить в %1$s</string>
<string name="advanced_settings">Дополнительные настройки</string>
<string name="allow_resharing">Разрешить повторную публикацию</string>
@ -157,6 +158,7 @@
<string name="conflict_local_file">Локальный файл</string>
<string name="conflict_message_description">Если вы выберете обе версии, локальный файл будет иметь номер, добавленный к его имени.</string>
<string name="conflict_server_file">Файл с сервера</string>
<string name="contact_backup_title">Резервная копия контактов</string>
<string name="contactlist_item_icon">Значок пользователя в списке контактов</string>
<string name="contactlist_no_permission">Отсутствуют разрешения, ничего не импортировано.</string>
<string name="contacts">Контакты</string>
@ -233,6 +235,7 @@
<string name="drawer_item_all_files">Все файлы</string>
<string name="drawer_item_favorites">Избранное</string>
<string name="drawer_item_gallery">Медиа</string>
<string name="drawer_item_groupfolders">Групповые папки</string>
<string name="drawer_item_home">Главная</string>
<string name="drawer_item_notifications">Уведомления</string>
<string name="drawer_item_on_device">На устройстве</string>
@ -682,6 +685,7 @@
<string name="share_password_title">Защищено паролем</string>
<string name="share_permission_can_edit">Можно редактировать</string>
<string name="share_permission_file_drop">Принимать файлы</string>
<string name="share_permission_secure_file_drop">Защищенный очиститель файлов</string>
<string name="share_permission_view_only">Только просмотр</string>
<string name="share_permissions">Права на публикацию</string>
<string name="share_remote_clarification">%1$s (на сервере)</string>
@ -796,6 +800,7 @@
<string name="thumbnail">Миниатюра</string>
<string name="thumbnail_for_existing_file_description">Миниатюра существующего файла</string>
<string name="thumbnail_for_new_file_desc">Миниатюра нового файла</string>
<string name="timeout_richDocuments">Загрузка занимает больше времени, чем ожидалось</string>
<string name="today">Сегодня</string>
<string name="trashbin_activity_title">Удалённые файлы</string>
<string name="trashbin_empty_headline">Нет удалённых файлов</string>

View file

@ -1080,4 +1080,5 @@
<string name="download_download_invalid_local_file_name">Invalid filename for local file</string>
<string name="drawer_item_groupfolders">Groupfolders</string>
<string name="tags_more" translatable="false">+%1$d</string>
<string name="pdf_password_protected">Unable to open password-protected PDF. Please use an external PDF viewer.</string>
</resources>

View file

@ -69,7 +69,8 @@ class LogsViewModelTest {
override val lostEntries: Boolean = false
override fun load(onLoaded: OnLogsLoaded) { this.onLoadedCallback = onLoaded; loadRequestCount++ }
override fun deleteAll() { /* no implementation neeeded */
override fun deleteAll() {
/* no implementation needed */
}
}