reformat code

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2023-05-29 21:33:23 +02:00
parent c776bfd0e7
commit c7d0d0f47d
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
21 changed files with 100 additions and 45 deletions

View file

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

View file

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

View file

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

View file

@ -81,11 +81,13 @@ class AccountRemovalWork(
@Suppress("ReturnCount") // legacy code @Suppress("ReturnCount") // legacy code
override fun doWork(): Result { override fun doWork(): Result {
val accountName = inputData.getString(ACCOUNT) ?: "" 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() return Result.failure()
} }
val optionalUser = userAccountManager.getUser(accountName) 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() return Result.failure()
} }
val remoteWipe = inputData.getBoolean(REMOTE_WIPE, false) val remoteWipe = inputData.getBoolean(REMOTE_WIPE, false)

View file

@ -52,7 +52,8 @@ class CalendarBackupWork(
override fun doWork(): Result { override fun doWork(): Result {
val accountName = inputData.getString(ACCOUNT) ?: "" val accountName = inputData.getString(ACCOUNT) ?: ""
val optionalUser = accountManager.getUser(accountName) 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") Log_OC.d(TAG, "User not present")
return Result.failure() return Result.failure()
} }

View file

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

View file

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

View file

@ -67,21 +67,21 @@ object ErrorFormat {
/* Added in API level 17 /* Added in API level 17
Some operation takes too long to complete, usually more than 3-5 seconds. Some operation takes too long to complete, usually more than 3-5 seconds.
Constant Value: -110 (0xffffff92) Constant Value: -110 (0xffffff92)
*/ */
messageId = R.string.media_err_timeout messageId = R.string.media_err_timeout
} else if (what == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) { } else if (what == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
/* Added in API level 3 /* Added in API level 3
The video is streamed and its container is not valid for progressive playback i.e the video's index The video is streamed and its container is not valid for progressive playback i.e the video's index
(e.g moov atom) is not at the start of the file. (e.g moov atom) is not at the start of the file.
Constant Value: 200 (0x000000c8) Constant Value: 200 (0x000000c8)
*/ */
messageId = R.string.media_err_invalid_progressive_playback messageId = R.string.media_err_invalid_progressive_playback
} else { } else {
/* MediaPlayer.MEDIA_ERROR_UNKNOWN /* MediaPlayer.MEDIA_ERROR_UNKNOWN
Added in API level 1 Added in API level 1
Unspecified media player error. Unspecified media player error.
Constant Value: 1 (0x00000001) Constant Value: 1 (0x00000001)
*/ */
/* MediaPlayer.MEDIA_ERROR_SERVER_DIED) /* MediaPlayer.MEDIA_ERROR_SERVER_DIED)
Added in API level 1 Added in API level 1
Media server died. In this case, the application must release the MediaPlayer Media server died. In this case, the application must release the MediaPlayer

View file

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

View file

@ -28,13 +28,39 @@ import android.os.Bundle
* a mix-in. * a mix-in.
*/ */
interface ActivityMixin { interface ActivityMixin {
fun onNewIntent(intent: Intent) { /* no-op */ } fun onNewIntent(intent: Intent) {
fun onSaveInstanceState(outState: Bundle) { /* no-op */ } /* no-op */
fun onCreate(savedInstanceState: Bundle?) { /* no-op */ } }
fun onRestart() { /* no-op */ }
fun onStart() { /* no-op */ } fun onSaveInstanceState(outState: Bundle) {
fun onResume() { /* no-op */ } /* no-op */
fun onPause() { /* no-op */ } }
fun onStop() { /* no-op */ }
fun onDestroy() { /* 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) @RequiresApi(Build.VERSION_CODES.R)
private fun private fun getQueryArgsBundle(
getQueryArgsBundle(selection: String?, sortColumn: String?, sortDirection: String?, limit: Int?): Bundle { selection: String?,
sortColumn: String?,
sortDirection: String?,
limit: Int?
): Bundle {
return Bundle().apply { return Bundle().apply {
if (selection != null) { if (selection != null) {
putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selection) 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 onWifiOnly = intent.getBooleanExtra(KEY_WHILE_ON_WIFI_ONLY, false);
boolean whileChargingOnly = intent.getBooleanExtra(KEY_WHILE_CHARGING_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)) { 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"); Log_OC.e(TAG, "Not enough information provided in intent: no KEY_RETRY_UPLOAD_KEY");
return START_NOT_STICKY; return START_NOT_STICKY;
} }
retryUploads(intent, user, requestedUploads); retryUploads(intent, user, requestedUploads);
} else { // Start new uploads } else {
// Start new uploads
if (!(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) { if (!(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
Log_OC.e(TAG, "Not enough information provided in intent"); Log_OC.e(TAG, "Not enough information provided in intent");
return Service.START_NOT_STICKY; return Service.START_NOT_STICKY;
@ -793,7 +795,8 @@ public class FileUploader extends Service
boolean needsToUpdateCredentials = uploadResult.getCode() == ResultCode.UNAUTHORIZED; boolean needsToUpdateCredentials = uploadResult.getCode() == ResultCode.UNAUTHORIZED;
if (needsToUpdateCredentials) { if (needsToUpdateCredentials) {
tickerId = R.string.uploader_upload_failed_credentials_error; 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; tickerId = R.string.uploader_upload_failed_sync_conflict_error;
} }

View file

@ -336,7 +336,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
saveFolderInDB(); saveFolderInDB();
} }
} }
} else { // Create directory on DB } else {
// Create directory on DB
OCFile newDir = new OCFile(remotePath); OCFile newDir = new OCFile(remotePath);
newDir.setMimeType(MimeType.DIRECTORY); newDir.setMimeType(MimeType.DIRECTORY);
long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(remotePath)).getFileId(); 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()); Handler handler = new Handler(context.getMainLooper());
try { try {
return ParcelFileDescriptor.open(file, accessMode, handler, error -> { 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. // As we can't upload the file synchronously, let's at least update its metadata here already.
ocFile.setFileLength(file.length()); ocFile.setFileLength(file.length());
ocFile.setModificationTimestamp(System.currentTimeMillis()); ocFile.setModificationTimestamp(System.currentTimeMillis());
@ -275,7 +276,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
LOCAL_BEHAVIOUR_DELETE, LOCAL_BEHAVIOUR_DELETE,
NameCollisionPolicy.OVERWRITE, NameCollisionPolicy.OVERWRITE,
false); false);
} else { // error, no upload needed } else {
// error, no upload needed
Log_OC.e(TAG, "File was closed with an error: " + ocFile.getFileName(), error); 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. // Was tried without password, but not sure that it's optional.
// Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener // 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, sharingFragment.requestPasswordForShareViaLink(true,
getCapabilities().getFilesSharingPublicAskForOptionalPassword() getCapabilities().getFilesSharingPublicAskForOptionalPassword()

View file

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

View file

@ -497,7 +497,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
String remotePath = item.getRemotePath(); String remotePath = item.getRemotePath();
OCFile ocFile = storageManager.getFileByPath(remotePath); 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() + "/"); OCFile folder = storageManager.getFileByPath(new File(remotePath).getParent() + "/");
if (folder != null && folder.isFolder()) { if (folder != null && folder.isFolder()) {
this.refreshFolder(itemViewHolder, user, folder, (caller, result) -> { 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); 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); viewThemeUtils.material.themeFAB(mFabMain);
} }
@ -387,7 +388,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
registerFabListener(); registerFabListener();
} }
if (!searchFragment) { // do not touch search event if previously searched if (!searchFragment) {
// do not touch search event if previously searched
if (getArguments() == null) { if (getArguments() == null) {
searchEvent = null; searchEvent = null;
} else { } else {
@ -478,7 +480,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
public void registerFabListener() { public void registerFabListener() {
FileActivity activity = (FileActivity) getActivity(); FileActivity activity = (FileActivity) getActivity();
if (mFabMain != null) { // is not available in FolderPickerActivity if (mFabMain != null) {
// is not available in FolderPickerActivity
viewThemeUtils.material.themeFAB(mFabMain); viewThemeUtils.material.themeFAB(mFabMain);
mFabMain.setOnClickListener(v -> { mFabMain.setOnClickListener(v -> {
final OCFileListBottomSheetDialog dialog = final OCFileListBottomSheetDialog dialog =
@ -1028,7 +1031,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
intent.putExtra(FolderPickerActivity.EXTRA_FILES, file); intent.putExtra(FolderPickerActivity.EXTRA_FILES, file);
getActivity().setResult(Activity.RESULT_OK, intent); getActivity().setResult(Activity.RESULT_OK, intent);
getActivity().finish(); getActivity().finish();
} else if (!mOnlyFoldersClickable) { // Click on a file } else if (!mOnlyFoldersClickable) {
// Click on a file
if (PreviewImageFragment.canBePreviewed(file)) { if (PreviewImageFragment.canBePreviewed(file)) {
// preview image - it handles the download, if needed // preview image - it handles the download, if needed
if (searchFragment) { if (searchFragment) {

View file

@ -583,7 +583,8 @@ public final class FileStorageUtils {
} }
FileStorageUtils.StandardDirectory standardDirectory = FileStorageUtils.StandardDirectory.fromPath(storageFolder); 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()); storageFolder = " " + resources.getString(standardDirectory.getDisplayName());
} }

View file

@ -433,13 +433,15 @@ public class ProcessVEvent {
// - Check the calendars max number of alarms // - Check the calendars max number of alarms
if (t.getDateTime() != null) { if (t.getDateTime() != null) {
alarmMs = t.getDateTime().getTime(); // Absolute 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); Related rel = (Related) t.getParameter(Parameter.RELATED);
if (rel != null && rel == Related.END) { if (rel != null && rel == Related.END) {
alarmStartMs = e.getEndDate().getDate().getTime(); alarmStartMs = e.getEndDate().getDate().getTime();
} }
alarmMs = alarmStartMs - durationToMs(t.getDuration()); // Relative "-" 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); Related rel = (Related) t.getParameter(Parameter.RELATED);
if (rel != null && rel == Related.END) { if (rel != null && rel == Related.END) {
alarmStartMs = e.getEndDate().getDate().getTime(); alarmStartMs = e.getEndDate().getDate().getTime();

View file

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