Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 10, 2023
2 parents f8f890c + 6ff60c5 commit 1e2c613
Show file tree
Hide file tree
Showing 28 changed files with 881 additions and 943 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import android.app.Activity
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.action.ViewActions.scrollTo
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.DrawerActions
import androidx.test.espresso.contrib.NavigationViewActions
Expand Down Expand Up @@ -238,12 +240,15 @@ class FileDisplayActivityIT : AbstractOnServerIT() {
onView(withId(R.id.sort_button)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))

// browse into folder
onView(withId(R.id.list_root)).perform(
RecyclerViewActions.actionOnItemAtPosition<OCFileListItemViewHolder>(
0,
click()
onView(withId(R.id.list_root))
.perform(scrollTo())
.perform(closeSoftKeyboard())
.perform(
RecyclerViewActions.actionOnItemAtPosition<OCFileListItemViewHolder>(
0,
click()
)
)
)
shortSleep()
checkToolbarTitle(topFolder)
// sort button should now be visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ public static void deleteAllFilesOnServer() {

if (!remoteFile.getRemotePath().equals("/")) {
if (remoteFile.isEncrypted()) {
assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
remoteFile.getRemotePath(),
false)
.execute(client)
.isSuccess());
ToggleEncryptionRemoteOperation operation = new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
remoteFile.getRemotePath(),
false);

boolean operationResult = operation
.execute(client)
.isSuccess();

assertTrue(operationResult);
}

boolean removeResult = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.owncloud.android.R
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
import com.owncloud.android.ui.trashbin.TrashbinRepository.LoadFolderCallback

