mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Formated the code + added header
This commit is contained in:
parent
c821f192d6
commit
c59f9c0b91
2 changed files with 33 additions and 12 deletions
|
@ -1,5 +1,26 @@
|
|||
package com.owncloud.android.ui.activity;
|
||||
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Kilian Périsset
|
||||
* Copyright (C) 2019 Kilian Périsset (Infomaniak Network SA)
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -19,7 +40,7 @@ public class FolderPickerActivityTest {
|
|||
new ActivityTestRule<>(FolderPickerActivity.class);
|
||||
|
||||
@Test
|
||||
public void getFile_NoDifferenceTest() {
|
||||
public void getActivityFile() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.test");
|
||||
|
@ -34,7 +55,7 @@ public class FolderPickerActivityTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isNotRootFolderTest() {
|
||||
public void getParentFolder_isNotRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/");
|
||||
|
@ -52,7 +73,7 @@ public class FolderPickerActivityTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isRootFolderTest() {
|
||||
public void getParentFolder_isRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/");
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.nextcloud.client.di.Injectable;
|
|||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
|
@ -59,6 +60,8 @@ import com.owncloud.android.utils.DataHolderUtil;
|
|||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import javax.inject.Inject;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
|
@ -299,8 +302,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_create_dir: {
|
||||
OCFile currentFolder = getCurrentFolder();
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(currentFolder);
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
break;
|
||||
}
|
||||
|
@ -333,20 +335,18 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
protected OCFile getCurrentFolder() {
|
||||
OCFile currentFile = getFile();
|
||||
OCFile finalFolder = null;
|
||||
FileDataStorageManager storageManager = getStorageManager();
|
||||
|
||||
// If the file is null, take the root folder to avoid any error in functions depending on this one
|
||||
if (currentFile != null) {
|
||||
if (currentFile.isFolder()) {
|
||||
finalFolder = currentFile;
|
||||
} else if(currentFile.getRemotePath() != null) {
|
||||
String parentPath = currentFile
|
||||
.getRemotePath()
|
||||
.substring(0, currentFile.getRemotePath()
|
||||
.lastIndexOf(currentFile.getFileName()));
|
||||
finalFolder = getStorageManager().getFileByPath(parentPath);
|
||||
} else if (currentFile.getRemotePath() != null) {
|
||||
long parentId = currentFile.getParentId();
|
||||
finalFolder = storageManager.getFileById(parentId);
|
||||
}
|
||||
} else {
|
||||
finalFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||
finalFolder = storageManager.getFileByPath(OCFile.ROOT_PATH);
|
||||
}
|
||||
return finalFolder;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue