Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db407b0b6a | ||
|
|
5b2c912a66 |
No files matched your search
@@ -1,11 +1,10 @@
|
||||
# synced from @nextcloud/android-config
|
||||
name: "Analysis"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "master", "main", "stable-*" ]
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ "master", "main", "stable-*" ]
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
@@ -17,7 +16,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup variables
|
||||
id: get-vars
|
||||
@@ -33,12 +32,12 @@ jobs:
|
||||
echo "pr=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
with:
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck ]
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -26,13 +26,13 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- name: Set Swap Space
|
||||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
|
||||
uses: github/codeql-action/init@6ca1aa8c195c3ca3e77c174fe0356db1bce3b319 # v2.21.1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 17
|
||||
@@ -46,4 +46,4 @@ jobs:
|
||||
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
|
||||
uses: github/codeql-action/analyze@6ca1aa8c195c3ca3e77c174fe0356db1bce3b319 # v2.21.1
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
reaction-type: "+1"
|
||||
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
@@ -16,9 +16,9 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -18,5 +18,5 @@ jobs:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0
|
||||
@@ -1,8 +1,3 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: 'Ask for feedback on PRs'
|
||||
on:
|
||||
schedule:
|
||||
@@ -10,7 +5,7 @@ on:
|
||||
|
||||
jobs:
|
||||
pr-feedback:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: The get-github-handles-from-website action
|
||||
uses: marcelklehr/get-github-handles-from-website-action@a739600f6b91da4957f51db0792697afbb2f143c # v1.0.0
|
||||
@@ -23,12 +18,12 @@ jobs:
|
||||
Hello there,
|
||||
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
|
||||
|
||||
We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
|
||||
We hope that the reviewing process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR reviewing process.
|
||||
|
||||
Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
|
||||
|
||||
Thank you for contributing to Nextcloud and we hope to hear from you soon!
|
||||
days-before-feedback: 14
|
||||
start-date: "2023-07-10"
|
||||
exempt-authors: "${{ steps.scrape.outputs.users }},nextcloud-command,nextcloud-android-bot"
|
||||
exempt-authors: "${{ steps.scrape.outputs.users }}"
|
||||
exempt-bots: true
|
||||
@@ -19,10 +19,10 @@ jobs:
|
||||
- name: Check if secrets are available
|
||||
run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}"
|
||||
id: check-secrets
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -37,6 +37,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
|
||||
uses: github/codeql-action/upload-sarif@6ca1aa8c195c3ca3e77c174fe0356db1bce3b319 # v2.21.1
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
color: [ blue ]
|
||||
api-level: [ 27 ]
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
|
||||
- uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -18,9 +18,9 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
|
||||
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
- name: Run unit tests with coverage
|
||||
uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1
|
||||
uses: gradle/gradle-build-action@915a66c096a03101667f9df2e56c9efef558b165 # v2.6.1
|
||||
with:
|
||||
arguments: jacocoTestGplayDebugUnitTest
|
||||
- name: Upload failing results
|
||||
|
||||
@@ -4,9 +4,9 @@ import org.gradle.internal.jvm.Jvm
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$androidPluginVersion"
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.1.3'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.1"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:5.14.1'
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
@@ -57,7 +57,7 @@ configurations.configureEach {
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 27
|
||||
def versionMinor = 26
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
@@ -82,7 +82,7 @@ android {
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 33
|
||||
|
||||
buildConfigField 'boolean', 'CI', ciBuild.toString()
|
||||
@@ -318,8 +318,6 @@ dependencies {
|
||||
// dependencies for image cropping and rotation
|
||||
implementation 'com.vanniktech:android-image-cropper:4.5.0'
|
||||
|
||||
implementation 'org.osmdroid:osmdroid-android:6.1.16'
|
||||
|
||||
implementation('org.mnode.ical4j:ical4j:3.0.0') {
|
||||
['org.apache.commons', 'commons-logging'].each {
|
||||
exclude group: "$it"
|
||||
@@ -375,7 +373,7 @@ dependencies {
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
|
||||
// upon each update first test: new registration, receive push
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:23.2.1"
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:23.1.2"
|
||||
gplayImplementation 'com.google.android.play:review-ktx:2.0.1'
|
||||
|
||||
implementation 'com.github.nextcloud.android-common:ui:0.12.0'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
build:
|
||||
maxIssues: 2
|
||||
maxIssues: 0
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 178 KiB |
|
Before Width: | Height: | Size: 56 KiB |
@@ -111,7 +111,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
if (capability.getVersion().equals(new OwnCloudVersion("0.0.0"))) {
|
||||
// fetch new one
|
||||
assertTrue(new GetCapabilitiesOperation(getStorageManager())
|
||||
.execute(nextcloudClient)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
// tests only for NC19+
|
||||
|
||||
@@ -25,7 +25,6 @@ package com.nextcloud.client;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.client.preferences.SubFolderRule;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.MediaFolderType;
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
|
||||
@@ -73,8 +72,7 @@ public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
1000,
|
||||
"Name",
|
||||
MediaFolderType.IMAGE,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH);
|
||||
false);
|
||||
SyncedFolderPreferencesDialogFragment sut = SyncedFolderPreferencesDialogFragment.newInstance(item, 0);
|
||||
|
||||
Intent intent = new Intent(targetContext, SyncedFoldersActivity.class);
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -244,12 +245,35 @@ public abstract class AbstractIT {
|
||||
}
|
||||
}
|
||||
|
||||
public static File createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getTemporalPath(account.name) + File.separator + name);
|
||||
public static File createFile(String name, long size) throws IOException {
|
||||
File file = new File(FileStorageUtils.getInternalTemporalPath(account.name, targetContext) + File.separator + name);
|
||||
if (!file.getParentFile().exists()) {
|
||||
assertTrue(file.getParentFile().mkdirs());
|
||||
}
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
file.createNewFile();
|
||||
|
||||
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
|
||||
randomAccessFile.setLength(size);
|
||||
randomAccessFile.close();
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public static File createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getInternalTemporalPath(account.name, targetContext) + File.separator + name);
|
||||
if (!file.getParentFile().exists()) {
|
||||
assertTrue(file.getParentFile().mkdirs());
|
||||
}
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
|
||||
@@ -32,8 +32,6 @@ import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.model.GeoLocation;
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
@@ -54,7 +52,6 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -472,59 +469,7 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
assertEquals(remotePath, ocFile.getRemotePath());
|
||||
assertEquals(creationTimestamp, ocFile.getCreationTimestamp());
|
||||
assertTrue(uploadTimestamp - 10 < ocFile.getUploadTimestamp() ||
|
||||
uploadTimestamp + 10 > ocFile.getUploadTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetadata() throws IOException {
|
||||
File file = getFile("gps.jpg");
|
||||
String remotePath = "/gps.jpg";
|
||||
OCUpload ocUpload = new OCUpload(file.getAbsolutePath(), remotePath, account.name);
|
||||
|
||||
assertTrue(
|
||||
new UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
getStorageManager()
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client)
|
||||
.isSuccess()
|
||||
);
|
||||
|
||||
// RefreshFolderOperation
|
||||
assertTrue(new RefreshFolderOperation(getStorageManager().getFileByDecryptedRemotePath("/"),
|
||||
System.currentTimeMillis() / 1000,
|
||||
false,
|
||||
false,
|
||||
getStorageManager(),
|
||||
user,
|
||||
targetContext).execute(client).isSuccess());
|
||||
|
||||
List<OCFile> files = getStorageManager().getFolderContent(getStorageManager().getFileByDecryptedRemotePath("/"),
|
||||
false);
|
||||
|
||||
OCFile ocFile = null;
|
||||
for (OCFile f : files) {
|
||||
if (f.getFileName().equals("gps.jpg")) {
|
||||
ocFile = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(ocFile);
|
||||
assertEquals(remotePath, ocFile.getRemotePath());
|
||||
assertEquals(new ImageDimension(451f, 529f), ocFile.getImageDimension());
|
||||
assertEquals(new GeoLocation(49.99679166666667, 8.67198611111111), ocFile.getGeoLocation());
|
||||
uploadTimestamp + 10 > ocFile.getUploadTimestamp());
|
||||
}
|
||||
|
||||
private void verifyStoragePath(OCFile file) {
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract public class FileDataStorageManagerIT extends AbstractOnServerIT {
|
||||
assertEquals(0, sut.getAllFiles().size());
|
||||
|
||||
capability = (OCCapability) new GetCapabilitiesRemoteOperation(null)
|
||||
.execute(nextcloudClient)
|
||||
.execute(client)
|
||||
.getSingleData();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.nextcloud.ui.ImageDetailFragment
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -41,16 +40,13 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
var file = getFile("gps.jpg")
|
||||
val oCFile = OCFile("/").apply {
|
||||
storagePath = file.absolutePath
|
||||
}
|
||||
val file = OCFile("/")
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showFileDetailActivitiesFragment() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(file, user))
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
@@ -62,19 +58,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
@ScreenshotTest
|
||||
fun showFileDetailSharingFragment() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showFileDetailDetailsFragment() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
sut.addFragment(ImageDetailFragment.newInstance(oCFile, user))
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(file, user))
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
@@ -87,7 +71,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
@Suppress("MagicNumber")
|
||||
fun showDetailsActivities() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val sut = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
val sut = FileDetailFragment.newInstance(file, user, 0)
|
||||
activity.addFragment(sut)
|
||||
|
||||
waitForIdleSync()
|
||||
@@ -157,7 +141,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
// @ScreenshotTest
|
||||
fun showDetailsActivitiesNone() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val sut = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
val sut = FileDetailFragment.newInstance(file, user, 0)
|
||||
activity.addFragment(sut)
|
||||
|
||||
waitForIdleSync()
|
||||
@@ -175,7 +159,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
@ScreenshotTest
|
||||
fun showDetailsActivitiesError() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val sut = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
val sut = FileDetailFragment.newInstance(file, user, 0)
|
||||
activity.addFragment(sut)
|
||||
|
||||
waitForIdleSync()
|
||||
@@ -195,7 +179,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
@ScreenshotTest
|
||||
fun showDetailsSharing() {
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
sut.addFragment(FileDetailFragment.newInstance(oCFile, user, 1))
|
||||
sut.addFragment(FileDetailFragment.newInstance(file, user, 1))
|
||||
|
||||
waitForIdleSync()
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ import android.graphics.Paint
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.ImageDimension
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.InitDiskCacheTask
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertNotNull
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.owncloud.android.datamodel.DecryptedFolderMetadata;
|
||||
import com.owncloud.android.datamodel.EncryptedFolderMetadata;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.CsrHelper;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
@@ -44,7 +45,6 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyPair;
|
||||
@@ -65,7 +65,6 @@ import javax.crypto.BadPaddingException;
|
||||
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static com.owncloud.android.utils.EncryptionUtils.EncryptedFile;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decodeStringToBase64Bytes;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptFile;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptFolderMetaData;
|
||||
@@ -91,6 +90,7 @@ import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -401,6 +401,19 @@ public class EncryptionTestIT extends AbstractIT {
|
||||
assertTrue(cryptFile("ia7OEEEyXMoRa1QWQk8r", "78f42172166f9dc8fd1a7156b1753353", key, iv, authTag));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargeFile() throws Exception {
|
||||
byte[] key = decodeStringToBase64Bytes("WANM0gRv+DhaexIsI0T3Lg==");
|
||||
byte[] iv = decodeStringToBase64Bytes("gKm3n+mJzeY26q4OfuZEqg==");
|
||||
|
||||
createFile("large1", 500 * 1024 * 1024L);
|
||||
File file = getDummyFile("large1");
|
||||
String md5 = getMD5Sum(file);
|
||||
Log_OC.d("Large file", "Size: " + DisplayUtils.bytesToHumanReadable(file.length()));
|
||||
|
||||
assertTrue(cryptFile(file, md5, key, iv, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cryptFileWithMetadata() throws Exception {
|
||||
DecryptedFolderMetadata metadata = generateFolderMetadata();
|
||||
@@ -751,28 +764,34 @@ public class EncryptionTestIT extends AbstractIT {
|
||||
private boolean cryptFile(String fileName, String md5, byte[] key, byte[] iv, byte[] expectedAuthTag)
|
||||
throws Exception {
|
||||
File file = getFile(fileName);
|
||||
|
||||
return cryptFile(file, md5, key, iv, expectedAuthTag);
|
||||
}
|
||||
|
||||
private boolean cryptFile(File file, String md5, byte[] key, byte[] iv, byte[] expectedAuthTag)
|
||||
throws Exception {
|
||||
assertEquals(md5, getMD5Sum(file));
|
||||
|
||||
EncryptedFile encryptedFile = encryptFile(file, key, iv);
|
||||
File encryptedLargeTempFile = File.createTempFile("largeEncrypted", "tmp");
|
||||
byte[] authenticationTag = encryptFile(file, encryptedLargeTempFile, key, iv);
|
||||
|
||||
File encryptedTempFile = File.createTempFile("file", "tmp");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(encryptedTempFile);
|
||||
fileOutputStream.write(encryptedFile.encryptedBytes);
|
||||
fileOutputStream.close();
|
||||
|
||||
byte[] authenticationTag = decodeStringToBase64Bytes(encryptedFile.authenticationTag);
|
||||
assertNotNull(authenticationTag);
|
||||
|
||||
// verify authentication tag
|
||||
assertTrue(Arrays.equals(expectedAuthTag, authenticationTag));
|
||||
if (expectedAuthTag != null) {
|
||||
assertEquals(expectedAuthTag, authenticationTag);
|
||||
}
|
||||
|
||||
byte[] decryptedBytes = decryptFile(encryptedTempFile, key, iv, authenticationTag);
|
||||
File decryptedLargeTempFile = File.createTempFile("largeDecrypted", "tmp");
|
||||
assertTrue(decryptFile(encryptedLargeTempFile,
|
||||
decryptedLargeTempFile,
|
||||
key,
|
||||
iv,
|
||||
authenticationTag
|
||||
)
|
||||
);
|
||||
|
||||
File decryptedFile = File.createTempFile("file", "dec");
|
||||
FileOutputStream fileOutputStream1 = new FileOutputStream(decryptedFile);
|
||||
fileOutputStream1.write(decryptedBytes);
|
||||
fileOutputStream1.close();
|
||||
|
||||
return md5.compareTo(getMD5Sum(decryptedFile)) == 0;
|
||||
return md5.compareTo(getMD5Sum(decryptedLargeTempFile)) == 0;
|
||||
}
|
||||
|
||||
private String getMD5Sum(File file) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
package com.owncloud.android.utils
|
||||
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.MediaFolder
|
||||
import com.owncloud.android.datamodel.MediaFolderType
|
||||
@@ -186,8 +185,7 @@ class SyncedFolderUtilsTest : AbstractIT() {
|
||||
true,
|
||||
0L,
|
||||
MediaFolderType.IMAGE,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH
|
||||
false
|
||||
)
|
||||
Assert.assertFalse(SyncedFolderUtils.isQualifyingMediaFolder(folder))
|
||||
}
|
||||
@@ -209,8 +207,7 @@ class SyncedFolderUtilsTest : AbstractIT() {
|
||||
true,
|
||||
0L,
|
||||
MediaFolderType.IMAGE,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH
|
||||
false
|
||||
)
|
||||
Assert.assertFalse(SyncedFolderUtils.isQualifyingMediaFolder(folder))
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.owncloud.android.datamodel.SignatureVerification;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.notifications.RegisterAccountDeviceForNotificationsOperation;
|
||||
@@ -149,8 +150,11 @@ public final class PushUtils {
|
||||
OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, context);
|
||||
|
||||
RemoteOperationResult remoteOperationResult = new
|
||||
UnregisterAccountDeviceForNotificationsOperation().execute(mClient);
|
||||
RemoteOperation unregisterAccountDeviceForNotificationsOperation = new
|
||||
UnregisterAccountDeviceForNotificationsOperation();
|
||||
|
||||
RemoteOperationResult remoteOperationResult = unregisterAccountDeviceForNotificationsOperation.
|
||||
execute(mClient);
|
||||
|
||||
if (remoteOperationResult.getHttpCode() == HttpStatus.SC_ACCEPTED) {
|
||||
String arbitraryValue;
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author ZetaTom
|
||||
* Copyright (C) 2023 ZetaTom
|
||||
* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.owncloud.android.MainApp
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.internal.http.HTTP_OK
|
||||
import java.net.URLEncoder
|
||||
|
||||
class NominatimClient constructor(geocoderBaseUrl: String, email: String) {
|
||||
private val client = OkHttpClient()
|
||||
private val gson = Gson()
|
||||
private val reverseUrl = "${geocoderBaseUrl}reverse?format=jsonv2&email=${URLEncoder.encode(email, ENCODING_UTF_8)}"
|
||||
|
||||
private fun doRequest(requestUrl: String): String? {
|
||||
val request = Request.Builder().url(requestUrl).header(HEADER_USER_AGENT, MainApp.getUserAgent()).build()
|
||||
|
||||
try {
|
||||
val response = client.newCall(request).execute()
|
||||
if (response.code == HTTP_OK) {
|
||||
return response.body.string()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse geocode specified location - get human readable name suitable for displaying from given coordinates.
|
||||
*
|
||||
* @param latitude GPS latitude
|
||||
* @param longitude GPS longitude
|
||||
* @param zoom level of detail to request
|
||||
*/
|
||||
fun reverseGeocode(
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
zoom: ZoomLevel = ZoomLevel.TOWN_BOROUGH
|
||||
): ReverseGeocodingResult? {
|
||||
val response = doRequest("$reverseUrl&addressdetails=0&zoom=${zoom.int}&lat=$latitude&lon=$longitude")
|
||||
return response?.let { gson.fromJson(it, ReverseGeocodingResult::class.java) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ENCODING_UTF_8 = "UTF-8"
|
||||
private const val HEADER_USER_AGENT = "User-Agent"
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
enum class ZoomLevel(val int: Int) {
|
||||
COUNTRY(3),
|
||||
STATE(5),
|
||||
COUNTY(8),
|
||||
CITY(10),
|
||||
TOWN_BOROUGH(12),
|
||||
VILLAGE_SUBURB(13),
|
||||
NEIGHBOURHOOD(14),
|
||||
LOCALITY(15),
|
||||
MAJOR_STREETS(16),
|
||||
MINOR_STREETS(17),
|
||||
BUILDING(18),
|
||||
MAX(19)
|
||||
}
|
||||
|
||||
data class ReverseGeocodingResult(
|
||||
@SerializedName("lat")
|
||||
val latitude: Double,
|
||||
@SerializedName("lon")
|
||||
val longitude: Double,
|
||||
val name: String,
|
||||
@SerializedName("display_name")
|
||||
val displayName: String
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,7 @@ import com.owncloud.android.db.ProviderMeta
|
||||
AutoMigration(from = 65, to = 66),
|
||||
AutoMigration(from = 66, to = 67),
|
||||
AutoMigration(from = 68, to = 69),
|
||||
AutoMigration(from = 69, to = 70),
|
||||
AutoMigration(from = 71, to = 72),
|
||||
AutoMigration(from = 72, to = 73)
|
||||
AutoMigration(from = 69, to = 70)
|
||||
],
|
||||
exportSchema = true
|
||||
)
|
||||
|
||||
@@ -119,7 +119,5 @@ data class FileEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_LOCK_TOKEN)
|
||||
val lockToken: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_TAGS)
|
||||
val tags: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_METADATA_GPS)
|
||||
val metadataGPS: String?
|
||||
val tags: String?
|
||||
)
|
||||
@@ -57,7 +57,5 @@ data class SyncedFolderEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_TYPE)
|
||||
val type: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_HIDDEN)
|
||||
val hidden: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_RULE)
|
||||
val subFolderRule: Int?
|
||||
val hidden: Int?
|
||||
)
|
||||
@@ -50,7 +50,6 @@ class LegacyMigration(
|
||||
*
|
||||
* This is needed because the [Migration] does not know which versions it's dealing with
|
||||
*/
|
||||
@Suppress("ForEachOnRange")
|
||||
fun RoomDatabase.Builder<NextcloudDatabase>.addLegacyMigrations(
|
||||
clock: Clock
|
||||
): RoomDatabase.Builder<NextcloudDatabase> {
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.nextcloud.client.widget.DashboardWidgetConfigurationActivity;
|
||||
import com.nextcloud.client.widget.DashboardWidgetProvider;
|
||||
import com.nextcloud.client.widget.DashboardWidgetService;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.ImageDetailFragment;
|
||||
import com.nextcloud.ui.SetStatusDialogFragment;
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
|
||||
import com.nmc.android.ui.LauncherActivity;
|
||||
@@ -476,6 +475,4 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract EditImageActivity editImageActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ImageDetailFragment imageDetailFragment();
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import android.app.NotificationManager
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.work.ListenableWorker
|
||||
import androidx.work.WorkerFactory
|
||||
@@ -87,7 +89,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
null
|
||||
}
|
||||
|
||||
return if (workerClass == ContentObserverWork::class) {
|
||||
// ContentObserverWork requires N
|
||||
return if (deviceInfo.apiLevel >= Build.VERSION_CODES.N && workerClass == ContentObserverWork::class) {
|
||||
createContentObserverJob(context, workerParameters)
|
||||
} else {
|
||||
when (workerClass) {
|
||||
@@ -124,14 +127,19 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private fun createContentObserverJob(
|
||||
context: Context,
|
||||
workerParameters: WorkerParameters
|
||||
): ListenableWorker {
|
||||
return ContentObserverWork(
|
||||
context,
|
||||
workerParameters,
|
||||
SyncedFolderProvider(contentResolver, preferences, clock),
|
||||
powerManagementService,
|
||||
backgroundJobManager.get()
|
||||
)
|
||||
): ListenableWorker? {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
if (deviceInfo.apiLevel >= Build.VERSION_CODES.N) {
|
||||
return ContentObserverWork(
|
||||
context,
|
||||
workerParameters,
|
||||
syncedFolderProvider,
|
||||
powerManagementService,
|
||||
backgroundJobManager.get()
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun createContactsBackupWork(context: Context, params: WorkerParameters): ContactsBackupWork {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.LiveData
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -42,6 +44,7 @@ interface BackgroundJobManager {
|
||||
* This call is idempotent - there will be only one scheduled job
|
||||
* regardless of number of calls.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun scheduleContentObserverJob()
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.map
|
||||
import androidx.work.Constraints
|
||||
@@ -209,6 +211,7 @@ internal class BackgroundJobManagerImpl(
|
||||
return workInfo.map { it -> it.map { fromWorkInfo(it) ?: JobInfo() }.sortedBy { it.started }.reversed() }
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
override fun scheduleContentObserverJob() {
|
||||
val constrains = Constraints.Builder()
|
||||
.addContentUriTrigger(MediaStore.Images.Media.INTERNAL_CONTENT_URI, true)
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
@@ -32,6 +34,7 @@ import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
*
|
||||
* This job must not be started on API < 24.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class ContentObserverWork(
|
||||
appContext: Context,
|
||||
private val params: WorkerParameters,
|
||||
|
||||
@@ -32,7 +32,6 @@ import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
@@ -204,15 +203,12 @@ class FilesSyncWork(
|
||||
val lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter)
|
||||
val remoteFolder: String
|
||||
val useSubfolders: Boolean
|
||||
val subFolderRule: SubFolderRule
|
||||
if (lightVersion) {
|
||||
useSubfolders = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders)
|
||||
remoteFolder = resources.getString(R.string.syncedFolder_remote_folder)
|
||||
subFolderRule = SubFolderRule.YEAR_MONTH
|
||||
} else {
|
||||
useSubfolders = syncedFolder.isSubfolderByDate
|
||||
remoteFolder = syncedFolder.remotePath
|
||||
subFolderRule = syncedFolder.subfolderRule
|
||||
}
|
||||
return FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
@@ -220,8 +216,7 @@ class FilesSyncWork(
|
||||
remoteFolder,
|
||||
syncedFolder.localPath,
|
||||
lastModificationTime,
|
||||
useSubfolders,
|
||||
subFolderRule
|
||||
useSubfolders
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
package com.nextcloud.client.media
|
||||
|
||||
import android.os.AsyncTask
|
||||
import com.owncloud.android.files.StreamMediaFileOperation
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.resources.files.StreamMediaFileRemoteOperation
|
||||
|
||||
internal class LoadUrlTask(
|
||||
private val client: OwnCloudClient,
|
||||
@@ -33,7 +33,7 @@ internal class LoadUrlTask(
|
||||
) : AsyncTask<Void, Void, String>() {
|
||||
|
||||
override fun doInBackground(vararg args: Void): String? {
|
||||
val operation = StreamMediaFileRemoteOperation(fileId)
|
||||
val operation = StreamMediaFileOperation(fileId)
|
||||
val result = operation.execute(client)
|
||||
return when (result.isSuccess) {
|
||||
true -> result.data[0] as String
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.nextcloud.client.migrations
|
||||
|
||||
import android.os.Build
|
||||
import androidx.work.WorkManager
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
@@ -88,8 +89,12 @@ class Migrations @Inject constructor(
|
||||
logger.i(TAG, "${s.description}: cancelling legacy work ${it.id}")
|
||||
workManager.cancelWorkById(it.id)
|
||||
}
|
||||
jobManager.scheduleContentObserverJob()
|
||||
logger.i(TAG, "$s: enabled")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
jobManager.scheduleContentObserverJob()
|
||||
logger.i(TAG, "$s: enabled")
|
||||
} else {
|
||||
logger.i(TAG, "$s: disabled")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,9 +75,6 @@ public interface AppPreferences {
|
||||
boolean isShowHiddenFilesEnabled();
|
||||
void setShowHiddenFilesEnabled(boolean enabled);
|
||||
|
||||
boolean isShowEcosystemApps();
|
||||
void setShowEcosystemApps(boolean enabled);
|
||||
|
||||
/**
|
||||
* Gets the selected file extension position the user selected to do the
|
||||
* last upload of a url file shared from other app.
|
||||
|
||||
@@ -76,7 +76,6 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
private static final String PREF__INSTANT_UPLOADING = "instant_uploading";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
|
||||
private static final String PREF__SHOW_HIDDEN_FILES = "show_hidden_files_pref";
|
||||
private static final String PREF__SHOW_ECOSYSTEM_APPS = "show_ecosystem_apps";
|
||||
private static final String PREF__LEGACY_CLEAN = "legacyClean";
|
||||
private static final String PREF__KEYS_MIGRATION = "keysMigration";
|
||||
private static final String PREF__FIX_STORAGE_PATH = "storagePathFix";
|
||||
@@ -222,16 +221,6 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
preferences.edit().putBoolean(PREF__SHOW_HIDDEN_FILES, enabled).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowEcosystemApps() {
|
||||
return preferences.getBoolean(PREF__SHOW_ECOSYSTEM_APPS, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowEcosystemApps(boolean enabled) {
|
||||
preferences.edit().putBoolean(PREF__SHOW_ECOSYSTEM_APPS, enabled).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUploadUrlFileExtensionUrlSelectedPos() {
|
||||
return preferences.getInt(AUTO_PREF__UPLOAD_FILE_EXTENSION_URL, 0);
|
||||
|
||||
@@ -1,415 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author ZetaTom
|
||||
* Copyright (C) 2023 ZetaTom
|
||||
* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.NominatimClient
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.PreviewImageDetailsFragmentBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.osmdroid.config.Configuration
|
||||
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import org.osmdroid.views.CustomZoomButtonsController
|
||||
import org.osmdroid.views.overlay.ItemizedIconOverlay
|
||||
import org.osmdroid.views.overlay.ItemizedIconOverlay.OnItemGestureListener
|
||||
import org.osmdroid.views.overlay.OverlayItem
|
||||
import java.lang.Long.max
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class ImageDetailFragment : Fragment(), Injectable {
|
||||
private lateinit var binding: PreviewImageDetailsFragmentBinding
|
||||
private lateinit var file: OCFile
|
||||
private lateinit var user: User
|
||||
private lateinit var metadata: ImageMetadata
|
||||
private lateinit var nominatimClient: NominatimClient
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = PreviewImageDetailsFragmentBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.fileDetailsIcon.setImageDrawable(
|
||||
viewThemeUtils.platform.tintDrawable(
|
||||
requireContext(),
|
||||
R.drawable.outline_image_24,
|
||||
ColorRole.ON_BACKGROUND
|
||||
)
|
||||
)
|
||||
|
||||
binding.cameraInformationIcon.setImageDrawable(
|
||||
viewThemeUtils.platform.tintDrawable(
|
||||
requireContext(),
|
||||
R.drawable.outline_camera_24,
|
||||
ColorRole.ON_BACKGROUND
|
||||
)
|
||||
)
|
||||
|
||||
val arguments = arguments ?: throw IllegalStateException("arguments are mandatory")
|
||||
file = arguments.getParcelable(ARG_FILE)!!
|
||||
user = arguments.getParcelable(ARG_USER)!!
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
file = savedInstanceState.getParcelable(ARG_FILE)!!
|
||||
user = savedInstanceState.getParcelable(ARG_USER)!!
|
||||
metadata = savedInstanceState.getParcelable(ARG_METADATA)!!
|
||||
}
|
||||
|
||||
nominatimClient = NominatimClient(
|
||||
getString(R.string.osm_geocoder_url), getString(R.string.osm_geocoder_contact)
|
||||
)
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putParcelable(ARG_FILE, file)
|
||||
outState.putParcelable(ARG_USER, user)
|
||||
outState.putParcelable(ARG_METADATA, metadata)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
gatherMetadata()
|
||||
setupFragment()
|
||||
}
|
||||
|
||||
@SuppressLint("LongMethod")
|
||||
private fun setupFragment() {
|
||||
binding.fileInformationTime.text = metadata.date
|
||||
|
||||
// detailed file information
|
||||
val fileInformation = mutableListOf<String>()
|
||||
if (metadata.length != null && metadata.width != null && metadata.length!! > 0 && metadata.width!! > 0) {
|
||||
try {
|
||||
@Suppress("MagicNumber")
|
||||
val pxlCount = when (val res = metadata.length!! * metadata.width!!.toLong()) {
|
||||
in 0..999999 -> "%.2f".format(res / 1000000f)
|
||||
in 1000000..9999999 -> "%.1f".format(res / 1000000f)
|
||||
else -> (res / 1000000).toString()
|
||||
}
|
||||
|
||||
fileInformation.add(String.format(getString(R.string.image_preview_unit_megapixel), pxlCount))
|
||||
fileInformation.add("${metadata.width!!} × ${metadata.length!!}")
|
||||
} catch (_: NumberFormatException) {
|
||||
}
|
||||
}
|
||||
metadata.fileSize?.let { fileInformation.add(it) }
|
||||
|
||||
if (fileInformation.isNotEmpty()) {
|
||||
binding.fileInformationDetails.text = fileInformation.joinToString(separator = TEXT_SEP)
|
||||
binding.fileInformation.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
setImageTakenConditions()
|
||||
|
||||
// initialise map and address views
|
||||
metadata.location?.let { location ->
|
||||
initMap(location.first, location.second)
|
||||
binding.imageLocation.visibility = View.VISIBLE
|
||||
|
||||
// launch reverse geocoding request
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val geocodingResult = nominatimClient.reverseGeocode(location.first, location.second)
|
||||
if (geocodingResult != null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.imageLocationText.visibility = View.VISIBLE
|
||||
binding.imageLocationText.text = geocodingResult.displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setImageTakenConditions() {
|
||||
// camera make and model
|
||||
val makeModel = if (metadata.make?.let { metadata.model?.contains(it) } == false) {
|
||||
"${metadata.make} ${metadata.model}"
|
||||
} else {
|
||||
metadata.model ?: metadata.make
|
||||
}
|
||||
|
||||
if (metadata.make == null || metadata.model?.contains(metadata.make!!) == true) {
|
||||
binding.imgTCMakeModel.text = metadata.model
|
||||
} else {
|
||||
binding.imgTCMakeModel.text = String.format(
|
||||
getString(R.string.make_model),
|
||||
metadata.make,
|
||||
metadata.model
|
||||
)
|
||||
}
|
||||
|
||||
// image taking conditions
|
||||
val imageTakingConditions = mutableListOf<String>()
|
||||
metadata.aperture?.let {
|
||||
imageTakingConditions.add(String.format(getString(R.string.image_preview_unit_fnumber), it))
|
||||
}
|
||||
metadata.exposure?.let {
|
||||
imageTakingConditions.add(String.format(getString(R.string.image_preview_unit_seconds), it))
|
||||
}
|
||||
metadata.focalLen?.let {
|
||||
imageTakingConditions.add(String.format(getString(R.string.image_preview_unit_millimetres), it))
|
||||
}
|
||||
metadata.iso?.let {
|
||||
imageTakingConditions.add(String.format(getString(R.string.image_preview_unit_iso), it))
|
||||
}
|
||||
|
||||
if (imageTakingConditions.isNotEmpty() && makeModel != null) {
|
||||
binding.imgTCMakeModel.text = makeModel
|
||||
binding.imgTCConditions.text = imageTakingConditions.joinToString(separator = TEXT_SEP)
|
||||
binding.imgTC.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initMap(latitude: Double, longitude: Double, zoom: Double = 13.0) {
|
||||
// required for OpenStreetMap
|
||||
Configuration.getInstance().userAgentValue = MainApp.getUserAgent()
|
||||
|
||||
val location = GeoPoint(latitude, longitude)
|
||||
|
||||
binding.imageLocationMap.apply {
|
||||
setTileSource(TileSourceFactory.MAPNIK)
|
||||
|
||||
// set expected boundaries
|
||||
setScrollableAreaLimitLatitude(SCROLL_LIMIT, -SCROLL_LIMIT, 0)
|
||||
isVerticalMapRepetitionEnabled = false
|
||||
minZoomLevel = 2.0
|
||||
maxZoomLevel = NominatimClient.Companion.ZoomLevel.MAX.int.toDouble()
|
||||
|
||||
// initial location
|
||||
controller.setCenter(location)
|
||||
controller.setZoom(zoom)
|
||||
|
||||
// scale labels to be legible
|
||||
isTilesScaledToDpi = true
|
||||
setZoomRounding(true)
|
||||
|
||||
// hide zoom buttons
|
||||
zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
|
||||
|
||||
// enable multi-touch zoom
|
||||
setMultiTouchControls(true)
|
||||
setOnTouchListener { v, _ ->
|
||||
v.parent.requestDisallowInterceptTouchEvent(true)
|
||||
false
|
||||
}
|
||||
|
||||
val markerOverlay = ItemizedIconOverlay(
|
||||
mutableListOf(OverlayItem("Location", "", location)),
|
||||
imagePinDrawable(context),
|
||||
markerOnGestureListener(latitude, longitude),
|
||||
context
|
||||
)
|
||||
|
||||
overlays.add(markerOverlay)
|
||||
|
||||
onResume()
|
||||
}
|
||||
|
||||
// add copyright notice
|
||||
binding.imageLocationMapCopyright.text = binding.imageLocationMap.tileProvider.tileSource.copyrightNotice
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun gatherMetadata() {
|
||||
val fileSize = DisplayUtils.bytesToHumanReadable(file.fileLength)
|
||||
var timestamp = max(file.modificationTimestamp, file.creationTimestamp)
|
||||
if (file.isDown) {
|
||||
val exif = androidx.exifinterface.media.ExifInterface(file.storagePath)
|
||||
var length = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_IMAGE_LENGTH)?.toInt()
|
||||
var width = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_IMAGE_WIDTH)?.toInt()
|
||||
var exposure = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_SHUTTER_SPEED_VALUE)
|
||||
|
||||
// get timestamp from date string
|
||||
exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_DATETIME)?.let {
|
||||
timestamp = SimpleDateFormat("y:M:d H:m:s", Locale.ROOT).parse(it)?.time ?: timestamp
|
||||
}
|
||||
|
||||
// format exposure string
|
||||
if (exposure == null) {
|
||||
exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_EXPOSURE_TIME)?.let {
|
||||
exposure = "1/" + (1 / it.toDouble()).toInt()
|
||||
}
|
||||
} else if ("/" in exposure!!) {
|
||||
try {
|
||||
exposure!!.split("/").also {
|
||||
exposure = "1/" + 2f.pow(it[0].toFloat() / it[1].toFloat()).roundToInt()
|
||||
}
|
||||
} catch (_: NumberFormatException) {
|
||||
}
|
||||
}
|
||||
|
||||
// determine size if not contained in exif data
|
||||
if (width == null || length == null || width <= 0 || length <= 0) {
|
||||
val res = BitmapUtils.getImageResolution(file.storagePath)
|
||||
width = res[0]
|
||||
length = res[1]
|
||||
}
|
||||
|
||||
metadata = ImageMetadata(
|
||||
fileSize = fileSize,
|
||||
length = length,
|
||||
width = width,
|
||||
exposure = exposure,
|
||||
date = formatDate(timestamp),
|
||||
location = exif.latLong?.let { Pair(it[0], it[1]) },
|
||||
aperture = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_F_NUMBER),
|
||||
focalLen = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_FOCAL_LENGTH_IN_35MM_FILM),
|
||||
make = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_MAKE),
|
||||
model = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_MODEL),
|
||||
iso = exif.getAttribute(androidx.exifinterface.media.ExifInterface.TAG_ISO_SPEED) ?: exif.getAttribute(
|
||||
androidx.exifinterface.media.ExifInterface.TAG_PHOTOGRAPHIC_SENSITIVITY
|
||||
)
|
||||
)
|
||||
} else {
|
||||
// get metadata from server
|
||||
val location = if (file.geoLocation == null) {
|
||||
null
|
||||
} else {
|
||||
Pair(file.geoLocation!!.latitude, file.geoLocation!!.longitude)
|
||||
}
|
||||
metadata = ImageMetadata(
|
||||
fileSize = fileSize,
|
||||
date = formatDate(timestamp),
|
||||
location = location,
|
||||
width = file.imageDimension?.width?.toInt(),
|
||||
length = file.imageDimension?.height?.toInt()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun formatDate(timestamp: Long): String {
|
||||
return buildString {
|
||||
append(SimpleDateFormat("EEEE").format(timestamp))
|
||||
append(TEXT_SEP)
|
||||
append(DateFormat.getDateInstance(DateFormat.MEDIUM).format(timestamp))
|
||||
append(TEXT_SEP)
|
||||
append(DateFormat.getTimeInstance(DateFormat.SHORT).format(timestamp))
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun imagePinDrawable(context: Context): LayerDrawable {
|
||||
val bitmap =
|
||||
ThumbnailsCacheManager.getBitmapFromDiskCache(ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.remoteId)
|
||||
val foreground = BitmapUtils.bitmapToCircularBitmapDrawable(resources, bitmap)
|
||||
val background = ContextCompat.getDrawable(context, R.drawable.photo_pin)
|
||||
|
||||
val layerDrawable = if (foreground != null) {
|
||||
LayerDrawable(arrayOf(background, foreground))
|
||||
} else {
|
||||
val d = ContextCompat.getDrawable(context, R.drawable.file_image)
|
||||
LayerDrawable(arrayOf(background, d))
|
||||
}
|
||||
|
||||
val dp = DisplayUtils.convertDpToPixel(2f, context)
|
||||
layerDrawable.apply {
|
||||
setLayerSize(1, 38 * dp, 38 * dp)
|
||||
setLayerSize(0, 40 * dp, 47 * dp)
|
||||
setLayerInsetTop(1, dp)
|
||||
setLayerGravity(1, Gravity.CENTER_HORIZONTAL)
|
||||
}
|
||||
return layerDrawable
|
||||
}
|
||||
|
||||
/**
|
||||
* OnItemGestureListener for marker in MapView.
|
||||
*/
|
||||
private fun markerOnGestureListener(latitude: Double, longitude: Double) =
|
||||
object : OnItemGestureListener<OverlayItem> {
|
||||
override fun onItemSingleTapUp(index: Int, item: OverlayItem): Boolean {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=$latitude,$longitude"))
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, activity, R.string.no_map_app_availble)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: OverlayItem): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
private data class ImageMetadata(
|
||||
val fileSize: String? = null,
|
||||
val date: String? = null,
|
||||
val length: Int? = null,
|
||||
val width: Int? = null,
|
||||
val exposure: String? = null,
|
||||
val aperture: String? = null,
|
||||
val focalLen: String? = null,
|
||||
val iso: String? = null,
|
||||
val make: String? = null,
|
||||
val model: String? = null,
|
||||
val location: Pair<Double, Double>? = null
|
||||
) : Parcelable
|
||||
|
||||
companion object {
|
||||
private const val ARG_FILE = "FILE"
|
||||
private const val ARG_USER = "USER"
|
||||
private const val ARG_METADATA = "METADATA"
|
||||
private const val TEXT_SEP = " • "
|
||||
private const val SCROLL_LIMIT = 80.0
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(file: OCFile, user: User): ImageDetailFragment {
|
||||
return ImageDetailFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(ARG_FILE, file)
|
||||
putParcelable(ARG_USER, user)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
@@ -324,13 +325,14 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
Log_OC.d("Debug", "start logging");
|
||||
}
|
||||
|
||||
try {
|
||||
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
|
||||
m.invoke(null);
|
||||
} catch (Exception e) {
|
||||
Log_OC.d("Debug", "Failed to disable uri exposure");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
try {
|
||||
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
|
||||
m.invoke(null);
|
||||
} catch (Exception e) {
|
||||
Log_OC.d("Debug", "Failed to disable uri exposure");
|
||||
}
|
||||
}
|
||||
|
||||
initSyncOperations(preferences,
|
||||
uploadsStorageManager,
|
||||
accountManager,
|
||||
@@ -611,6 +613,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private static void createChannel(NotificationManager notificationManager,
|
||||
String channelId, int channelName,
|
||||
int channelDescription, Context context) {
|
||||
|
||||
@@ -85,7 +85,6 @@ import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.nextcloud.client.onboarding.OnboardingService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
@@ -912,12 +911,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
checkBasicAuthorization(webViewUser, webViewPassword);
|
||||
} else {
|
||||
new Thread(() -> {
|
||||
NextcloudClient client = OwnCloudClientFactory.createNextcloudClient(Uri.parse(mServerInfo.mBaseUrl),
|
||||
"",
|
||||
"",
|
||||
this,
|
||||
true);
|
||||
RemoteOperationResult<OCCapability> remoteOperationResult = new GetCapabilitiesRemoteOperation().execute(client);
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mServerInfo.mBaseUrl),
|
||||
this,
|
||||
true);
|
||||
RemoteOperationResult remoteOperationResult = new GetCapabilitiesRemoteOperation().execute(client);
|
||||
|
||||
if (remoteOperationResult.isSuccess() &&
|
||||
remoteOperationResult.getData() != null &&
|
||||
@@ -1226,8 +1223,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
try {
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManager(user.get(), getContentResolver());
|
||||
NextcloudClient nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user.get(), this);
|
||||
new GetCapabilitiesOperation(storageManager).execute(nextcloudClient);
|
||||
new GetCapabilitiesOperation(storageManager).execute(MainApp.getAppContext());
|
||||
handler.post(this::endSuccess);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Failed to fetch capabilities", e);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DeepLinkLoginActivity extends AuthenticatorActivity implements Inje
|
||||
LoginUrlInfo loginUrlInfo = parseLoginDataUrl(prefix, data.toString());
|
||||
|
||||
TextView loginText = findViewById(R.id.loginInfo);
|
||||
loginText.setText(String.format(getString(R.string.direct_login_text), loginUrlInfo.username,
|
||||
loginText.setText(String.format("Login with %1$s to %2$s", loginUrlInfo.username,
|
||||
loginUrlInfo.serverAddress));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(this, R.string.direct_login_failed, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -51,8 +51,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType;
|
||||
import com.owncloud.android.lib.resources.files.model.GeoLocation;
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
@@ -442,6 +440,7 @@ public class FileDataStorageManager {
|
||||
*/
|
||||
private ContentValues createContentValuesBase(OCFile fileOrFolder) {
|
||||
final ContentValues cv = new ContentValues();
|
||||
final Gson gson = new Gson();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, fileOrFolder.getModificationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, fileOrFolder.getModificationTimestampAtLastSyncForData());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, fileOrFolder.getParentId());
|
||||
@@ -508,8 +507,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TIMEOUT, file.getLockTimeout());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TOKEN, file.getLockToken());
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_METADATA_SIZE, gson.toJson(file.getImageDimension()));
|
||||
cv.put(ProviderTableMeta.FILE_METADATA_GPS, gson.toJson(file.getGeoLocation()));
|
||||
cv.put(ProviderTableMeta.FILE_METADATA_SIZE, new Gson().toJson(file.getImageDimension()));
|
||||
|
||||
return cv;
|
||||
}
|
||||
@@ -980,16 +978,6 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
String metadataGPS = fileEntity.getMetadataGPS();
|
||||
// Surprisingly JSON deserialization causes significant overhead.
|
||||
// Avoid it in common, trivial cases (null/empty).
|
||||
if (!(metadataGPS == null || metadataGPS.isEmpty() || JSON_NULL_STRING.equals(metadataGPS))) {
|
||||
GeoLocation geoLocation = gson.fromJson(metadataGPS, GeoLocation.class);
|
||||
if (geoLocation != null) {
|
||||
ocFile.setGeoLocation(geoLocation);
|
||||
}
|
||||
}
|
||||
|
||||
return ocFile;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Dean Birch
|
||||
* Copyright (C) 2023 Dean Birch
|
||||
* Copyright (C) 2023 Nextcloud GmbH
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2022 Tobias Kaminsky
|
||||
* Copyright (C) 2022 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
|
||||
@@ -18,9 +19,6 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
package com.nextcloud.client.preferences
|
||||
|
||||
enum class SubFolderRule {
|
||||
YEAR_MONTH, YEAR, YEAR_MONTH_DAY
|
||||
}
|
||||
data class ImageDimension(var width: Float = -1f, var height: Float = -1f)
|
||||
@@ -34,8 +34,6 @@ import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType;
|
||||
import com.owncloud.android.lib.resources.files.model.GeoLocation;
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
@@ -117,13 +115,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
private String lockToken;
|
||||
@Nullable
|
||||
private ImageDimension imageDimension;
|
||||
@Nullable
|
||||
private GeoLocation geolocation;
|
||||
private List<String> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call to
|
||||
* {@link #getStorageUri()}
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call to {@link
|
||||
* #getStorageUri()}
|
||||
*/
|
||||
private Uri localUri;
|
||||
|
||||
@@ -979,15 +975,6 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return imageDimension;
|
||||
}
|
||||
|
||||
public void setGeoLocation(@Nullable GeoLocation geolocation) {
|
||||
this.geolocation = geolocation;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GeoLocation getGeoLocation() {
|
||||
return geolocation;
|
||||
}
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import com.nextcloud.client.preferences.SubFolderRule;
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -34,8 +33,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
|
||||
private static final long serialVersionUID = -793476118299906429L;
|
||||
|
||||
|
||||
|
||||
private long id;
|
||||
private String localPath;
|
||||
private String remotePath;
|
||||
@@ -50,7 +47,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
private long enabledTimestampMs;
|
||||
private MediaFolderType type;
|
||||
private boolean hidden;
|
||||
private SubFolderRule subfolderRule;
|
||||
|
||||
/**
|
||||
* constructor for new, to be persisted entity.
|
||||
@@ -81,8 +77,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
MediaFolderType type,
|
||||
boolean hidden,
|
||||
SubFolderRule subFolderRule) {
|
||||
boolean hidden) {
|
||||
this(UNPERSISTED_ID,
|
||||
localPath,
|
||||
remotePath,
|
||||
@@ -96,8 +91,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
enabled,
|
||||
timestampMs,
|
||||
type,
|
||||
hidden,
|
||||
subFolderRule);
|
||||
hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,8 +112,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
MediaFolderType type,
|
||||
boolean hidden,
|
||||
SubFolderRule subFolderRule) {
|
||||
boolean hidden) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
@@ -133,7 +126,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
this.setEnabled(enabled, timestampMs);
|
||||
this.type = type;
|
||||
this.hidden = hidden;
|
||||
this.subfolderRule = subFolderRule;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,8 +204,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
public SubFolderRule getSubfolderRule() { return this.subfolderRule; }
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -261,6 +251,4 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public void setSubFolderRule(SubFolderRule subFolderRule) { this.subfolderRule = subFolderRule; }
|
||||
}
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import com.nextcloud.client.preferences.SubFolderRule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -34,7 +32,6 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
private String folderName;
|
||||
private long numberOfFiles;
|
||||
|
||||
|
||||
/**
|
||||
* constructor for the display item specialization for a synced folder object.
|
||||
*
|
||||
@@ -53,7 +50,6 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
* @param numberOfFiles the UI info for number of files within the folder
|
||||
* @param type the type of the folder
|
||||
* @param hidden hide item flag
|
||||
* @param subFolderRule whether to filter subFolder by year/month/day
|
||||
*/
|
||||
public SyncedFolderDisplayItem(long id,
|
||||
String localPath,
|
||||
@@ -71,8 +67,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
String folderName,
|
||||
long numberOfFiles,
|
||||
MediaFolderType type,
|
||||
boolean hidden,
|
||||
SubFolderRule subFolderRule) {
|
||||
boolean hidden) {
|
||||
super(id,
|
||||
localPath,
|
||||
remotePath,
|
||||
@@ -86,8 +81,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
enabled,
|
||||
timestampMs,
|
||||
type,
|
||||
hidden,
|
||||
subFolderRule);
|
||||
hidden);
|
||||
this.filePaths = filePaths;
|
||||
this.folderName = folderName;
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
@@ -107,8 +101,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
long timestampMs,
|
||||
String folderName,
|
||||
MediaFolderType type,
|
||||
boolean hidden,
|
||||
SubFolderRule subFolderRule) {
|
||||
boolean hidden) {
|
||||
super(id,
|
||||
localPath,
|
||||
remotePath,
|
||||
@@ -122,8 +115,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
enabled,
|
||||
timestampMs,
|
||||
type,
|
||||
hidden,
|
||||
subFolderRule);
|
||||
hidden);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.SubFolderRule;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
@@ -362,9 +361,6 @@ public class SyncedFolderProvider extends Observable {
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
|
||||
boolean hidden = cursor.getInt(cursor.getColumnIndexOrThrow(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;
|
||||
SubFolderRule subFolderRule = SubFolderRule.values()[cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_RULE))];
|
||||
|
||||
|
||||
syncedFolder = new SyncedFolder(id,
|
||||
localPath,
|
||||
@@ -379,8 +375,7 @@ public class SyncedFolderProvider extends Observable {
|
||||
enabled,
|
||||
enabledTimestampMs,
|
||||
type,
|
||||
hidden,
|
||||
subFolderRule);
|
||||
hidden);
|
||||
}
|
||||
return syncedFolder;
|
||||
}
|
||||
@@ -408,7 +403,6 @@ public class SyncedFolderProvider extends Observable {
|
||||
syncedFolder.getNameCollisionPolicyInt());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_RULE, syncedFolder.getSubfolderRule().ordinal());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/**
|
||||
* Template for creating a file from it via RichDocuments app
|
||||
*/
|
||||
@Parcelize
|
||||
data class Template(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val thumbnailLink: String,
|
||||
val type: Type,
|
||||
val extension: String
|
||||
) : Parcelable {
|
||||
enum class Type {
|
||||
DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN;
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun parse(name: String) = try {
|
||||
valueOf(name.uppercase())
|
||||
} catch (_: IllegalArgumentException) {
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,6 @@ import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
@@ -205,10 +204,7 @@ public final class ThumbnailsCacheManager {
|
||||
thumbnail = BitmapUtils.rotateImage(thumbnail,path);
|
||||
|
||||
// Add thumbnail to cache
|
||||
// do not overwrite any pre-existing image
|
||||
if (!mThumbnailCache.containsKey(imageKey)) {
|
||||
addBitmapToCache(imageKey, thumbnail);
|
||||
}
|
||||
addBitmapToCache(imageKey, thumbnail);
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 73;
|
||||
public static final int DB_VERSION = 71;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
@@ -117,7 +117,6 @@ public class ProviderMeta {
|
||||
public static final String FILE_SHAREES = "sharees";
|
||||
public static final String FILE_RICH_WORKSPACE = "rich_workspace";
|
||||
public static final String FILE_METADATA_SIZE = "metadata_size";
|
||||
public static final String FILE_METADATA_GPS = "metadata_gps";
|
||||
public static final String FILE_LOCKED = "locked";
|
||||
public static final String FILE_LOCK_TYPE = "lock_type";
|
||||
public static final String FILE_LOCK_OWNER = "lock_owner";
|
||||
@@ -129,53 +128,52 @@ public class ProviderMeta {
|
||||
public static final String FILE_TAGS = "tags";
|
||||
|
||||
public static final List<String> FILE_ALL_COLUMNS = Collections.unmodifiableList(Arrays.asList(
|
||||
_ID,
|
||||
FILE_PARENT,
|
||||
FILE_NAME,
|
||||
FILE_ENCRYPTED_NAME,
|
||||
FILE_CREATION,
|
||||
FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
FILE_CONTENT_LENGTH,
|
||||
FILE_CONTENT_TYPE,
|
||||
FILE_STORAGE_PATH,
|
||||
FILE_PATH,
|
||||
FILE_PATH_DECRYPTED,
|
||||
FILE_ACCOUNT_OWNER,
|
||||
FILE_LAST_SYNC_DATE,
|
||||
FILE_LAST_SYNC_DATE_FOR_DATA,
|
||||
FILE_KEEP_IN_SYNC,
|
||||
FILE_ETAG,
|
||||
FILE_ETAG_ON_SERVER,
|
||||
FILE_SHARED_VIA_LINK,
|
||||
FILE_SHARED_WITH_SHAREE,
|
||||
FILE_PERMISSIONS,
|
||||
FILE_REMOTE_ID,
|
||||
FILE_LOCAL_ID,
|
||||
FILE_UPDATE_THUMBNAIL,
|
||||
FILE_IS_DOWNLOADING,
|
||||
FILE_ETAG_IN_CONFLICT,
|
||||
FILE_FAVORITE,
|
||||
FILE_IS_ENCRYPTED,
|
||||
FILE_MOUNT_TYPE,
|
||||
FILE_HAS_PREVIEW,
|
||||
FILE_UNREAD_COMMENTS_COUNT,
|
||||
FILE_OWNER_ID,
|
||||
FILE_OWNER_DISPLAY_NAME,
|
||||
FILE_NOTE,
|
||||
FILE_SHAREES,
|
||||
FILE_RICH_WORKSPACE,
|
||||
FILE_LOCKED,
|
||||
FILE_LOCK_TYPE,
|
||||
FILE_LOCK_OWNER,
|
||||
FILE_LOCK_OWNER_DISPLAY_NAME,
|
||||
FILE_LOCK_OWNER_EDITOR,
|
||||
FILE_LOCK_TIMESTAMP,
|
||||
FILE_LOCK_TIMEOUT,
|
||||
FILE_LOCK_TOKEN,
|
||||
FILE_METADATA_SIZE,
|
||||
FILE_TAGS,
|
||||
FILE_METADATA_GPS));
|
||||
_ID,
|
||||
FILE_PARENT,
|
||||
FILE_NAME,
|
||||
FILE_ENCRYPTED_NAME,
|
||||
FILE_CREATION,
|
||||
FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
FILE_CONTENT_LENGTH,
|
||||
FILE_CONTENT_TYPE,
|
||||
FILE_STORAGE_PATH,
|
||||
FILE_PATH,
|
||||
FILE_PATH_DECRYPTED,
|
||||
FILE_ACCOUNT_OWNER,
|
||||
FILE_LAST_SYNC_DATE,
|
||||
FILE_LAST_SYNC_DATE_FOR_DATA,
|
||||
FILE_KEEP_IN_SYNC,
|
||||
FILE_ETAG,
|
||||
FILE_ETAG_ON_SERVER,
|
||||
FILE_SHARED_VIA_LINK,
|
||||
FILE_SHARED_WITH_SHAREE,
|
||||
FILE_PERMISSIONS,
|
||||
FILE_REMOTE_ID,
|
||||
FILE_LOCAL_ID,
|
||||
FILE_UPDATE_THUMBNAIL,
|
||||
FILE_IS_DOWNLOADING,
|
||||
FILE_ETAG_IN_CONFLICT,
|
||||
FILE_FAVORITE,
|
||||
FILE_IS_ENCRYPTED,
|
||||
FILE_MOUNT_TYPE,
|
||||
FILE_HAS_PREVIEW,
|
||||
FILE_UNREAD_COMMENTS_COUNT,
|
||||
FILE_OWNER_ID,
|
||||
FILE_OWNER_DISPLAY_NAME,
|
||||
FILE_NOTE,
|
||||
FILE_SHAREES,
|
||||
FILE_RICH_WORKSPACE,
|
||||
FILE_LOCKED,
|
||||
FILE_LOCK_TYPE,
|
||||
FILE_LOCK_OWNER,
|
||||
FILE_LOCK_OWNER_DISPLAY_NAME,
|
||||
FILE_LOCK_OWNER_EDITOR,
|
||||
FILE_LOCK_TIMESTAMP,
|
||||
FILE_LOCK_TIMEOUT,
|
||||
FILE_LOCK_TOKEN,
|
||||
FILE_METADATA_SIZE,
|
||||
FILE_TAGS));
|
||||
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
|
||||
|
||||
// Columns of ocshares table
|
||||
@@ -292,7 +290,6 @@ public class ProviderMeta {
|
||||
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
|
||||
public static final String SYNCED_FOLDER_NAME_COLLISION_POLICY = "name_collision_policy";
|
||||
public static final String SYNCED_FOLDER_HIDDEN = "hidden";
|
||||
public static final String SYNCED_FOLDER_SUBFOLDER_RULE = "sub_folder_rule";
|
||||
|
||||
// Columns of external links table
|
||||
public static final String EXTERNAL_LINKS_ICON_URL = "icon_url";
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.Utf8PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateFileFromTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = CreateFileFromTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String NEW_FROM_TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/new";
|
||||
|
||||
private String path;
|
||||
private long templateId;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public CreateFileFromTemplateOperation(String path, long templateId) {
|
||||
this.path = path;
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
Utf8PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
postMethod = new Utf8PostMethod(client.getBaseUri() + NEW_FROM_TEMPLATE_URL + JSON_FORMAT);
|
||||
postMethod.setParameter("path", path);
|
||||
postMethod.setParameter("template", String.valueOf(templateId));
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString("url");
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
templateArray.add(url);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Create file from template " + templateId + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files;
|
||||
|
||||
import com.owncloud.android.datamodel.Template;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FetchTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = FetchTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/";
|
||||
|
||||
private ChooseRichDocumentsTemplateDialogFragment.Type type;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public FetchTemplateOperation(ChooseRichDocumentsTemplateDialogFragment.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
GetMethod getMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
getMethod = new GetMethod(client.getBaseUri() + TEMPLATE_URL + type.toString().toLowerCase(Locale.ENGLISH) +
|
||||
JSON_FORMAT);
|
||||
|
||||
// remote request
|
||||
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(getMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = getMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
JSONArray templates = respJSON.getJSONObject(NODE_OCS).getJSONArray(NODE_DATA);
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < templates.length(); i++) {
|
||||
JSONObject templateObject = templates.getJSONObject(i);
|
||||
|
||||
templateArray.add(new Template(templateObject.getLong("id"),
|
||||
templateObject.getString("name"),
|
||||
templateObject.optString("preview"),
|
||||
Template.Type.parse(templateObject.getString("type")
|
||||
.toUpperCase(Locale.ROOT)),
|
||||
templateObject.getString("extension")));
|
||||
}
|
||||
|
||||
result = new RemoteOperationResult(true, getMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, getMethod);
|
||||
client.exhaustResponse(getMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get templates for typ " + type + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (getMethod != null) {
|
||||
getMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.Utf8PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StreamMediaFileOperation extends RemoteOperation {
|
||||
private static final String TAG = StreamMediaFileOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String STREAM_MEDIA_URL = "/ocs/v2.php/apps/dav/api/v1/direct";
|
||||
|
||||
private final long fileID;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String NODE_URL = "url";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public StreamMediaFileOperation(long fileID) {
|
||||
this.fileID = fileID;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
Utf8PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
postMethod = new Utf8PostMethod(client.getBaseUri() + STREAM_MEDIA_URL + JSON_FORMAT);
|
||||
postMethod.setParameter("fileId", String.valueOf(fileID));
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString(NODE_URL);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
ArrayList<Object> urlArray = new ArrayList<>();
|
||||
urlArray.add(url);
|
||||
result.setData(urlArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get stream url for file with id " + fileID + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
@@ -51,7 +52,8 @@ public class CheckCurrentCredentialsOperation extends SyncOperation {
|
||||
"Account to validate is not the account connected to!")
|
||||
);
|
||||
} else {
|
||||
result = new ExistenceCheckRemoteOperation(OCFile.ROOT_PATH, false).execute(client);
|
||||
RemoteOperation check = new ExistenceCheckRemoteOperation(OCFile.ROOT_PATH, false);
|
||||
result = check.execute(client);
|
||||
ArrayList<Object> data = new ArrayList<>();
|
||||
data.add(user.toPlatformAccount());
|
||||
result.setData(data);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
|
||||
|
||||
/**
|
||||
* Comment file
|
||||
*/
|
||||
public class CommentFileOperation extends RemoteOperation {
|
||||
|
||||
private final String message;
|
||||
private final long fileId;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message Comment to store
|
||||
*/
|
||||
public CommentFileOperation(String message, long fileId) {
|
||||
this.message = message;
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the operation.
|
||||
*
|
||||
* @param client Client object to communicate with the remote ownCloud server.
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId).execute(client);
|
||||
|
||||
if (!result.isSuccess()) {
|
||||
Log_OC.e(this, "File with Id " + fileId + " could not be commented");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
|
||||
@@ -46,7 +46,7 @@ import java.util.Locale;
|
||||
* #onRemoteOperationFinish(RemoteOperation, RemoteOperationResult)} returns in
|
||||
* {@link RemoteOperationResult#getData()} a value of {@link AuthenticationMethod}.
|
||||
*/
|
||||
public class DetectAuthenticationMethodOperation extends LegacyRemoteOperation {
|
||||
public class DetectAuthenticationMethodOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = DetectAuthenticationMethodOperation.class.getSimpleName();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class DetectAuthenticationMethodOperation extends LegacyRemoteOperation {
|
||||
RemoteOperationResult result = null;
|
||||
AuthenticationMethod authMethod = AuthenticationMethod.UNKNOWN;
|
||||
|
||||
LegacyRemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
|
||||
RemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
|
||||
client.clearCredentials();
|
||||
client.setFollowRedirects(false);
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.OperationCancelledException;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.DownloadFileRemoteOperation;
|
||||
@@ -41,7 +41,6 @@ import com.owncloud.android.utils.FileExportUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -50,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
/**
|
||||
* Remote DownloadOperation performing the download of a file to an ownCloud server
|
||||
*/
|
||||
public class DownloadFileOperation extends LegacyRemoteOperation {
|
||||
public class DownloadFileOperation extends RemoteOperation {
|
||||
private static final String TAG = DownloadFileOperation.class.getSimpleName();
|
||||
|
||||
private User user;
|
||||
@@ -213,11 +212,18 @@ public class DownloadFileOperation extends LegacyRemoteOperation {
|
||||
.get(file.getEncryptedFileName()).getAuthenticationTag());
|
||||
|
||||
try {
|
||||
byte[] decryptedBytes = EncryptionUtils.decryptFile(tmpFile, key, iv, authenticationTag);
|
||||
File decryptedFile = new File(getTmpPath() + "_dec");
|
||||
boolean success = EncryptionUtils.decryptFile(tmpFile, decryptedFile, key, iv, authenticationTag);
|
||||
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tmpFile)) {
|
||||
fileOutputStream.write(decryptedBytes);
|
||||
if (!success) {
|
||||
return new RemoteOperationResult(new IllegalStateException("Decryption went wrong!"));
|
||||
}
|
||||
|
||||
decryptedFile.renameTo(tmpFile);
|
||||
if (decryptedFile.exists()) {
|
||||
decryptedFile.delete();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return new RemoteOperationResult(e);
|
||||
}
|
||||
|
||||
@@ -19,28 +19,25 @@
|
||||
*/
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.common.NextcloudSyncOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Get and save capabilities from the server
|
||||
*/
|
||||
public class GetCapabilitiesOperation extends NextcloudSyncOperation<OCCapability> {
|
||||
public class GetCapabilitiesOperation extends SyncOperation {
|
||||
|
||||
public GetCapabilitiesOperation(FileDataStorageManager storageManager) {
|
||||
super(storageManager);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RemoteOperationResult<OCCapability> run(@NonNull NextcloudClient client) {
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
final FileDataStorageManager storageManager = getStorageManager();
|
||||
|
||||
OCCapability currentCapability = null;
|
||||
@@ -48,7 +45,7 @@ public class GetCapabilitiesOperation extends NextcloudSyncOperation<OCCapabilit
|
||||
currentCapability = storageManager.getCapability(storageManager.getUser().getAccountName());
|
||||
}
|
||||
|
||||
RemoteOperationResult<OCCapability> result = new GetCapabilitiesRemoteOperation(currentCapability).execute(client);
|
||||
RemoteOperationResult result = new GetCapabilitiesRemoteOperation(currentCapability).execute(client);
|
||||
|
||||
if (result.isSuccess()
|
||||
&& result.getData() != null && result.getData().size() > 0) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.Context;
|
||||
|
||||
import com.owncloud.android.authentication.AuthenticatorUrlUtils;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
@@ -44,7 +43,7 @@ import java.util.Locale;
|
||||
* and finds out what authentication method is needed to access files in it.
|
||||
*/
|
||||
|
||||
public class GetServerInfoOperation extends LegacyRemoteOperation {
|
||||
public class GetServerInfoOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = GetServerInfoOperation.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -29,16 +29,14 @@ import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;
|
||||
import com.owncloud.android.operations.common.NextcloudSyncOperation;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
/**
|
||||
* Get and save user's profile from the server.
|
||||
* <p>
|
||||
* Currently only retrieves the display name.
|
||||
*/
|
||||
public class GetUserProfileOperation extends NextcloudSyncOperation<UserInfo> {
|
||||
public class GetUserProfileOperation extends SyncOperation {
|
||||
|
||||
public GetUserProfileOperation(FileDataStorageManager storageManager) {
|
||||
super(storageManager);
|
||||
@@ -55,9 +53,8 @@ public class GetUserProfileOperation extends NextcloudSyncOperation<UserInfo> {
|
||||
* {@link String} with the display name retrieved from the server.
|
||||
* Call {@link RemoteOperationResult#getData()}.get(0) to get it.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public RemoteOperationResult<UserInfo> run(@NonNull NextcloudClient client) {
|
||||
public RemoteOperationResult<UserInfo> run(NextcloudClient client) {
|
||||
|
||||
// get display name
|
||||
RemoteOperationResult<UserInfo> result = new GetUserInfoRemoteOperation().execute(client);
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -47,7 +47,6 @@ import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.GetSharesForFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.users.GetPredefinedStatusesRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus;
|
||||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||
@@ -80,7 +79,7 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
|
||||
* Does NOT enter in the child folders to synchronize their contents also.
|
||||
*/
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
public class RefreshFolderOperation extends LegacyRemoteOperation {
|
||||
public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = RefreshFolderOperation.class.getSimpleName();
|
||||
|
||||
@@ -302,7 +301,7 @@ public class RefreshFolderOperation extends LegacyRemoteOperation {
|
||||
String oldDirectEditingEtag = arbitraryDataProvider.getValue(user,
|
||||
ArbitraryDataProvider.DIRECT_EDITING_ETAG);
|
||||
|
||||
RemoteOperationResult<OCCapability> result = new GetCapabilitiesOperation(mStorageManager).execute(clientNew);
|
||||
RemoteOperationResult result = new GetCapabilitiesOperation(mStorageManager).execute(mContext);
|
||||
if (result.isSuccess()) {
|
||||
String newDirectEditingEtag = mStorageManager.getCapability(user.getAccountName()).getDirectEditingEtag();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
|
||||
@@ -92,7 +92,7 @@ public class RemoveFileOperation extends SyncOperation {
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = null;
|
||||
LegacyRemoteOperation operation;
|
||||
RemoteOperation operation;
|
||||
|
||||
if (MimeTypeUtil.isImage(fileToRemove.getMimeType())) {
|
||||
// store resized image
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
||||
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
|
||||
import com.owncloud.android.datamodel.EncryptedFolderMetadata;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.GetMetadataRemoteOperation;
|
||||
@@ -57,7 +57,7 @@ import javax.crypto.NoSuchPaddingException;
|
||||
/**
|
||||
* Remote operation performing the removal of a remote encrypted file or folder
|
||||
*/
|
||||
public class RemoveRemoteEncryptedFileOperation extends LegacyRemoteOperation {
|
||||
public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
private static final String TAG = RemoveRemoteEncryptedFileOperation.class.getSimpleName();
|
||||
|
||||
private static final int REMOVE_READ_TIMEOUT = 30000;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.Utf8PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Create asset for RichDocuments app from file, which is already stored on Nextcloud server
|
||||
*/
|
||||
|
||||
public class RichDocumentsCreateAssetOperation extends RemoteOperation {
|
||||
private static final String TAG = RichDocumentsCreateAssetOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String ASSET_URL = "/index.php/apps/richdocuments/assets";
|
||||
|
||||
private static final String NODE_URL = "url";
|
||||
private static final String PARAMETER_PATH = "path";
|
||||
private static final String PARAMETER_FORMAT = "format";
|
||||
private static final String PARAMETER_FORMAT_VALUE = "json";
|
||||
|
||||
private String path;
|
||||
|
||||
public RichDocumentsCreateAssetOperation(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
Utf8PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
postMethod = new Utf8PostMethod(client.getBaseUri() + ASSET_URL);
|
||||
postMethod.setParameter(PARAMETER_PATH, path);
|
||||
postMethod.setParameter(PARAMETER_FORMAT, PARAMETER_FORMAT_VALUE);
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getString(NODE_URL);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setSingleData(url);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Create asset for richdocuments with path " + path + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.NextcloudServer;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.Utf8PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Edit a file with Richdocuments. Returns URL which can be shown in WebView.
|
||||
*/
|
||||
public class RichDocumentsUrlOperation extends RemoteOperation {
|
||||
|
||||
/**
|
||||
* TODO move to library
|
||||
*/
|
||||
|
||||
private static final String TAG = RichDocumentsUrlOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String DOCUMENT_URL = "/ocs/v2.php/apps/richdocuments/api/v1/document";
|
||||
private static final String FILE_ID = "fileId";
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String NODE_URL = "url";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
private final long fileId;
|
||||
|
||||
public RichDocumentsUrlOperation(long fileID) {
|
||||
this.fileId = fileID;
|
||||
}
|
||||
|
||||
@NextcloudServer(max = 18)
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
Utf8PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
|
||||
postMethod.setParameter(FILE_ID, String.valueOf(fileId));
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString(NODE_URL);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setSingleData(url);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get rich document url for file with id " + fileId + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -23,14 +23,13 @@ package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Updates a note of a private share.
|
||||
@@ -48,20 +47,21 @@ public class UpdateNoteForShareOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult<List<OCShare>> run(OwnCloudClient client) {
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
|
||||
OCShare share = getStorageManager().getShareById(shareId);
|
||||
|
||||
if (share == null) {
|
||||
return new RemoteOperationResult<>(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
|
||||
UpdateShareRemoteOperation updateOperation = new UpdateShareRemoteOperation(share.getRemoteId());
|
||||
updateOperation.setNote(note);
|
||||
RemoteOperationResult<List<OCShare>> result = updateOperation.execute(client);
|
||||
RemoteOperationResult result = updateOperation.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
result = new GetShareRemoteOperation(share.getRemoteId()).execute(client);
|
||||
RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
|
||||
result = getShareOp.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
getStorageManager().saveShare((OCShare) result.getData().get(0));
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -41,7 +42,7 @@ import org.json.JSONObject;
|
||||
/**
|
||||
* Remote operation that checks the version of an ownCloud server and stores it locally
|
||||
*/
|
||||
public class UpdateOCVersionOperation extends LegacyRemoteOperation {
|
||||
public class UpdateOCVersionOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = UpdateOCVersionOperation.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
@@ -107,7 +108,8 @@ public class UpdateShareInfoOperation extends SyncOperation {
|
||||
RemoteOperationResult result = updateOp.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
result = new GetShareRemoteOperation(share.getRemoteId()).execute(client);
|
||||
RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
|
||||
result = getShareOp.execute(client);
|
||||
|
||||
//only update the share in storage if shareId is available
|
||||
//this will be triggered by editing existing share
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
|
||||
@@ -78,7 +79,8 @@ public class UpdateSharePermissionsOperation extends SyncOperation {
|
||||
RemoteOperationResult result = updateOp.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
result = new GetShareRemoteOperation(share.getRemoteId()).execute(client);
|
||||
RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
|
||||
result = getShareOp.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
share = (OCShare) result.getData().get(0);
|
||||
// TODO check permissions are being saved
|
||||
|
||||
@@ -61,7 +61,8 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
|
||||
if (result.isSuccess()) {
|
||||
// Retrieve updated share / save directly with password? -> no; the password is not to be saved
|
||||
result = new GetShareRemoteOperation(publicShare.getRemoteId()).execute(client);
|
||||
RemoteOperation getShareOp = new GetShareRemoteOperation(publicShare.getRemoteId());
|
||||
result = getShareOp.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
OCShare share = (OCShare) result.getData().get(0);
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.owncloud.android.files.services.NameCollisionPolicy;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
||||
import com.owncloud.android.lib.common.network.ProgressiveDataTransfer;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.OperationCancelledException;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -383,6 +382,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
mCancellationRequested.set(false);
|
||||
@@ -509,8 +509,6 @@ public class UploadFileOperation extends SyncOperation {
|
||||
// IV, always generate new one
|
||||
byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength);
|
||||
|
||||
EncryptionUtils.EncryptedFile encryptedFile = EncryptionUtils.encryptFile(mFile, key, iv);
|
||||
|
||||
// new random file name, check if it exists in metadata
|
||||
String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
@@ -519,9 +517,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
File encryptedTempFile = File.createTempFile("encFile", encryptedFileName);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(encryptedTempFile);
|
||||
fileOutputStream.write(encryptedFile.encryptedBytes);
|
||||
fileOutputStream.close();
|
||||
byte[] authenticationTag = EncryptionUtils.encryptFile(mFile, encryptedTempFile, key, iv);
|
||||
|
||||
/***** E2E *****/
|
||||
|
||||
@@ -614,7 +610,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
|
||||
decryptedFile.setEncrypted(data);
|
||||
decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv));
|
||||
decryptedFile.setAuthenticationTag(encryptedFile.authenticationTag);
|
||||
decryptedFile.setAuthenticationTag(EncryptionUtils.encodeBytesToBase64String(authenticationTag));
|
||||
|
||||
metadata.getFiles().put(encryptedFileName, decryptedFile);
|
||||
|
||||
@@ -1050,7 +1046,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
* will be uploaded.
|
||||
*/
|
||||
private RemoteOperationResult grantFolderExistence(String pathToGrant, OwnCloudClient client) {
|
||||
LegacyRemoteOperation operation = new ExistenceCheckRemoteOperation(pathToGrant, false);
|
||||
RemoteOperation operation = new ExistenceCheckRemoteOperation(pathToGrant, false);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND && mRemoteFolderToBeCreated) {
|
||||
SyncOperation syncOp = new CreateFolderOperation(pathToGrant, user, getContext(), getStorageManager());
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.operations.common;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.operations.NextcloudRemoteOperation;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
/**
|
||||
* Operation which execution involves both interactions with an ownCloud server and with local data in the device.
|
||||
* <p>
|
||||
* Provides methods to execute the operation both synchronously or asynchronously.
|
||||
*/
|
||||
public abstract class NextcloudSyncOperation<T> extends NextcloudRemoteOperation<T> {
|
||||
private final FileDataStorageManager storageManager;
|
||||
|
||||
public NextcloudSyncOperation(@NonNull FileDataStorageManager storageManager) {
|
||||
this.storageManager = storageManager;
|
||||
}
|
||||
|
||||
public FileDataStorageManager getStorageManager() {
|
||||
return this.storageManager;
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,11 @@ package com.owncloud.android.operations.common;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -37,8 +38,7 @@ import androidx.annotation.NonNull;
|
||||
* <p>
|
||||
* Provides methods to execute the operation both synchronously or asynchronously.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class SyncOperation extends LegacyRemoteOperation {
|
||||
public abstract class SyncOperation extends RemoteOperation {
|
||||
private final FileDataStorageManager storageManager;
|
||||
|
||||
public SyncOperation(@NonNull FileDataStorageManager storageManager) {
|
||||
@@ -64,6 +64,10 @@ public abstract class SyncOperation extends LegacyRemoteOperation {
|
||||
return super.execute(this.storageManager.getUser(), context);
|
||||
}
|
||||
|
||||
public RemoteOperationResult execute(@NonNull NextcloudClient client) {
|
||||
return run(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes the remote operation
|
||||
*
|
||||
|
||||
@@ -41,7 +41,6 @@ import android.util.Pair;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -49,8 +48,6 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.NextcloudRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -396,7 +393,6 @@ public class OperationsService extends Service {
|
||||
private RemoteOperation mCurrentOperation;
|
||||
private Target mLastTarget;
|
||||
private OwnCloudClient mOwnCloudClient;
|
||||
private NextcloudClient nextcloudClient;
|
||||
|
||||
public ServiceHandler(Looper looper, OperationsService service) {
|
||||
super(looper);
|
||||
@@ -440,18 +436,10 @@ public class OperationsService extends Service {
|
||||
}
|
||||
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, mService);
|
||||
|
||||
nextcloudClient = OwnCloudClientManagerFactory
|
||||
.getDefaultSingleton()
|
||||
.getNextcloudClientFor(ocAccount, mService);
|
||||
}
|
||||
|
||||
/// perform the operation
|
||||
if (mCurrentOperation instanceof LegacyRemoteOperation) {
|
||||
result = ((LegacyRemoteOperation) mCurrentOperation).execute(mOwnCloudClient);
|
||||
} else {
|
||||
result = ((NextcloudRemoteOperation) mCurrentOperation).execute(nextcloudClient);
|
||||
}
|
||||
result = mCurrentOperation.execute(mOwnCloudClient);
|
||||
} catch (AccountsException e) {
|
||||
if (mLastTarget.mAccount == null) {
|
||||
Log_OC.e(TAG, "Error while trying to get authorization for a NULL account",
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
@@ -106,13 +106,13 @@ public class FilesServiceApiImpl implements FilesServiceApi {
|
||||
|
||||
if (remoteOcFile.isFolder()) {
|
||||
// perform folder synchronization
|
||||
LegacyRemoteOperation synchFolderOp = new RefreshFolderOperation(remoteOcFile,
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
true,
|
||||
baseActivity.getStorageManager(),
|
||||
baseActivity.getUser().orElseThrow(RuntimeException::new),
|
||||
context);
|
||||
RemoteOperation synchFolderOp = new RefreshFolderOperation(remoteOcFile,
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
true,
|
||||
baseActivity.getStorageManager(),
|
||||
baseActivity.getUser().orElseThrow(RuntimeException::new),
|
||||
context);
|
||||
synchFolderOp.execute(ownCloudClient);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,11 @@ import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -51,6 +48,8 @@ import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -87,7 +86,6 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.Quota;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.lib.common.accounts.ExternalLinksOperation;
|
||||
import com.owncloud.android.lib.common.operations.NextcloudRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -135,7 +133,6 @@ import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import hct.Hct;
|
||||
|
||||
/**
|
||||
* Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
|
||||
@@ -206,25 +203,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
private ExternalLinksProvider externalLinksProvider;
|
||||
private ArbitraryDataProvider arbitraryDataProvider;
|
||||
|
||||
private NextcloudClient nextcloudClient;
|
||||
|
||||
@Inject
|
||||
AppPreferences preferences;
|
||||
|
||||
@Inject
|
||||
ClientFactory clientFactory;
|
||||
|
||||
public DrawerActivity() {
|
||||
try {
|
||||
User user = accountManager.getUser();
|
||||
nextcloudClient = OwnCloudClientManagerFactory
|
||||
.getDefaultSingleton()
|
||||
.getNextcloudClientFor(user.toOwnCloudAccount(), this);
|
||||
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
|
||||
Log_OC.e(this, "Error creating account", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the drawer, its content and highlights the menu item with the given id. This method needs to be
|
||||
@@ -336,7 +320,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
.decoder(new SvgOrImageDecoder());
|
||||
|
||||
// background image
|
||||
SimpleTarget<Bitmap> target = new SimpleTarget<>() {
|
||||
SimpleTarget target = new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
|
||||
|
||||
@@ -348,8 +332,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
logo = BitmapUtils.scaleBitmap(resource, MAX_LOGO_SIZE_PX, width, height, max);
|
||||
}
|
||||
|
||||
Drawable[] drawables = {new ColorDrawable(primaryColor),
|
||||
new BitmapDrawable(getResources(), logo)};
|
||||
Drawable[] drawables = {new ColorDrawable(primaryColor), new BitmapDrawable(logo)};
|
||||
LayerDrawable layerDrawable = new LayerDrawable(drawables);
|
||||
|
||||
String name = capability.getServerName();
|
||||
@@ -362,91 +345,29 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
.load(Uri.parse(logo))
|
||||
.into(target);
|
||||
}
|
||||
|
||||
// hide ecosystem apps according to user preference or in branded client
|
||||
LinearLayout ecosystemApps = mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps);
|
||||
if (getResources().getBoolean(R.bool.is_branded_client) || !preferences.isShowEcosystemApps()) {
|
||||
ecosystemApps.setVisibility(View.GONE);
|
||||
} else {
|
||||
LinearLayout[] views = {
|
||||
ecosystemApps.findViewById(R.id.drawer_ecosystem_notes),
|
||||
ecosystemApps.findViewById(R.id.drawer_ecosystem_talk),
|
||||
ecosystemApps.findViewById(R.id.drawer_ecosystem_more)
|
||||
};
|
||||
|
||||
views[0].setOnClickListener(v -> openAppOrStore("it.niedermann.owncloud.notes"));
|
||||
views[1].setOnClickListener(v -> openAppOrStore("com.nextcloud.talk2"));
|
||||
views[2].setOnClickListener(v -> openAppStore("Nextcloud", true));
|
||||
|
||||
int iconColor;
|
||||
if (Hct.fromInt(primaryColor).getTone() < 80.0) {
|
||||
iconColor = Color.WHITE;
|
||||
} else {
|
||||
iconColor = getColor(R.color.grey_800_transparent);
|
||||
}
|
||||
for (LinearLayout view : views) {
|
||||
ImageView imageView = (ImageView) view.getChildAt(0);
|
||||
imageView.setImageTintList(ColorStateList.valueOf(iconColor));
|
||||
GradientDrawable background = (GradientDrawable) imageView.getBackground();
|
||||
background.setStroke(DisplayUtils.convertDpToPixel(1, this), iconColor);
|
||||
TextView textView = (TextView) view.getChildAt(1);
|
||||
textView.setTextColor(iconColor);
|
||||
}
|
||||
|
||||
ecosystemApps.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open specified app and, if not installed redirect to corresponding download.
|
||||
*
|
||||
* @param packageName of app to be opened
|
||||
*/
|
||||
private void openAppOrStore(String packageName) {
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if (intent != null) {
|
||||
// app installed - open directly
|
||||
intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, getUser().get().hashCode());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
// app not found - open market (Google Play Store, F-Droid, etc.)
|
||||
openAppStore(packageName, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open app store page of specified app or search for specified string.
|
||||
* Will attempt to open browser when no app store is available.
|
||||
*
|
||||
* @param string packageName or url-encoded search string
|
||||
* @param search false -> show app corresponding to packageName; true -> open search for string
|
||||
*/
|
||||
private void openAppStore(String string, boolean search) {
|
||||
String suffix = (search ? "search?q=" : "details?id=") + string;
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + suffix));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException activityNotFoundException1) {
|
||||
// all is lost: open google play store web page for app
|
||||
if (!search) {
|
||||
suffix = "apps/" + suffix;
|
||||
}
|
||||
intent.setData(Uri.parse("https://play.google.com/store/" + suffix));
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDrawerHeaderLogo(Drawable drawable, String serverName) {
|
||||
private void setDrawerHeaderLogo(Drawable drawable, String name) {
|
||||
ImageView imageHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_logo);
|
||||
imageHeader.setImageDrawable(drawable);
|
||||
imageHeader.setScaleType(ImageView.ScaleType.FIT_START);
|
||||
imageHeader.setAdjustViewBounds(true);
|
||||
|
||||
if (!TextUtils.isEmpty(serverName)) {
|
||||
TextView serverNameView = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
|
||||
serverNameView.setVisibility(View.VISIBLE);
|
||||
serverNameView.setText(serverName);
|
||||
serverNameView.setTextColor(themeColorUtils.unchangedFontColor(this));
|
||||
imageHeader.setMaxWidth(DisplayUtils.convertDpToPixel(100f, this));
|
||||
|
||||
MarginLayoutParams oldParam = (MarginLayoutParams) imageHeader.getLayoutParams();
|
||||
MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.MATCH_PARENT);
|
||||
params.leftMargin = oldParam.leftMargin;
|
||||
params.rightMargin = oldParam.rightMargin;
|
||||
|
||||
imageHeader.setLayoutParams(new LinearLayout.LayoutParams(params));
|
||||
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
TextView serverName = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
|
||||
serverName.setText(name);
|
||||
serverName.setTextColor(themeColorUtils.unchangedFontColor(this));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -732,7 +653,11 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
// set home button properties
|
||||
if (mDrawerToggle != null) {
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(chosenFile != null && isRoot(chosenFile));
|
||||
if (chosenFile != null && isRoot(chosenFile)) {
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
} else {
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,7 +700,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
viewThemeUtils.material.colorProgressBar(mQuotaProgressBar);
|
||||
} else {
|
||||
viewThemeUtils.material.colorProgressBar(mQuotaProgressBar,
|
||||
getResources().getColor(R.color.infolevel_warning, getTheme()));
|
||||
getResources().getColor(R.color.infolevel_warning));
|
||||
}
|
||||
|
||||
updateQuotaLink();
|
||||
@@ -879,6 +804,21 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
return;
|
||||
}
|
||||
|
||||
final Context context = MainApp.getAppContext();
|
||||
NextcloudClient nextcloudClient = null;
|
||||
try {
|
||||
nextcloudClient = OwnCloudClientManagerFactory
|
||||
.getDefaultSingleton()
|
||||
.getNextcloudClientFor(user.toOwnCloudAccount(),
|
||||
context);
|
||||
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
|
||||
Log_OC.e(this, "Error retrieving user quota", e);
|
||||
}
|
||||
|
||||
if (nextcloudClient == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RemoteOperationResult<UserInfo> result = new GetUserInfoRemoteOperation().execute(nextcloudClient);
|
||||
|
||||
if (result.isSuccess() && result.getResultData() != null) {
|
||||
@@ -1113,22 +1053,28 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
@Override
|
||||
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
|
||||
if (callContext instanceof MenuItem menuItem) {
|
||||
if (callContext instanceof MenuItem) {
|
||||
MenuItem menuItem = (MenuItem) callContext;
|
||||
menuItem.setIcon(avatarDrawable);
|
||||
} else if (callContext instanceof ImageView imageView) {
|
||||
} else if (callContext instanceof ImageView) {
|
||||
ImageView imageView = (ImageView) callContext;
|
||||
imageView.setImageDrawable(avatarDrawable);
|
||||
} else if (callContext instanceof MaterialButton materialButton) {
|
||||
} else if (callContext instanceof MaterialButton) {
|
||||
MaterialButton materialButton = (MaterialButton) callContext;
|
||||
materialButton.setIcon(avatarDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
|
||||
if (callContext instanceof MenuItem menuItem) {
|
||||
if (callContext instanceof MenuItem) {
|
||||
MenuItem menuItem = (MenuItem) callContext;
|
||||
return String.valueOf(menuItem.getTitle()).equals(tag);
|
||||
} else if (callContext instanceof ImageView imageView) {
|
||||
} else if (callContext instanceof ImageView) {
|
||||
ImageView imageView = (ImageView) callContext;
|
||||
return String.valueOf(imageView.getTag()).equals(tag);
|
||||
} else if (callContext instanceof MaterialButton materialButton) {
|
||||
} else if (callContext instanceof MaterialButton) {
|
||||
MaterialButton materialButton = (MaterialButton) callContext;
|
||||
return String.valueOf(materialButton.getTag()).equals(tag);
|
||||
}
|
||||
return false;
|
||||
@@ -1181,7 +1127,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
if ((getCapabilities() == null || getCapabilities().getAccountName().isEmpty())
|
||||
&& getStorageManager() != null) {
|
||||
GetCapabilitiesOperation getCapabilities = new GetCapabilitiesOperation(getStorageManager());
|
||||
getCapabilities.execute(nextcloudClient);
|
||||
getCapabilities.execute(getBaseContext());
|
||||
}
|
||||
|
||||
User user = accountManager.getUser();
|
||||
@@ -1200,8 +1146,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
FileActivity.APP_OPENED_COUNT, "0");
|
||||
|
||||
Log_OC.d("ExternalLinks", "update via api");
|
||||
NextcloudRemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(nextcloudClient);
|
||||
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(user, this);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
externalLinksProvider.deleteAllExternalLinks();
|
||||
|
||||
@@ -391,10 +391,6 @@ public class FileDisplayActivity extends FileActivity
|
||||
if (OPEN_FILE.equals(getIntent().getAction())) {
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
onOpenFileIntent(getIntent());
|
||||
} else if (RESTART.equals(getIntent().getAction())) {
|
||||
// most likely switched to different account
|
||||
DisplayUtils.showSnackMessage(this, String.format(getString(R.string.logged_in_as),
|
||||
accountManager.getUser().getAccountName()));
|
||||
}
|
||||
|
||||
upgradeNotificationForInstantUpload();
|
||||
@@ -2507,7 +2503,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
openFileByPath(optionalUser.get(), filePath);
|
||||
} else {
|
||||
dismissLoadingDialog();
|
||||
accountClicked(optionalUser.get().hashCode());
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.file_not_found));
|
||||
}
|
||||
} else {
|
||||
dismissLoadingDialog();
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.RichDocumentsCreateAssetRemoteOperation;
|
||||
import com.owncloud.android.operations.RichDocumentsCreateAssetOperation;
|
||||
import com.owncloud.android.ui.asynctasks.PrintAsyncTask;
|
||||
import com.owncloud.android.ui.asynctasks.RichDocumentsLoadUrlTask;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
@@ -118,7 +118,7 @@ public class RichDocumentsEditorWebView extends EditorWebView {
|
||||
|
||||
new Thread(() -> {
|
||||
User user = currentAccountProvider.getUser();
|
||||
RichDocumentsCreateAssetRemoteOperation operation = new RichDocumentsCreateAssetRemoteOperation(file.getRemotePath());
|
||||
RichDocumentsCreateAssetOperation operation = new RichDocumentsCreateAssetOperation(file.getRemotePath());
|
||||
RemoteOperationResult result = operation.execute(user, this);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
@@ -235,8 +235,10 @@ public class RichDocumentsEditorWebView extends EditorWebView {
|
||||
@JavascriptInterface
|
||||
public void paste() {
|
||||
// Javascript cannot do this by itself, so help out.
|
||||
getWebView().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_PASTE));
|
||||
getWebView().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_PASTE));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
getWebView().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_PASTE));
|
||||
getWebView().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_PASTE));
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@@ -137,7 +137,6 @@ public class SettingsActivity extends PreferenceActivity
|
||||
|
||||
private ListPreference lock;
|
||||
private ThemeableSwitchPreference showHiddenFiles;
|
||||
private ThemeableSwitchPreference showEcosystemApps;
|
||||
private AppCompatDelegate delegate;
|
||||
|
||||
private ListPreference prefStoragePath;
|
||||
@@ -607,7 +606,6 @@ public class SettingsActivity extends PreferenceActivity
|
||||
boolean fPassCodeEnabled = getResources().getBoolean(R.bool.passcode_enabled);
|
||||
boolean fDeviceCredentialsEnabled = getResources().getBoolean(R.bool.device_credentials_enabled);
|
||||
boolean fShowHiddenFilesEnabled = getResources().getBoolean(R.bool.show_hidden_files_enabled);
|
||||
boolean fShowEcosystemAppsEnabled = !getResources().getBoolean(R.bool.is_branded_client);
|
||||
boolean fSyncedFolderLightEnabled = getResources().getBoolean(R.bool.syncedFolder_light);
|
||||
boolean fShowMediaScanNotifications = preferences.isShowMediaScanNotifications();
|
||||
|
||||
@@ -615,8 +613,6 @@ public class SettingsActivity extends PreferenceActivity
|
||||
|
||||
setupHiddenFilesPreference(preferenceCategoryDetails, fShowHiddenFilesEnabled);
|
||||
|
||||
setupShowEcosystemAppsPreference(preferenceCategoryDetails, fShowEcosystemAppsEnabled);
|
||||
|
||||
setupShowMediaScanNotifications(preferenceCategoryDetails, fShowMediaScanNotifications);
|
||||
|
||||
if (!fPassCodeEnabled && !fDeviceCredentialsEnabled && !fShowHiddenFilesEnabled && fSyncedFolderLightEnabled
|
||||
@@ -648,20 +644,6 @@ public class SettingsActivity extends PreferenceActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void setupShowEcosystemAppsPreference(PreferenceCategory preferenceCategoryDetails,
|
||||
boolean fShowEcosystemAppsEnabled) {
|
||||
showEcosystemApps = (ThemeableSwitchPreference) findPreference("show_ecosystem_apps");
|
||||
if (fShowEcosystemAppsEnabled) {
|
||||
showEcosystemApps.setOnPreferenceClickListener(preference -> {
|
||||
preferences.setShowEcosystemApps(showEcosystemApps.isChecked());
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryDetails.removePreference(showEcosystemApps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupLockPreference(PreferenceCategory preferenceCategoryDetails,
|
||||
boolean passCodeEnabled,
|
||||
boolean deviceCredentialsEnabled) {
|
||||
|
||||
@@ -44,7 +44,6 @@ import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
import com.nextcloud.client.jobs.MediaFoldersDetectionWork
|
||||
import com.nextcloud.client.jobs.NotificationWork
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.owncloud.android.BuildConfig
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
@@ -401,8 +400,7 @@ class SyncedFoldersActivity :
|
||||
localFolder.name,
|
||||
files.size.toLong(),
|
||||
syncedFolder.type,
|
||||
syncedFolder.isHidden,
|
||||
syncedFolder.subfolderRule
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
}
|
||||
|
||||
@@ -431,8 +429,7 @@ class SyncedFoldersActivity :
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type,
|
||||
syncedFolder.isHidden,
|
||||
syncedFolder.subfolderRule
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
}
|
||||
|
||||
@@ -460,8 +457,7 @@ class SyncedFoldersActivity :
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -552,8 +548,7 @@ class SyncedFoldersActivity :
|
||||
clock.currentTime,
|
||||
null,
|
||||
MediaFolderType.CUSTOM,
|
||||
false,
|
||||
SubFolderRule.YEAR_MONTH
|
||||
false
|
||||
)
|
||||
onSyncFolderSettingsClick(0, emptyCustomFolder)
|
||||
} else {
|
||||
@@ -662,8 +657,7 @@ class SyncedFoldersActivity :
|
||||
clock.currentTime,
|
||||
File(syncedFolder.localPath).name,
|
||||
syncedFolder.type,
|
||||
syncedFolder.isHidden,
|
||||
syncedFolder.subFolderRule
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
saveOrUpdateSyncedFolder(newCustomFolder)
|
||||
adapter.addSyncFolderItem(newCustomFolder)
|
||||
@@ -680,8 +674,7 @@ class SyncedFoldersActivity :
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.uploadAction,
|
||||
syncedFolder.nameCollisionPolicy.serialize(),
|
||||
syncedFolder.isEnabled,
|
||||
syncedFolder.subFolderRule
|
||||
syncedFolder.isEnabled
|
||||
)
|
||||
saveOrUpdateSyncedFolder(item)
|
||||
|
||||
@@ -761,8 +754,7 @@ class SyncedFoldersActivity :
|
||||
subfolderByDate: Boolean,
|
||||
uploadAction: Int,
|
||||
nameCollisionPolicy: Int,
|
||||
enabled: Boolean,
|
||||
subFolderRule: SubFolderRule
|
||||
enabled: Boolean
|
||||
) {
|
||||
item.id = id
|
||||
item.localPath = localPath
|
||||
@@ -774,7 +766,6 @@ class SyncedFoldersActivity :
|
||||
item.uploadAction = uploadAction
|
||||
item.setNameCollisionPolicy(nameCollisionPolicy)
|
||||
item.setEnabled(enabled, clock.currentTime)
|
||||
item.setSubFolderRule(subFolderRule)
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
|
||||
@@ -21,12 +21,10 @@
|
||||
package com.owncloud.android.ui.adapter;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.ui.ImageDetailFragment;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.fragment.FileDetailActivitiesFragment;
|
||||
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -42,7 +40,6 @@ public class FileDetailTabAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private FileDetailSharingFragment fileDetailSharingFragment;
|
||||
private FileDetailActivitiesFragment fileDetailActivitiesFragment;
|
||||
private ImageDetailFragment imageDetailFragment;
|
||||
|
||||
public FileDetailTabAdapter(FragmentManager fm, OCFile file, User user) {
|
||||
super(fm);
|
||||
@@ -61,9 +58,6 @@ public class FileDetailTabAdapter extends FragmentStatePagerAdapter {
|
||||
case 1:
|
||||
fileDetailSharingFragment = FileDetailSharingFragment.newInstance(file, user);
|
||||
return fileDetailSharingFragment;
|
||||
case 2:
|
||||
imageDetailFragment = ImageDetailFragment.newInstance(file, user);
|
||||
return imageDetailFragment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,23 +69,18 @@ public class FileDetailTabAdapter extends FragmentStatePagerAdapter {
|
||||
return fileDetailActivitiesFragment;
|
||||
}
|
||||
|
||||
public ImageDetailFragment getImageDetailFragment() {
|
||||
return imageDetailFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (file.isEncrypted()) {
|
||||
if (EncryptionUtils.supportsSecureFiledrop(file, user)) {
|
||||
return 2;
|
||||
} else {
|
||||
// sharing not allowed for encrypted files, thus only show first tab (activities)
|
||||
return 1;
|
||||
}
|
||||
// sharing not allowed for encrypted files, thus only show first tab (activities)
|
||||
return 1;
|
||||
} else {
|
||||
// unencrypted files/folders
|
||||
return 2;
|
||||
}
|
||||
// unencrypted files/folders
|
||||
if (MimeTypeUtil.isImage(file)) {
|
||||
return 3;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,9 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.GalleryRowBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.GalleryRow
|
||||
import com.owncloud.android.datamodel.ImageDimension
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ import com.owncloud.android.datamodel.VirtualFolderType;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
@@ -752,15 +751,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
}
|
||||
|
||||
// create partial OCFile from OCShares
|
||||
List<OCFile> files = OCShareToOCFileConverter.buildOCFilesFromShares(shares);
|
||||
|
||||
// set localPath of individual files iff present on device
|
||||
for (OCFile file : files) {
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.getAccountName());
|
||||
}
|
||||
|
||||
mFiles.clear();
|
||||
mFiles.addAll(files);
|
||||
mStorageManager.saveShares(shares);
|
||||
}
|
||||
@@ -823,13 +814,13 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
// also sync folder content
|
||||
if (ocFile.isFolder()) {
|
||||
long currentSyncTime = System.currentTimeMillis();
|
||||
LegacyRemoteOperation refreshFolderOperation = new RefreshFolderOperation(ocFile,
|
||||
currentSyncTime,
|
||||
true,
|
||||
false,
|
||||
mStorageManager,
|
||||
user,
|
||||
activity);
|
||||
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(ocFile,
|
||||
currentSyncTime,
|
||||
true,
|
||||
false,
|
||||
mStorageManager,
|
||||
user,
|
||||
activity);
|
||||
refreshFolderOperation.execute(user, activity);
|
||||
}
|
||||
}
|
||||
@@ -1027,4 +1018,27 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
public void notifyItemChanged(@NonNull OCFile file) {
|
||||
notifyItemChanged(getItemPosition(file));
|
||||
}
|
||||
|
||||
public void replaceFileByRemotePath(@NonNull OCFile newFile, boolean notify) {
|
||||
final String remotePath = newFile.getRemotePath();
|
||||
for (OCFile file : mFiles) {
|
||||
if (file.getRemotePath().equals(remotePath)) {
|
||||
final int index = mFiles.indexOf(file);
|
||||
mFiles.set(index, newFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (OCFile file : mFilesAll) {
|
||||
if (file.getRemotePath().equals(remotePath)) {
|
||||
final int index = mFilesAll.indexOf(file);
|
||||
mFilesAll.set(index, newFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
notifyItemChanged(getItemPosition(newFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.TemplateButtonBinding;
|
||||
import com.owncloud.android.lib.resources.files.RichDocumentsTemplateType;
|
||||
import com.owncloud.android.lib.resources.files.Template;
|
||||
import com.owncloud.android.datamodel.Template;
|
||||
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
|
||||
import com.owncloud.android.utils.NextcloudServer;
|
||||
import com.owncloud.android.utils.glide.CustomGlideStreamLoader;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
@@ -52,14 +52,14 @@ public class RichDocumentsTemplateAdapter extends RecyclerView.Adapter<RichDocum
|
||||
private List<Template> templateList = new ArrayList<>();
|
||||
private ClickListener clickListener;
|
||||
private Context context;
|
||||
private RichDocumentsTemplateType type;
|
||||
private ChooseRichDocumentsTemplateDialogFragment.Type type;
|
||||
private CurrentAccountProvider currentAccountProvider;
|
||||
private ClientFactory clientFactory;
|
||||
private Template selectedTemplate;
|
||||
private ViewThemeUtils viewThemeUtils;
|
||||
|
||||
public RichDocumentsTemplateAdapter(
|
||||
RichDocumentsTemplateType type,
|
||||
ChooseRichDocumentsTemplateDialogFragment.Type type,
|
||||
ClickListener clickListener,
|
||||
Context context,
|
||||
CurrentAccountProvider currentAccountProvider,
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.LegacyRemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
|
||||
@@ -97,13 +97,13 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
|
||||
}
|
||||
|
||||
long currentSyncTime = System.currentTimeMillis();
|
||||
LegacyRemoteOperation refreshFolderOperation = new RefreshFolderOperation(toSync,
|
||||
currentSyncTime,
|
||||
true,
|
||||
true,
|
||||
storageManager,
|
||||
user,
|
||||
fileDisplayActivity);
|
||||
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(toSync,
|
||||
currentSyncTime,
|
||||
true,
|
||||
true,
|
||||
storageManager,
|
||||
user,
|
||||
fileDisplayActivity);
|
||||
refreshFolderOperation.execute(user, fileDisplayActivity);
|
||||
|
||||
fileDisplayActivity.setFile(ocFile);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.operations.RefreshFolderOperation
|
||||
@@ -47,7 +48,7 @@ class GetRemoteFileTask(
|
||||
val remoteOcFile = storageManager.saveFileWithParent(temp, context)
|
||||
if (remoteOcFile.isFolder()) {
|
||||
// perform folder synchronization
|
||||
val synchFolderOp = RefreshFolderOperation(
|
||||
val synchFolderOp: RemoteOperation<Any> = RefreshFolderOperation(
|
||||
remoteOcFile,
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
|
||||