class TrashbinLocalRepository(val testCase: TrashbinActivityIT.TestCase) : TrashbinRepository {
class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase) : TrashbinRepository {
override fun emptyTrashbin(callback: TrashbinRepository.OperationCallback?) {
TODO("Not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,19 @@ class MediaFoldersDetectionWork constructor(
)
val imageMediaFolderPaths: MutableList<String> = ArrayList()
val videoMediaFolderPaths: MutableList<String> = ArrayList()

for (imageMediaFolder in imageMediaFolders) {
imageMediaFolderPaths.add(imageMediaFolder.absolutePath)
imageMediaFolder.absolutePath?.let {
imageMediaFolderPaths.add(it)
}
}

for (videoMediaFolder in videoMediaFolders) {
imageMediaFolderPaths.add(videoMediaFolder.absolutePath)
videoMediaFolder.absolutePath?.let {
imageMediaFolderPaths.add(it)
}
}

val arbitraryDataString = arbitraryDataProvider.getValue(ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS)
if (!TextUtils.isEmpty(arbitraryDataString)) {
mediaFoldersModel = gson.fromJson(arbitraryDataString, MediaFoldersModel::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,21 @@ class FirstRunActivity : BaseActivity(), ViewPager.OnPageChangeListener, Injecta
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onFinish()
val isFromAddAccount = intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)

if (intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
onBackPressedDispatcher.onBackPressed()
val destination: Intent = if (isFromAddAccount) {
Intent(applicationContext, FileDisplayActivity::class.java)
} else {
val intent = Intent(applicationContext, AuthenticatorActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.putExtra(EXTRA_EXIT, true)
startActivity(intent)
finish()
Intent(applicationContext, AuthenticatorActivity::class.java)
}

if (!isFromAddAccount) {
destination.putExtra(EXTRA_EXIT, true)
}

destination.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(destination)
finish()
}
}
)
Expand Down
70 changes: 39 additions & 31 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ protected void attachBaseContext(Context base) {

if (!isCrashReportingProcess && !appInfo.isDebugBuild()) {
Thread.UncaughtExceptionHandler defaultPlatformHandler = Thread.getDefaultUncaughtExceptionHandler();
final ExceptionHandler crashReporter = new ExceptionHandler(this,
defaultPlatformHandler);
Thread.setDefaultUncaughtExceptionHandler(crashReporter);

if (defaultPlatformHandler != null) {
final ExceptionHandler crashReporter = new ExceptionHandler(this,
defaultPlatformHandler);
Thread.setDefaultUncaughtExceptionHandler(crashReporter);
}
}
}

Expand Down Expand Up @@ -791,25 +794,34 @@ private static void splitOutAutoUploadEntries(Clock clock,
+ syncedFolder.getId() + " - " + syncedFolder.getLocalPath());

for (MediaFolder imageMediaFolder : imageMediaFolders) {
if (imageMediaFolder.absolutePath.equals(syncedFolder.getLocalPath())) {
newSyncedFolder = (SyncedFolder) syncedFolder.clone();
newSyncedFolder.setType(MediaFolderType.IMAGE);
primaryKey = syncedFolderProvider.storeSyncedFolder(newSyncedFolder);
Log_OC.i(TAG, "Migrated image synced_folders record: "
+ primaryKey + " - " + newSyncedFolder.getLocalPath());
break;
String absolutePathOfImageFolder = imageMediaFolder.absolutePath;

if (absolutePathOfImageFolder != null) {
if (absolutePathOfImageFolder.equals(syncedFolder.getLocalPath())) {
newSyncedFolder = (SyncedFolder) syncedFolder.clone();
newSyncedFolder.setType(MediaFolderType.IMAGE);
primaryKey = syncedFolderProvider.storeSyncedFolder(newSyncedFolder);
Log_OC.i(TAG, "Migrated image synced_folders record: "
+ primaryKey + " - " + newSyncedFolder.getLocalPath());
break;
}
}
}

for (MediaFolder videoMediaFolder : videoMediaFolders) {
if (videoMediaFolder.absolutePath.equals(syncedFolder.getLocalPath())) {
newSyncedFolder = (SyncedFolder) syncedFolder.clone();
newSyncedFolder.setType(MediaFolderType.VIDEO);
primaryKey = syncedFolderProvider.storeSyncedFolder(newSyncedFolder);
Log_OC.i(TAG, "Migrated video synced_folders record: "
+ primaryKey + " - " + newSyncedFolder.getLocalPath());
break;
String absolutePathOfVideoFolder = videoMediaFolder.absolutePath;

if (absolutePathOfVideoFolder != null) {
if (absolutePathOfVideoFolder.equals(syncedFolder.getLocalPath())) {
newSyncedFolder = (SyncedFolder) syncedFolder.clone();
newSyncedFolder.setType(MediaFolderType.VIDEO);
primaryKey = syncedFolderProvider.storeSyncedFolder(newSyncedFolder);
Log_OC.i(TAG, "Migrated video synced_folders record: "
+ primaryKey + " - " + newSyncedFolder.getLocalPath());
break;
}
}

}
}

Expand All @@ -835,19 +847,22 @@ private static void cleanOldEntries(Clock clock) {

List<SyncedFolder> syncedFolderList = syncedFolderProvider.getSyncedFolders();
Map<Pair<String, String>, Long> syncedFolders = new HashMap<>();
ArrayList<Long> ids = new ArrayList<>();
for (SyncedFolder syncedFolder : syncedFolderList) {
Pair<String, String> checkPair = new Pair<>(syncedFolder.getAccount(), syncedFolder.getLocalPath());
if (syncedFolders.containsKey(checkPair)) {
if (syncedFolder.getId() > syncedFolders.get(checkPair)) {
syncedFolders.put(checkPair, syncedFolder.getId());
Long folderId = syncedFolders.get(checkPair);

if (folderId != null) {
if (syncedFolder.getId() > folderId) {
syncedFolders.put(checkPair, syncedFolder.getId());
}
}
} else {
syncedFolders.put(checkPair, syncedFolder.getId());
}
}

ids.addAll(syncedFolders.values());
ArrayList<Long> ids = new ArrayList<>(syncedFolders.values());

if (ids.size() > 0) {
int deletedCount = syncedFolderProvider.deleteSyncedFoldersNotInList(ids);
Expand All @@ -865,18 +880,11 @@ public AndroidInjector<Object> androidInjector() {
return dispatchingAndroidInjector;
}


public static void setAppTheme(DarkMode mode) {
switch (mode) {
case LIGHT:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
break;
case DARK:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
break;
case SYSTEM:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
break;
case LIGHT -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
case DARK -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
case SYSTEM -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.owncloud.android.authentication

import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import com.nextcloud.client.di.Injectable
import com.owncloud.android.R

class DeepLinkLoginActivity : AuthenticatorActivity(), Injectable {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

if (!resources.getBoolean(R.bool.multiaccount_support) &&
accountManager.accounts.size == 1
) {
Toast.makeText(this, R.string.no_mutliple_accounts_allowed, Toast.LENGTH_LONG).show()
return
}

setContentView(R.layout.deep_link_login)

intent.data?.let {
try {
val prefix = getString(R.string.login_data_own_scheme) + PROTOCOL_SUFFIX + "login/"
val loginUrlInfo = parseLoginDataUrl(prefix, it.toString())
val loginText = findViewById<TextView>(R.id.loginInfo)
loginText.text = String.format(
getString(R.string.direct_login_text), loginUrlInfo.username,
loginUrlInfo.serverAddress
)
} catch (e: IllegalArgumentException) {
Toast.makeText(this, R.string.direct_login_failed, Toast.LENGTH_LONG).show()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@
* 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 <http://www.gnu.org/licenses/>.
* License along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.datamodel;

import java.util.ArrayList;
import java.util.List;
package com.owncloud.android.datamodel

/**
* Business object representing a media folder with all information that are gathered via media queries.
*/
public class MediaFolder {
/** name of the folder. */
public String folderName;
class MediaFolder {
/** name of the folder. */
@JvmField
var folderName: String? = null

/** absolute path of the folder. */
@JvmField
var absolutePath: String? = null

/** absolute path of the folder. */
public String absolutePath;

/** list of file paths of the folder's content */
public List<String> filePaths = new ArrayList<>();
/** list of file paths of the folder's content */
@JvmField
var filePaths: List<String> = ArrayList()

/** total number of files in the media folder. */
public long numberOfFiles;
/** total number of files in the media folder. */
@JvmField
var numberOfFiles: Long = 0

/** type of media folder. */
public MediaFolderType type;
/** type of media folder. */
@JvmField
var type: MediaFolderType? = null
}
Loading

0 comments on commit 1e2c613

Please sign in to comment.