Compare commits
66
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c65b2c6ac7 | ||
|
|
8ff6aa37b3 | ||
|
|
204cd5a2c5 | ||
|
|
88605985a0 | ||
|
|
3e97e1e212 | ||
|
|
6ccd2f91de | ||
|
|
c2bdea7f74 | ||
|
|
f3de5f9862 | ||
|
|
96c55a6d9f | ||
|
|
dc7f3f88e1 | ||
|
|
7baa0f8da4 | ||
|
|
2baf63d809 | ||
|
|
462da35fdb | ||
|
|
c5ebc05964 | ||
|
|
618a770349 | ||
|
|
4a29c2e4c4 | ||
|
|
8fc8cc9836 | ||
|
|
a8dae30a3a | ||
|
|
d51268d7b8 | ||
|
|
af2059660f | ||
|
|
c01fa0b170 | ||
|
|
27559efb79 | ||
|
|
38c60b7618 | ||
|
|
494cceab8e | ||
|
|
7eaed66ebc | ||
|
|
45fc831989 | ||
|
|
9d5395c8fd | ||
|
|
043d839d70 | ||
|
|
a9ec1de015 | ||
|
|
00586a5bde | ||
|
|
b6115a5fc1 | ||
|
|
b07716c0e5 | ||
|
|
9f2bdd5916 | ||
|
|
e35b6211f0 | ||
|
|
ae8752a4f7 | ||
|
|
e6d64e5ed5 | ||
|
|
41b3921643 | ||
|
|
e1b41b5d77 | ||
|
|
db74d67168 | ||
|
|
83e56643f4 | ||
|
|
ebb74bc8a0 | ||
|
|
0e8fbe73b1 | ||
|
|
750864d951 | ||
|
|
8e67653a38 | ||
|
|
5a65c65e76 | ||
|
|
80928a2799 | ||
|
|
7181249667 | ||
|
|
d057d48a89 | ||
|
|
a8feb7bb66 | ||
|
|
b7f1ebd74b | ||
|
|
fe28ce3190 | ||
|
|
dc6ea6cd0e | ||
|
|
4c44d469e0 | ||
|
|
d328d89c2d | ||
|
|
22367838ab | ||
|
|
2476be69ba | ||
|
|
1a735f1840 | ||
|
|
c45dd9f5ff | ||
|
|
63c780999d | ||
|
|
6a45a90019 | ||
|
|
93f973cdc2 | ||
|
|
dd94e20045 | ||
|
|
f0ea41a56b | ||
|
|
21e756cf88 | ||
|
|
f7e53a17c0 | ||
|
|
43610aedba |
No files matched your search
@@ -1,14 +1,35 @@
|
||||
name: "Analysis"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup variables
|
||||
id: get-vars
|
||||
run: |
|
||||
if [ -z "$GITHUB_HEAD_REF" ]; then
|
||||
# push
|
||||
echo "::set-output name=branch::$GITHUB_REF_NAME"
|
||||
echo "::set-output name=pr::$GITHUB_RUN_ID"
|
||||
else
|
||||
# pull request
|
||||
echo "::set-output name=branch::$GITHUB_HEAD_REF"
|
||||
echo "::set-output name=pr::${{ github.event.pull_request.number }}"
|
||||
fi
|
||||
- name: Show variables
|
||||
run: |
|
||||
echo "BRANCH: ${{ steps.get-vars.outputs.branch }}"
|
||||
echo "PR: ${{ steps.get-vars.outputs.pr }}"
|
||||
echo "RUN NUMBER: $GITHUB_RUN_NUMBER"
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
@@ -18,4 +39,4 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
|
||||
scripts/analysis/analysis-wrapper.sh ${{ secrets.GIT_USERNAME }} ${{ secrets.GIT_TOKEN }} ${{ github.head_ref }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ github.event.pull_request.number }}
|
||||
scripts/analysis/analysis-wrapper.sh ${{ secrets.GIT_USERNAME }} ${{ secrets.GIT_TOKEN }} ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ steps.get-vars.outputs.pr }}
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
sdcard-path-or-size: 100M
|
||||
target: google_apis
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
|
||||
script: ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
|
||||
script: ./gradlew uninstallAll gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
|
||||
- name: upload failing results
|
||||
if: ${{ failure() }}
|
||||
run:
|
||||
|
||||
+26
-22
@@ -8,23 +8,23 @@ GEM
|
||||
artifactory (3.0.15)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.2.0)
|
||||
aws-partitions (1.541.0)
|
||||
aws-sdk-core (3.124.0)
|
||||
aws-partitions (1.549.0)
|
||||
aws-sdk-core (3.125.5)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.525.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.52.0)
|
||||
aws-sdk-core (~> 3, >= 3.122.0)
|
||||
aws-sdk-kms (1.53.0)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.109.0)
|
||||
aws-sdk-core (~> 3, >= 3.122.0)
|
||||
aws-sdk-s3 (1.111.2)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.4)
|
||||
aws-sigv4 (1.4.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
claide (1.0.3)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
@@ -36,17 +36,18 @@ GEM
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.7.6)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.89.0)
|
||||
faraday (1.8.0)
|
||||
excon (0.90.0)
|
||||
faraday (1.9.3)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-retry (~> 1.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.7)
|
||||
faraday (>= 0.8.0)
|
||||
@@ -55,14 +56,17 @@ GEM
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.0.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.2.5)
|
||||
fastlane (2.199.0)
|
||||
fastimage (2.2.6)
|
||||
fastlane (2.201.1)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -101,11 +105,11 @@ GEM
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
xcpretty-travis-formatter (>= 0.0.3)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.17)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.18)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.14.0)
|
||||
google-apis-androidpublisher_v3 (0.15.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-core (0.4.1)
|
||||
google-apis-core (0.4.2)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
httpclient (>= 2.8.1, < 3.a)
|
||||
@@ -114,11 +118,11 @@ GEM
|
||||
retriable (>= 2.0, < 4.a)
|
||||
rexml
|
||||
webrick
|
||||
google-apis-iamcredentials_v1 (0.9.0)
|
||||
google-apis-iamcredentials_v1 (0.10.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.6.0)
|
||||
google-apis-playcustomapp_v1 (0.7.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-storage_v1 (0.10.0)
|
||||
google-apis-storage_v1 (0.11.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-cloud-core (1.6.0)
|
||||
google-cloud-env (~> 1.0)
|
||||
@@ -126,7 +130,7 @@ GEM
|
||||
google-cloud-env (1.5.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
google-cloud-errors (1.2.0)
|
||||
google-cloud-storage (1.35.0)
|
||||
google-cloud-storage (1.36.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
google-apis-iamcredentials_v1 (~> 0.1)
|
||||
@@ -145,7 +149,7 @@ GEM
|
||||
http-cookie (1.0.4)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.4.0)
|
||||
jmespath (1.5.0)
|
||||
json (2.6.1)
|
||||
jwt (2.3.0)
|
||||
memoist (0.16.2)
|
||||
|
||||
+19
-25
@@ -19,13 +19,13 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.4'
|
||||
classpath 'com.android.tools.build:gradle:7.1.0'
|
||||
classpath 'com.hiya:jacoco-android:0.2'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.4'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.5'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:5.11.2'
|
||||
classpath 'com.karumi:shot:5.13.0'
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
|
||||
@@ -64,8 +64,8 @@ ext {
|
||||
daggerVersion = "2.40.5"
|
||||
markwonVersion = "4.6.2"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion ="2b6ccf62a00f9feb7f1c48483c17ba6a260b6caa"
|
||||
mockitoVersion = "4.2.0"
|
||||
androidLibraryVersion ="26878b66a0cd72c44f046307bc0098324c8df48f"
|
||||
mockitoVersion = "4.3.1"
|
||||
mockkVersion = "1.12.2"
|
||||
powermockVersion = "2.0.9"
|
||||
byteBuddyVersion = "1.12.7"
|
||||
@@ -102,20 +102,6 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
|
||||
}
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
checkGeneratedSources = true
|
||||
abortOnError false
|
||||
htmlReport true
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
disable 'MissingTranslation',
|
||||
'GradleDependency',
|
||||
'VectorPath',
|
||||
'IconMissingDensityFolder',
|
||||
'IconDensities',
|
||||
'GoogleAppIndexingWarning',
|
||||
'MissingDefaultResource',
|
||||
'InvalidPeriodicWorkRequestInterval' // crashes due to a bug in lint itself
|
||||
}
|
||||
|
||||
compileSdkVersion 31
|
||||
|
||||
@@ -173,8 +159,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20220122
|
||||
versionName "20220122"
|
||||
versionCode 20220128
|
||||
versionName "20220128"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -193,10 +179,10 @@ android {
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
exclude 'META-INF/LICENSE'
|
||||
resources {
|
||||
excludes += ['META-INF/LICENSE.txt', 'META-INF/LICENSE']
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkstyle", Checkstyle) {
|
||||
@@ -239,6 +225,14 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError false
|
||||
checkGeneratedSources true
|
||||
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities', 'GoogleAppIndexingWarning', 'MissingDefaultResource', 'InvalidPeriodicWorkRequestInterval', 'StringFormatInvalid', 'MissingQuantity'
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
htmlReport true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -263,7 +257,7 @@ dependencies {
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
|
||||
implementation "androidx.work:work-runtime:$workRuntime"
|
||||
implementation "androidx.work:work-runtime-ktx:$workRuntime"
|
||||
implementation "androidx.fragment:fragment-ktx:1.4.0"
|
||||
implementation "androidx.fragment:fragment-ktx:1.4.1"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.3.2' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
|
||||
implementation 'commons-io:commons-io:2.11.0'
|
||||
|
||||
@@ -1 +1 @@
|
||||
642
|
||||
641
|
||||
@@ -110,8 +110,6 @@ previous_git_email = previous_git_email.strip
|
||||
# update git user name and email for this script
|
||||
system ("git config --local user.name '" + git_user + "'")
|
||||
system ("git config --local user.email '[email protected]'")
|
||||
system ("git remote rm origin")
|
||||
system ("git remote add origin https://" + git_user + ":" + git_token + "@github.com/nextcloud/android")
|
||||
|
||||
# add previous FindBugs result file to git
|
||||
system ('git add ' + PREVIOUS_FINDBUGS_RESULTS_FILE)
|
||||
@@ -120,7 +118,7 @@ system ('git add ' + PREVIOUS_FINDBUGS_RESULTS_FILE)
|
||||
system({"GIT_COMMITTER_EMAIL" => "[email protected]", "GIT_AUTHOR_EMAIL" => "[email protected]"}, 'git commit -sm "Drone: update FindBugs results to reflect reduced error/warning count [skip ci]"')
|
||||
|
||||
# push to origin
|
||||
system ('git push origin HEAD:' + git_branch)
|
||||
system ('git push')
|
||||
|
||||
# restore previous git user name and email
|
||||
system("git config --local user.name '#{previous_git_username}'")
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 124 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 103 warnings</span>
|
||||
@@ -179,8 +179,6 @@ previous_git_email = previous_git_email.strip
|
||||
# update git user name and email for this script
|
||||
system ("git config --local user.name '" + git_user + "'")
|
||||
system ("git config --local user.email '[email protected]'")
|
||||
system ("git remote rm origin")
|
||||
system ("git remote add origin https://" + git_user + ":" + git_token + "@github.com/nextcloud/android")
|
||||
|
||||
# add previous Lint result file to git
|
||||
system ('git add ' + PREVIOUS_LINT_RESULTS_FILE)
|
||||
@@ -189,11 +187,7 @@ system ('git add ' + PREVIOUS_LINT_RESULTS_FILE)
|
||||
system({"GIT_COMMITTER_EMAIL" => "[email protected]", "GIT_AUTHOR_EMAIL" => "[email protected]"}, 'git commit -sm "Drone: update Lint results to reflect reduced error/warning count [skip ci]"')
|
||||
|
||||
# push to origin
|
||||
system ('git push origin HEAD:' + git_branch)
|
||||
|
||||
# restore previous git user name and email
|
||||
system("git config --local user.name '#{previous_git_username}'")
|
||||
system("git config --local user.email '#{previous_git_email}'")
|
||||
system ('git push')
|
||||
|
||||
puts "SUCCESS: count was reduced"
|
||||
exit 0 # success
|
||||
@@ -67,7 +67,7 @@ if [ $TYPE = "IT" ]; then
|
||||
elif [ $TYPE = "Unit" ]; then
|
||||
FOLDER=build/reports/tests/testGplayDebugUnitTest
|
||||
else
|
||||
FOLDER=build/reports/shot/verification
|
||||
FOLDER=build/reports/shot/gplay/debug/verification
|
||||
fi
|
||||
|
||||
if [ -e $FOLDER ]; then
|
||||
@@ -92,10 +92,10 @@ else
|
||||
upload "build/reports/tests/testGplayDebugUnitTest"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/shot/verification ] ; then
|
||||
if [ -e build/reports/shot/gplay/debug/verification ] ; then
|
||||
TYPE="Screenshot"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/shot/verification"
|
||||
upload "build/reports/shot/gplay/debug/verification"
|
||||
fi
|
||||
|
||||
exit 1 # always fail
|
||||
|
||||
@@ -419,13 +419,13 @@ public class TestSorting {
|
||||
if (sortedList.get(0) instanceof OCFile) {
|
||||
Collections.sort(unsortedList, (Comparator<OCFile>) (o1, o2) -> {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
return new AlphanumComparator().compare(o1, o2);
|
||||
return AlphanumComparator.compare(o1, o2);
|
||||
} else if (o1.isFolder()) {
|
||||
return -1;
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
}
|
||||
return new AlphanumComparator().compare(o1, o2);
|
||||
return AlphanumComparator.compare(o1, o2);
|
||||
});
|
||||
} else {
|
||||
Collections.sort(unsortedList, new AlphanumComparator<>());
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
|
||||
|
||||
<service
|
||||
android:exported="false"
|
||||
android:name=".services.firebase.NCFirebaseMessagingService">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
||||
|
||||
@@ -88,7 +88,6 @@
|
||||
android:name=".ui.activity.FileDisplayActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/Theme.ownCloud.Launcher">
|
||||
<intent-filter>
|
||||
@@ -193,7 +192,6 @@
|
||||
<activity
|
||||
android:name=".ui.preview.PreviewVideoActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.ownCloud.Fullscreen" />
|
||||
|
||||
<service
|
||||
@@ -425,12 +423,10 @@
|
||||
android:label="@string/copy_link" />
|
||||
<activity
|
||||
android:name=".ui.activity.FolderPickerActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name" />
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activity.FilePickerActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DeckApiImpl implements DeckApi {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
return PendingIntent.getActivity(context, notification.getNotificationId(),
|
||||
putExtrasToIntent(intent, notification, user),
|
||||
PendingIntent.FLAG_ONE_SHOT);
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
|
||||
private Intent putExtrasToIntent(@NonNull Intent intent, @NonNull Notification notification, @NonNull User user) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.NotificationManager
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
@@ -65,6 +66,7 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val deckApi: DeckApi
|
||||
) : WorkerFactory() {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Suppress("ComplexMethod") // it's just a trivial dispatch
|
||||
override fun createWorker(
|
||||
context: Context,
|
||||
@@ -78,18 +80,22 @@ class BackgroundJobFactory @Inject constructor(
|
||||
null
|
||||
}
|
||||
|
||||
return when (workerClass) {
|
||||
ContentObserverWork::class -> createContentObserverJob(context, workerParameters, clock)
|
||||
ContactsBackupWork::class -> createContactsBackupWork(context, workerParameters)
|
||||
ContactsImportWork::class -> createContactsImportWork(context, workerParameters)
|
||||
FilesSyncWork::class -> createFilesSyncWork(context, workerParameters)
|
||||
OfflineSyncWork::class -> createOfflineSyncWork(context, workerParameters)
|
||||
MediaFoldersDetectionWork::class -> createMediaFoldersDetectionWork(context, workerParameters)
|
||||
NotificationWork::class -> createNotificationWork(context, workerParameters)
|
||||
AccountRemovalWork::class -> createAccountRemovalWork(context, workerParameters)
|
||||
CalendarBackupWork::class -> createCalendarBackupWork(context, workerParameters)
|
||||
CalendarImportWork::class -> createCalendarImportWork(context, workerParameters)
|
||||
else -> null // caller falls back to default factory
|
||||
// ContentObserverWork requires N
|
||||
return if (deviceInfo.apiLevel >= Build.VERSION_CODES.N && workerClass == ContentObserverWork::class) {
|
||||
createContentObserverJob(context, workerParameters, clock)
|
||||
} else {
|
||||
when (workerClass) {
|
||||
ContactsBackupWork::class -> createContactsBackupWork(context, workerParameters)
|
||||
ContactsImportWork::class -> createContactsImportWork(context, workerParameters)
|
||||
FilesSyncWork::class -> createFilesSyncWork(context, workerParameters)
|
||||
OfflineSyncWork::class -> createOfflineSyncWork(context, workerParameters)
|
||||
MediaFoldersDetectionWork::class -> createMediaFoldersDetectionWork(context, workerParameters)
|
||||
NotificationWork::class -> createNotificationWork(context, workerParameters)
|
||||
AccountRemovalWork::class -> createAccountRemovalWork(context, workerParameters)
|
||||
CalendarBackupWork::class -> createCalendarBackupWork(context, workerParameters)
|
||||
CalendarImportWork::class -> createCalendarImportWork(context, workerParameters)
|
||||
else -> null // caller falls back to default factory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +184,7 @@ class MediaFoldersDetectionWork constructor(
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
private fun sendNotification(contentTitle: String, subtitle: String, user: User, path: String, type: Int) {
|
||||
val notificationId = randomIdGenerator.nextInt()
|
||||
val context = context
|
||||
@@ -193,7 +194,12 @@ class MediaFoldersDetectionWork constructor(
|
||||
intent.putExtra(NotificationWork.KEY_NOTIFICATION_ACCOUNT, user.accountName)
|
||||
intent.putExtra(KEY_MEDIA_FOLDER_PATH, path)
|
||||
intent.putExtra(KEY_MEDIA_FOLDER_TYPE, type)
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
val notificationBuilder = NotificationCompat.Builder(
|
||||
context,
|
||||
NotificationUtils.NOTIFICATION_CHANNEL_GENERAL
|
||||
@@ -214,7 +220,7 @@ class MediaFoldersDetectionWork constructor(
|
||||
context,
|
||||
notificationId,
|
||||
disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
notificationBuilder.addAction(
|
||||
NotificationCompat.Action(
|
||||
@@ -227,7 +233,7 @@ class MediaFoldersDetectionWork constructor(
|
||||
context,
|
||||
notificationId,
|
||||
intent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
notificationBuilder.addAction(
|
||||
NotificationCompat.Action(
|
||||
|
||||
@@ -159,7 +159,7 @@ class NotificationWork constructor(
|
||||
context,
|
||||
notification.getNotificationId(),
|
||||
intent,
|
||||
PendingIntent.FLAG_ONE_SHOT
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class NotificationWork constructor(
|
||||
context,
|
||||
pushNotificationId,
|
||||
disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
notificationBuilder.addAction(
|
||||
NotificationCompat.Action(
|
||||
@@ -207,7 +207,7 @@ class NotificationWork constructor(
|
||||
context,
|
||||
randomId.nextInt(),
|
||||
actionIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
var icon: Int
|
||||
icon = if (action.primary) {
|
||||
|
||||
@@ -102,12 +102,12 @@ class PlayerService : Service() {
|
||||
|
||||
val stop = Intent(this, PlayerService::class.java)
|
||||
stop.action = ACTION_STOP
|
||||
val pendingStop = PendingIntent.getService(this, 0, stop, 0)
|
||||
val pendingStop = PendingIntent.getService(this, 0, stop, PendingIntent.FLAG_IMMUTABLE)
|
||||
notificationBuilder.addAction(0, getString(R.string.player_stop).toUpperCase(Locale.getDefault()), pendingStop)
|
||||
|
||||
val toggle = Intent(this, PlayerService::class.java)
|
||||
toggle.action = ACTION_TOGGLE
|
||||
val pendingToggle = PendingIntent.getService(this, 0, toggle, 0)
|
||||
val pendingToggle = PendingIntent.getService(this, 0, toggle, PendingIntent.FLAG_IMMUTABLE)
|
||||
notificationBuilder.addAction(
|
||||
0,
|
||||
getString(R.string.player_toggle).toUpperCase(Locale.getDefault()),
|
||||
|
||||
@@ -75,7 +75,7 @@ class AppNotificationManagerImpl @Inject constructor(
|
||||
context,
|
||||
System.currentTimeMillis().toInt(),
|
||||
openFileIntent,
|
||||
0
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
builder.setContentIntent(pendingOpenFileIntent)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class ChooseAccountDialogFragment :
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
_binding = DialogChooseAccountBinding.inflate(LayoutInflater.from(requireContext()))
|
||||
_binding = DialogChooseAccountBinding.inflate(layoutInflater)
|
||||
dialogView = binding.root
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
|
||||
@@ -126,7 +126,7 @@ class SetStatusDialogFragment :
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
binding = DialogSetStatusBinding.inflate(LayoutInflater.from(context))
|
||||
binding = DialogSetStatusBinding.inflate(layoutInflater)
|
||||
|
||||
return AlertDialog.Builder(requireContext())
|
||||
.setView(binding.root)
|
||||
|
||||
@@ -478,13 +478,13 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
@Override
|
||||
public int compareTo(@NonNull OCFile another) {
|
||||
if (isFolder() && another.isFolder()) {
|
||||
return new AlphanumComparator().compare(this, another);
|
||||
return AlphanumComparator.compare(this, another);
|
||||
} else if (isFolder()) {
|
||||
return -1;
|
||||
} else if (another.isFolder()) {
|
||||
return 1;
|
||||
}
|
||||
return new AlphanumComparator().compare(this, another);
|
||||
return AlphanumComparator.compare(this, another);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -579,7 +579,7 @@ public class FileDownloader extends Service
|
||||
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
|
||||
showDetailsIntent, 0));
|
||||
showDetailsIntent, PendingIntent.FLAG_IMMUTABLE));
|
||||
|
||||
|
||||
if (mNotificationManager == null) {
|
||||
@@ -659,7 +659,7 @@ public class FileDownloader extends Service
|
||||
// TODO put something smart in showDetailsIntent
|
||||
Intent showDetailsIntent = new Intent();
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
|
||||
showDetailsIntent, 0));
|
||||
showDetailsIntent, PendingIntent.FLAG_IMMUTABLE));
|
||||
}
|
||||
|
||||
mNotificationBuilder.setContentText(ErrorMessageAdapter.getErrorCauseMessage(downloadResult,
|
||||
@@ -689,8 +689,12 @@ public class FileDownloader extends Service
|
||||
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
|
||||
updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT));
|
||||
mNotificationBuilder.setContentIntent(
|
||||
PendingIntent.getActivity(this,
|
||||
(int) System.currentTimeMillis(),
|
||||
updateAccountCredentials,
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ public class FileUploader extends Service
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this,
|
||||
(int) System.currentTimeMillis(),
|
||||
intent,
|
||||
0)
|
||||
PendingIntent.FLAG_IMMUTABLE)
|
||||
);
|
||||
|
||||
if (!upload.isInstantPicture() && !upload.isInstantVideo()) {
|
||||
@@ -823,7 +823,7 @@ public class FileUploader extends Service
|
||||
this,
|
||||
(int) System.currentTimeMillis(),
|
||||
updateAccountCredentials,
|
||||
PendingIntent.FLAG_ONE_SHOT
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE
|
||||
));
|
||||
} else {
|
||||
Intent intent;
|
||||
@@ -843,7 +843,7 @@ public class FileUploader extends Service
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this,
|
||||
(int) System.currentTimeMillis(),
|
||||
intent,
|
||||
0)
|
||||
PendingIntent.FLAG_IMMUTABLE)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ import android.content.Intent;
|
||||
import android.content.SyncResult;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -408,7 +406,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
.setContentTitle(i18n(R.string.sync_fail_ticker_unauthorized))
|
||||
.setContentIntent(PendingIntent.getActivity(
|
||||
getContext(), (int)System.currentTimeMillis(), updateAccountCredentials,
|
||||
PendingIntent.FLAG_ONE_SHOT
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE
|
||||
))
|
||||
.setContentText(i18n(R.string.sync_fail_content_unauthorized, getAccount().name));
|
||||
} else {
|
||||
@@ -436,8 +434,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
// TODO put something smart in the contentIntent below
|
||||
notificationBuilder
|
||||
.setContentIntent(PendingIntent.getActivity(
|
||||
getContext(), (int) System.currentTimeMillis(), new Intent(), 0
|
||||
))
|
||||
getContext(), (int) System.currentTimeMillis(), new Intent(), PendingIntent.FLAG_IMMUTABLE
|
||||
))
|
||||
.setContentTitle(i18n(R.string.sync_fail_in_favourites_ticker))
|
||||
.setContentText(getQuantityString(
|
||||
R.plurals.sync_fail_in_favourites_content,
|
||||
@@ -454,8 +452,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
// TODO put something smart in the contentIntent below
|
||||
notificationBuilder
|
||||
.setContentIntent(PendingIntent.getActivity(
|
||||
getContext(), (int) System.currentTimeMillis(), new Intent(), 0
|
||||
))
|
||||
getContext(), (int) System.currentTimeMillis(), new Intent(), PendingIntent.FLAG_IMMUTABLE
|
||||
))
|
||||
.setContentTitle(i18n(R.string.sync_conflicts_in_favourites_ticker))
|
||||
.setContentText(i18n(R.string.sync_conflicts_in_favourites_ticker, mConflictsFound));
|
||||
|
||||
@@ -491,8 +489,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
|
||||
notificationBuilder
|
||||
.setContentIntent(PendingIntent.getActivity(
|
||||
getContext(), (int) System.currentTimeMillis(), explanationIntent, 0
|
||||
))
|
||||
getContext(), (int) System.currentTimeMillis(), explanationIntent, PendingIntent.FLAG_IMMUTABLE
|
||||
))
|
||||
.setContentTitle(i18n(R.string.sync_foreign_files_forgotten_ticker))
|
||||
.setContentText(getQuantityString(
|
||||
R.plurals.sync_foreign_files_forgotten_content,
|
||||
|
||||
@@ -525,7 +525,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.searchType)) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
GalleryFragment photoFragment = new GalleryFragment(true);
|
||||
GalleryFragment photoFragment = new GalleryFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
||||
photoFragment.setArguments(bundle);
|
||||
@@ -2071,7 +2071,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
OCFileListFragment fragment = getListOfFilesFragment();
|
||||
|
||||
if (fragment != null) {
|
||||
if (fragment != null && !(fragment instanceof GalleryFragment)) {
|
||||
fragment.setLoading(true);
|
||||
}
|
||||
|
||||
@@ -2341,7 +2341,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
setLeftFragment(new GalleryFragment(true));
|
||||
setLeftFragment(new GalleryFragment());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
* Copyright (C) 2016 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.ui.activity;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ManageSpaceActivity extends AppCompatActivity implements Injectable {
|
||||
|
||||
private static final String TAG = ManageSpaceActivity.class.getSimpleName();
|
||||
private static final String LIB_FOLDER = "lib";
|
||||
|
||||
@Inject AppPreferences preferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_space);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setTitle(R.string.manage_space_title);
|
||||
}
|
||||
|
||||
TextView descriptionTextView = findViewById(R.id.general_description);
|
||||
descriptionTextView.setText(getString(R.string.manage_space_description, getString(R.string.app_name)));
|
||||
|
||||
Button clearDataButton = findViewById(R.id.clearDataButton);
|
||||
clearDataButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ClearDataAsyncTask clearDataTask = new ClearDataAsyncTask();
|
||||
clearDataTask.execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
Log_OC.w(TAG, "Unknown menu item triggered");
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* AsyncTask for Clear Data, saving the passcode
|
||||
*/
|
||||
private class ClearDataAsyncTask extends AsyncTask<Void, Void, Boolean>{
|
||||
|
||||
private final AppPreferences preferences = ManageSpaceActivity.this.preferences;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
|
||||
String lockPref = preferences.getLockPreference();
|
||||
boolean passCodeEnable = SettingsActivity.LOCK_PASSCODE.equals(lockPref);
|
||||
|
||||
String passCodeDigits[] = new String[4];
|
||||
if (passCodeEnable) {
|
||||
passCodeDigits = preferences.getPassCode();
|
||||
}
|
||||
|
||||
// Clear data
|
||||
preferences.clear();
|
||||
boolean result = clearApplicationData();
|
||||
|
||||
// Recover passcode
|
||||
if (passCodeEnable) {
|
||||
preferences.setPassCode(
|
||||
passCodeDigits[0],
|
||||
passCodeDigits[1],
|
||||
passCodeDigits[2],
|
||||
passCodeDigits[3]
|
||||
);
|
||||
}
|
||||
|
||||
preferences.setLockPreference(lockPref);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
super.onPostExecute(result);
|
||||
if (!result) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
R.string.manage_space_clear_data,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean clearApplicationData() {
|
||||
boolean clearResult = true;
|
||||
File appDir = new File(getCacheDir().getParent());
|
||||
if (appDir.exists()) {
|
||||
String[] children = appDir.list();
|
||||
if (children != null) {
|
||||
for (String s : children) {
|
||||
if (!LIB_FOLDER.equals(s)) {
|
||||
File fileToDelete = new File(appDir, s);
|
||||
clearResult = clearResult && deleteDir(fileToDelete);
|
||||
Log_OC.d(TAG, "Clear Application Data, File: " + fileToDelete.getName() + " DELETED *****");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clearResult = false;
|
||||
}
|
||||
}
|
||||
return clearResult;
|
||||
}
|
||||
|
||||
public boolean deleteDir(File dir) {
|
||||
if (dir != null && dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
if (children != null) {
|
||||
for (String child : children) {
|
||||
boolean success = deleteDir(new File(dir, child));
|
||||
if (!success) {
|
||||
Log_OC.w(TAG, "File NOT deleted " + child);
|
||||
return false;
|
||||
} else {
|
||||
Log_OC.d(TAG, "File deleted " + child);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (dir != null) {
|
||||
return dir.delete();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
* Copyright (C) 2016 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.ui.activity
|
||||
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class ManageSpaceActivity : AppCompatActivity(), Injectable {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: AppPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var userAccountManager: UserAccountManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manage_space)
|
||||
val actionBar = supportActionBar
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.setTitle(R.string.manage_space_title)
|
||||
}
|
||||
val descriptionTextView = findViewById<TextView>(R.id.general_description)
|
||||
descriptionTextView.text = getString(R.string.manage_space_description, getString(R.string.app_name))
|
||||
val clearDataButton = findViewById<Button>(R.id.clearDataButton)
|
||||
clearDataButton.setOnClickListener {
|
||||
val clearDataTask = ClearDataAsyncTask()
|
||||
clearDataTask.execute()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
var retval = true
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> finish()
|
||||
else -> {
|
||||
Log_OC.w(TAG, "Unknown menu item triggered")
|
||||
retval = super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
return retval
|
||||
}
|
||||
|
||||
/**
|
||||
* AsyncTask for Clear Data, saving the passcode
|
||||
*/
|
||||
private inner class ClearDataAsyncTask : AsyncTask<Void, Void, Boolean>() {
|
||||
private val preferences = this@ManageSpaceActivity.preferences
|
||||
private val userAccountManager = this@ManageSpaceActivity.userAccountManager
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
override fun doInBackground(vararg params: Void): Boolean {
|
||||
val lockPref = preferences.lockPreference
|
||||
val passCodeEnable = SettingsActivity.LOCK_PASSCODE == lockPref
|
||||
var passCodeDigits = arrayOfNulls<String>(4)
|
||||
if (passCodeEnable) {
|
||||
passCodeDigits = preferences.passCode
|
||||
}
|
||||
|
||||
// Clear data
|
||||
preferences.clear()
|
||||
val result = clearApplicationData()
|
||||
|
||||
// Recover passcode
|
||||
if (passCodeEnable) {
|
||||
preferences.setPassCode(
|
||||
passCodeDigits[0],
|
||||
passCodeDigits[1],
|
||||
passCodeDigits[2],
|
||||
passCodeDigits[3]
|
||||
)
|
||||
}
|
||||
preferences.lockPreference = lockPref
|
||||
userAccountManager.removeAllAccounts()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Boolean) {
|
||||
super.onPostExecute(result)
|
||||
if (!result) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
R.string.manage_space_clear_data,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
} else {
|
||||
finishAndRemoveTask()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearApplicationData(): Boolean {
|
||||
var clearResult = true
|
||||
val appDir = File(cacheDir.parent!!)
|
||||
if (appDir.exists()) {
|
||||
val children = appDir.list()
|
||||
if (children != null) {
|
||||
children.filter { it != LIB_FOLDER }.forEach { s ->
|
||||
val fileToDelete = File(appDir, s)
|
||||
clearResult = clearResult && deleteDir(fileToDelete)
|
||||
Log_OC.d(TAG, "Clear Application Data, File: " + fileToDelete.name + " DELETED *****")
|
||||
}
|
||||
} else {
|
||||
clearResult = false
|
||||
}
|
||||
}
|
||||
return clearResult
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
fun deleteDir(dir: File?): Boolean {
|
||||
if (dir != null && dir.isDirectory) {
|
||||
dir.list()?.forEach { child ->
|
||||
val success = deleteDir(File(dir, child))
|
||||
if (!success) {
|
||||
Log_OC.w(TAG, "File NOT deleted $child")
|
||||
return false
|
||||
} else {
|
||||
Log_OC.d(TAG, "File deleted $child")
|
||||
}
|
||||
} ?: return false
|
||||
}
|
||||
return dir?.delete() ?: false
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = ManageSpaceActivity::class.java.simpleName
|
||||
private const val LIB_FOLDER = "lib"
|
||||
}
|
||||
}
|
||||
@@ -141,8 +141,8 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||
binding.header.setText(R.string.pass_code_configure_your_pass_code);
|
||||
|
||||
binding.explanation.setVisibility(View.VISIBLE);
|
||||
setCancelButtonEnabled(true);
|
||||
}
|
||||
setCancelButtonEnabled(true);
|
||||
|
||||
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
|
||||
// pass code preference has just been disabled in SettingsActivity;
|
||||
|
||||
@@ -359,7 +359,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
}
|
||||
}
|
||||
|
||||
LayoutInflater layout = LayoutInflater.from(requireContext());
|
||||
LayoutInflater layout = getLayoutInflater();
|
||||
View view = layout.inflate(R.layout.upload_file_dialog, null);
|
||||
|
||||
ArrayAdapter<String> adapter
|
||||
|
||||
@@ -23,6 +23,8 @@ package com.owncloud.android.ui.adapter;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -49,6 +51,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -79,9 +82,10 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
this.preferences = preferences;
|
||||
mContext = context;
|
||||
mLocalFolderPicker = localFolderPickerMode;
|
||||
swapDirectory(directory);
|
||||
this.localFileListFragmentInterface = localFileListFragmentInterface;
|
||||
checkedFiles = new HashSet<>();
|
||||
|
||||
swapDirectory(directory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,39 +317,58 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
* @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
|
||||
*/
|
||||
public void swapDirectory(final File directory) {
|
||||
if (mLocalFolderPicker) {
|
||||
localFileListFragmentInterface.setLoading(true);
|
||||
final Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
List<File> fileList;
|
||||
if (directory == null) {
|
||||
mFiles.clear();
|
||||
fileList = new ArrayList<>();
|
||||
} else {
|
||||
mFiles = getFolders(directory);
|
||||
if (mLocalFolderPicker) {
|
||||
fileList = getFolders(directory);
|
||||
} else {
|
||||
fileList = getFiles(directory);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (directory == null) {
|
||||
mFiles.clear();
|
||||
} else {
|
||||
mFiles = getFiles(directory);
|
||||
|
||||
if (!fileList.isEmpty()) {
|
||||
FileSortOrder sortOrder = preferences.getSortOrderByType(FileSortOrder.Type.localFileListView);
|
||||
fileList = sortOrder.sortLocalFiles(fileList);
|
||||
|
||||
// Fetch preferences for showing hidden files
|
||||
boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
|
||||
if (!showHiddenFiles) {
|
||||
fileList = filterHiddenFiles(fileList);
|
||||
}
|
||||
}
|
||||
}
|
||||
final List<File> newFiles = fileList;
|
||||
|
||||
FileSortOrder sortOrder = preferences.getSortOrderByType(FileSortOrder.Type.localFileListView);
|
||||
mFiles = sortOrder.sortLocalFiles(mFiles);
|
||||
uiHandler.post(() -> {
|
||||
mFiles = newFiles;
|
||||
mFilesAll = new ArrayList<>();
|
||||
mFilesAll.addAll(mFiles);
|
||||
|
||||
// Fetch preferences for showing hidden files
|
||||
boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
|
||||
if (!showHiddenFiles) {
|
||||
mFiles = filterHiddenFiles(mFiles);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
localFileListFragmentInterface.setLoading(false);
|
||||
});
|
||||
});
|
||||
|
||||
mFilesAll.clear();
|
||||
mFilesAll.addAll(mFiles);
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setSortOrder(FileSortOrder sortOrder) {
|
||||
preferences.setSortOrder(FileSortOrder.Type.localFileListView, sortOrder);
|
||||
mFiles = sortOrder.sortLocalFiles(mFiles);
|
||||
notifyDataSetChanged();
|
||||
localFileListFragmentInterface.setLoading(true);
|
||||
final Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
preferences.setSortOrder(FileSortOrder.Type.localFileListView, sortOrder);
|
||||
mFiles = sortOrder.sortLocalFiles(mFiles);
|
||||
|
||||
uiHandler.post(() -> {
|
||||
notifyDataSetChanged();
|
||||
localFileListFragmentInterface.setLoading(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<File> getFolders(final File directory) {
|
||||
|
||||
@@ -153,7 +153,6 @@ public class ExtendedListFragment extends Fragment implements
|
||||
FAVORITE_SEARCH,
|
||||
GALLERY_SEARCH,
|
||||
RECENTLY_MODIFIED_SEARCH,
|
||||
RECENTLY_ADDED_SEARCH,
|
||||
// not a real filter, but nevertheless
|
||||
SHARED_FILTER
|
||||
}
|
||||
@@ -673,10 +672,6 @@ public class ExtendedListFragment extends Fragment implements
|
||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||
R.string.file_list_empty_recently_modified,
|
||||
R.drawable.ic_list_empty_recent);
|
||||
} else if (searchType == SearchType.RECENTLY_ADDED_SEARCH) {
|
||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||
R.string.file_list_empty_recently_added,
|
||||
R.drawable.ic_list_empty_recent);
|
||||
} else if (searchType == SearchType.REGULAR_FILTER) {
|
||||
setMessageForEmptyList(R.string.file_list_empty_headline_search,
|
||||
R.string.file_list_empty_search,
|
||||
|
||||
@@ -54,27 +54,25 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
private SearchEvent searchEvent;
|
||||
private boolean refresh;
|
||||
|
||||
public GalleryFragment() {
|
||||
this.refresh = false;
|
||||
}
|
||||
private void createOperation() {
|
||||
if(searchEvent == null) {
|
||||
searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
if(searchRemoteOperation == null) {
|
||||
OCCapability ocCapability = mContainerActivity.getStorageManager()
|
||||
.getCapability(accountManager.getUser().getAccountName());
|
||||
|
||||
public GalleryFragment(boolean refresh) {
|
||||
this.refresh = refresh;
|
||||
searchRemoteOperation = new SearchRemoteOperation(searchEvent.getSearchQuery(),
|
||||
searchEvent.getSearchType(),
|
||||
false,
|
||||
ocCapability);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.GALLERY_SEARCH);
|
||||
|
||||
OCCapability ocCapability = mContainerActivity.getStorageManager()
|
||||
.getCapability(accountManager.getUser().getAccountName());
|
||||
|
||||
searchRemoteOperation = new SearchRemoteOperation(searchEvent.getSearchQuery(),
|
||||
searchEvent.getSearchType(),
|
||||
false,
|
||||
ocCapability);
|
||||
refresh = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +89,7 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
createOperation();
|
||||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
getRecyclerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@@ -126,6 +125,12 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setLoading(photoSearchQueryRunning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageEvent(ChangeMenuEvent changeMenuEvent) {
|
||||
super.onMessageEvent(changeMenuEvent);
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -367,6 +368,22 @@ public class LocalFileListFragment extends ExtendedListFragment implements
|
||||
super.switchToListView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoading(boolean enabled) {
|
||||
super.setLoading(enabled);
|
||||
if (enabled) {
|
||||
setEmptyListLoadingMessage();
|
||||
} else {
|
||||
// ugly hack because setEmptyListLoadingMessage also uses a handler and there's a race condition otherwise
|
||||
new Handler().post(() -> {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
if(mAdapter.getFilesCount() == 0){
|
||||
setEmptyListMessage(SearchType.NO_SEARCH);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to implement by any Activity that includes some instance of LocalFileListFragment
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,7 @@ import com.nextcloud.client.device.DeviceInfo;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.utils.Throttler;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -101,7 +102,6 @@ import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.nextcloud.client.utils.Throttler;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeFabUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
@@ -240,6 +240,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
if (intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
|
||||
searchEvent = Parcels.unwrap(intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
|
||||
}
|
||||
|
||||
if (isSearchEventSet(searchEvent)) {
|
||||
handleSearchEvent(searchEvent);
|
||||
}
|
||||
|
||||
@@ -1376,9 +1379,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
case GALLERY_SEARCH:
|
||||
setTitle(R.string.drawer_item_gallery);
|
||||
break;
|
||||
case RECENTLY_ADDED_SEARCH:
|
||||
setTitle(R.string.drawer_item_recently_added);
|
||||
break;
|
||||
case RECENTLY_MODIFIED_SEARCH:
|
||||
setTitle(R.string.drawer_item_recently_modified);
|
||||
break;
|
||||
@@ -1397,9 +1397,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
if (event != null) {
|
||||
switch (event.getSearchType()) {
|
||||
case FAVORITE_SEARCH:
|
||||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
|
||||
break;
|
||||
|
||||
case RECENTLY_MODIFIED_SEARCH:
|
||||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
|
||||
break;
|
||||
@@ -1479,6 +1476,15 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
|
||||
super.onViewStateRestored(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
searchEvent = Parcels.unwrap(savedInstanceState.getParcelable(SEARCH_EVENT));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onMessageEvent(final SearchEvent event) {
|
||||
handleSearchEvent(event);
|
||||
@@ -1717,7 +1723,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
(!TextUtils.isEmpty(event.getSearchQuery()) ||
|
||||
event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH ||
|
||||
event.searchType == SearchRemoteOperation.SearchType.SHARED_FILTER ||
|
||||
event.searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH);
|
||||
event.searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH ||
|
||||
event.searchType == SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH);
|
||||
}
|
||||
|
||||
private void syncAndCheckFiles(Collection<OCFile> files) {
|
||||
|
||||
@@ -32,4 +32,5 @@ public interface LocalFileListFragmentInterface {
|
||||
int getColumnsCount();
|
||||
void onItemClicked(File file);
|
||||
void onItemCheckboxClicked(File file);
|
||||
void setLoading(boolean loading);
|
||||
}
|
||||
@@ -46,10 +46,6 @@ public final class DrawerMenuUtil {
|
||||
filterMenuItems(menu, R.id.nav_gallery, R.id.nav_favorites);
|
||||
}
|
||||
|
||||
if (!resources.getBoolean(R.bool.recently_added_enabled)) {
|
||||
menu.removeItem(R.id.nav_recently_added);
|
||||
}
|
||||
|
||||
if (!resources.getBoolean(R.bool.recently_modified_enabled)) {
|
||||
menu.removeItem(R.id.nav_recently_modified);
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Sort order
|
||||
*/
|
||||
|
||||
public class FileSortOrder {
|
||||
public static final String sort_a_to_z_id = "sort_a_to_z";
|
||||
public static final String sort_z_to_a_id = "sort_z_to_a";
|
||||
public static final String sort_old_to_new_id = "sort_old_to_new";
|
||||
public static final String sort_new_to_old_id = "sort_new_to_old";
|
||||
public static final String sort_small_to_big_id = "sort_small_to_big";
|
||||
public static final String sort_big_to_small_id = "sort_big_to_small";
|
||||
|
||||
public static final FileSortOrder sort_a_to_z = new FileSortOrderByName(sort_a_to_z_id, true);
|
||||
public static final FileSortOrder sort_z_to_a = new FileSortOrderByName(sort_z_to_a_id, false);
|
||||
public static final FileSortOrder sort_old_to_new = new FileSortOrderByDate(sort_old_to_new_id, true);
|
||||
public static final FileSortOrder sort_new_to_old = new FileSortOrderByDate(sort_new_to_old_id, false);
|
||||
public static final FileSortOrder sort_small_to_big = new FileSortOrderBySize(sort_small_to_big_id, true);
|
||||
public static final FileSortOrder sort_big_to_small = new FileSortOrderBySize(sort_big_to_small_id, false);
|
||||
|
||||
public static final Map<String, FileSortOrder> sortOrders;
|
||||
|
||||
public enum Type {
|
||||
trashBinView, localFileListView
|
||||
}
|
||||
static {
|
||||
HashMap<String, FileSortOrder> temp = new HashMap<>();
|
||||
temp.put(sort_a_to_z.name, sort_a_to_z);
|
||||
temp.put(sort_z_to_a.name, sort_z_to_a);
|
||||
temp.put(sort_old_to_new.name, sort_old_to_new);
|
||||
temp.put(sort_new_to_old.name, sort_new_to_old);
|
||||
temp.put(sort_small_to_big.name, sort_small_to_big);
|
||||
temp.put(sort_big_to_small.name, sort_big_to_small);
|
||||
|
||||
sortOrders = Collections.unmodifiableMap(temp);
|
||||
}
|
||||
|
||||
public String name;
|
||||
public boolean isAscending;
|
||||
|
||||
public FileSortOrder(String name, boolean ascending) {
|
||||
this.name = name;
|
||||
isAscending = ascending;
|
||||
}
|
||||
|
||||
public List<OCFile> sortCloudFiles(List<OCFile> files) {
|
||||
return sortCloudFilesByFavourite(files);
|
||||
}
|
||||
|
||||
public List<File> sortLocalFiles(List<File> files) {
|
||||
return files;
|
||||
}
|
||||
|
||||
public List<TrashbinFile> sortTrashbinFiles(List<TrashbinFile> files) {
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Favourites.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
public static List<OCFile> sortCloudFilesByFavourite(List<OCFile> files) {
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isFavorite() && o2.isFavorite()) {
|
||||
return 0;
|
||||
} else if (o1.isFavorite()) {
|
||||
return -1;
|
||||
} else if (o2.isFavorite()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
import java.util.Collections
|
||||
|
||||
/**
|
||||
* Sort order
|
||||
*/
|
||||
open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) {
|
||||
|
||||
val sortMultiplier: Int
|
||||
get() = if (isAscending) 1 else -1
|
||||
|
||||
@Suppress("EnumNaming") // already saved in user preferences -.-'
|
||||
enum class Type {
|
||||
trashBinView, localFileListView
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val sort_a_to_z_id = "sort_a_to_z"
|
||||
const val sort_z_to_a_id = "sort_z_to_a"
|
||||
const val sort_old_to_new_id = "sort_old_to_new"
|
||||
const val sort_new_to_old_id = "sort_new_to_old"
|
||||
const val sort_small_to_big_id = "sort_small_to_big"
|
||||
const val sort_big_to_small_id = "sort_big_to_small"
|
||||
|
||||
@JvmField
|
||||
val sort_a_to_z: FileSortOrder = FileSortOrderByName(sort_a_to_z_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_z_to_a: FileSortOrder = FileSortOrderByName(sort_z_to_a_id, false)
|
||||
|
||||
@JvmField
|
||||
val sort_old_to_new: FileSortOrder = FileSortOrderByDate(sort_old_to_new_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_new_to_old: FileSortOrder = FileSortOrderByDate(sort_new_to_old_id, false)
|
||||
|
||||
@JvmField
|
||||
val sort_small_to_big: FileSortOrder = FileSortOrderBySize(sort_small_to_big_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_big_to_small: FileSortOrder = FileSortOrderBySize(sort_big_to_small_id, false)
|
||||
|
||||
@JvmField
|
||||
val sortOrders: Map<String, FileSortOrder> = Collections.unmodifiableMap(
|
||||
mapOf(
|
||||
sort_a_to_z.name to sort_a_to_z,
|
||||
sort_z_to_a.name to sort_z_to_a,
|
||||
sort_old_to_new.name to sort_old_to_new,
|
||||
sort_new_to_old.name to sort_new_to_old,
|
||||
sort_small_to_big.name to sort_small_to_big,
|
||||
sort_big_to_small.name to sort_big_to_small
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Sorts list by Favourites.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@JvmStatic
|
||||
fun sortCloudFilesByFavourite(files: MutableList<OCFile>): List<OCFile> {
|
||||
files.sortWith { o1: OCFile, o2: OCFile ->
|
||||
when {
|
||||
o1.isFavorite && o2.isFavorite -> 0
|
||||
o1.isFavorite -> -1
|
||||
o2.isFavorite -> 1
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
|
||||
open fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
return sortCloudFilesByFavourite(files)
|
||||
}
|
||||
|
||||
open fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
return files
|
||||
}
|
||||
|
||||
open fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
public class FileSortOrderByDate extends FileSortOrder {
|
||||
|
||||
FileSortOrderByDate(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
public List<OCFile> sortCloudFiles(List<OCFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) ->
|
||||
multiplier * Long.compare(o1.getModificationTimestamp(), o2.getModificationTimestamp()));
|
||||
|
||||
return super.sortCloudFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
@Override
|
||||
public List<TrashbinFile> sortTrashbinFiles(List<TrashbinFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
return multiplier * Long.compare(o1.getDeletionTimestamp(),o2.getDeletionTimestamp());
|
||||
});
|
||||
|
||||
return super.sortTrashbinFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
@Override
|
||||
public List<File> sortLocalFiles(List<File> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> multiplier * Long.compare(o1.lastModified(),o2.lastModified()));
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
class FileSortOrderByDate(name: String, ascending: Boolean) : FileSortOrder(name, ascending) {
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: OCFile, o2: OCFile ->
|
||||
multiplier * o1.modificationTimestamp.compareTo(o2.modificationTimestamp)
|
||||
}
|
||||
return super.sortCloudFiles(files)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: TrashbinFile, o2: TrashbinFile ->
|
||||
multiplier * o1.deletionTimestamp.compareTo(o2.deletionTimestamp)
|
||||
}
|
||||
return super.sortTrashbinFiles(files)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
multiplier * o1.lastModified().compareTo(o2.lastModified())
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import third_parties.daveKoeller.AlphanumComparator;
|
||||
|
||||
/**
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
public class FileSortOrderByName extends FileSortOrder {
|
||||
|
||||
FileSortOrderByName(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@SuppressFBWarnings("Bx")
|
||||
public List<OCFile> sortCloudFiles(List<OCFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
return multiplier * new AlphanumComparator().compare(o1, o2);
|
||||
} else if (o1.isFolder()) {
|
||||
return -1;
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
}
|
||||
return multiplier * new AlphanumComparator().compare(o1, o2);
|
||||
});
|
||||
|
||||
return super.sortCloudFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@SuppressFBWarnings("Bx")
|
||||
@Override
|
||||
public List<TrashbinFile> sortTrashbinFiles(List<TrashbinFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
return multiplier * new AlphanumComparator().compare(o1, o2);
|
||||
} else if (o1.isFolder()) {
|
||||
return -1;
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
}
|
||||
return multiplier * new AlphanumComparator().compare(o1, o2);
|
||||
});
|
||||
|
||||
return super.sortTrashbinFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@Override
|
||||
public List<File> sortLocalFiles(List<File> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isDirectory() && o2.isDirectory()) {
|
||||
return multiplier * o1.getPath().toLowerCase(Locale.getDefault())
|
||||
.compareTo(o2.getPath().toLowerCase(Locale.getDefault()));
|
||||
} else if (o1.isDirectory()) {
|
||||
return -1;
|
||||
} else if (o2.isDirectory()) {
|
||||
return 1;
|
||||
}
|
||||
return multiplier * new AlphanumComparator().compare(o1.getPath()
|
||||
.toLowerCase(Locale.getDefault()),
|
||||
o2.getPath().toLowerCase(Locale.getDefault()));
|
||||
});
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
|
||||
import third_parties.daveKoeller.AlphanumComparator
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
class FileSortOrderByName internal constructor(name: String?, ascending: Boolean) : FileSortOrder(name!!, ascending) {
|
||||
/**
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@SuppressFBWarnings("Bx")
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val sortedByName = sortServerFiles(files)
|
||||
return super.sortCloudFiles(sortedByName)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val sortedByName = sortServerFiles(files)
|
||||
return super.sortTrashbinFiles(sortedByName)
|
||||
}
|
||||
|
||||
private fun <T : ServerFileInterface> sortServerFiles(files: MutableList<T>): MutableList<T> {
|
||||
files.sortWith { o1: ServerFileInterface, o2: ServerFileInterface ->
|
||||
when {
|
||||
o1.isFolder && o2.isFolder -> sortMultiplier * AlphanumComparator.compare(o1, o2)
|
||||
o1.isFolder -> -1
|
||||
o2.isFolder -> 1
|
||||
else -> sortMultiplier * AlphanumComparator.compare(o1, o2)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
when {
|
||||
o1.isDirectory && o2.isDirectory -> sortMultiplier * o1.path.lowercase(Locale.getDefault())
|
||||
.compareTo(o2.path.lowercase(Locale.getDefault()))
|
||||
o1.isDirectory -> -1
|
||||
o2.isDirectory -> 1
|
||||
else -> sortMultiplier * AlphanumComparator.compare(
|
||||
o1.path.lowercase(Locale.getDefault()),
|
||||
o2.path.lowercase(Locale.getDefault())
|
||||
)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Sorts files by sizes
|
||||
*/
|
||||
public class FileSortOrderBySize extends FileSortOrder {
|
||||
|
||||
FileSortOrderBySize(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Size.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
public List<OCFile> sortCloudFiles(List<OCFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
return multiplier * Long.compare(o1.getFileLength(), o2.getFileLength());
|
||||
} else if (o1.isFolder()) {
|
||||
return -1;
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
} else {
|
||||
return multiplier * Long.compare(o1.getFileLength(),o2.getFileLength());
|
||||
}
|
||||
});
|
||||
|
||||
return super.sortCloudFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Size.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
@Override
|
||||
public List<TrashbinFile> sortTrashbinFiles(List<TrashbinFile> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
return multiplier * Long.compare(o1.getFileLength(), o2.getFileLength());
|
||||
} else if (o1.isFolder()) {
|
||||
return -1;
|
||||
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
} else {
|
||||
return multiplier * Long.compare(o1.getFileLength(),o2.getFileLength());
|
||||
}
|
||||
});
|
||||
|
||||
return super.sortTrashbinFiles(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Size.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
@Override
|
||||
public List<File> sortLocalFiles(List<File> files) {
|
||||
final int multiplier = isAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
if (o1.isDirectory() && o2.isDirectory()) {
|
||||
return multiplier * Long.compare(FileStorageUtils.getFolderSize(o1),
|
||||
FileStorageUtils.getFolderSize(o2));
|
||||
} else if (o1.isDirectory()) {
|
||||
return -1;
|
||||
} else if (o2.isDirectory()) {
|
||||
return 1;
|
||||
} else {
|
||||
return multiplier * Long.compare(o1.length(),o2.length());
|
||||
}
|
||||
});
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Sorts files by sizes
|
||||
*/
|
||||
class FileSortOrderBySize internal constructor(name: String?, ascending: Boolean) : FileSortOrder(name!!, ascending) {
|
||||
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val sortedBySize = sortServerFiles(files)
|
||||
return super.sortCloudFiles(sortedBySize)
|
||||
}
|
||||
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val sortedBySize = sortServerFiles(files)
|
||||
return super.sortTrashbinFiles(sortedBySize)
|
||||
}
|
||||
|
||||
private fun <T : ServerFileInterface> sortServerFiles(files: MutableList<T>): MutableList<T> {
|
||||
files.sortWith { o1: ServerFileInterface, o2: ServerFileInterface ->
|
||||
when {
|
||||
o1.isFolder && o2.isFolder -> sortMultiplier * o1.fileLength.compareTo(o2.fileLength)
|
||||
o1.isFolder -> -1
|
||||
o2.isFolder -> 1
|
||||
else -> sortMultiplier * o1.fileLength.compareTo(o2.fileLength)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
when {
|
||||
o1.isDirectory && o2.isDirectory -> sortMultiplier * FileStorageUtils.getFolderSize(o1)
|
||||
.compareTo(FileStorageUtils.getFolderSize(o2))
|
||||
o1.isDirectory -> -1
|
||||
o2.isDirectory -> 1
|
||||
else -> sortMultiplier * o1.length().compareTo(o2.length())
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,18 @@ import java.util.Comparator;
|
||||
* by Tobias Kaminsky
|
||||
*/
|
||||
public class AlphanumComparator<T> implements Comparator<T>, Serializable {
|
||||
private boolean isDigit(char ch) {
|
||||
private static boolean isDigit(char ch) {
|
||||
return ch >= 48 && ch <= 57;
|
||||
}
|
||||
|
||||
private boolean isSpecialChar(char ch) {
|
||||
private static boolean isSpecialChar(char ch) {
|
||||
return ch <= 47 || ch >= 58 && ch <= 64 || ch >= 91 && ch <= 96 || ch >= 123 && ch <= 126;
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of string is passed in for improved efficiency (only need to calculate it once)
|
||||
**/
|
||||
private String getChunk(String string, int stringLength, int marker) {
|
||||
private static String getChunk(String string, int stringLength, int marker) {
|
||||
StringBuilder chunk = new StringBuilder();
|
||||
char c = string.charAt(marker);
|
||||
chunk.append(c);
|
||||
@@ -87,14 +87,14 @@ public class AlphanumComparator<T> implements Comparator<T>, Serializable {
|
||||
return chunk.toString();
|
||||
}
|
||||
|
||||
public int compare(ServerFileInterface o1, ServerFileInterface o2) {
|
||||
public static int compare(ServerFileInterface o1, ServerFileInterface o2) {
|
||||
String s1 = o1.getFileName();
|
||||
String s2 = o2.getFileName();
|
||||
|
||||
return compare(s1, s2);
|
||||
}
|
||||
|
||||
public int compare(File f1, File f2) {
|
||||
public static int compare(File f1, File f2) {
|
||||
String s1 = f1.getPath();
|
||||
String s2 = f2.getPath();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class AlphanumComparator<T> implements Comparator<T>, Serializable {
|
||||
return compare(t1.toString(), t2.toString());
|
||||
}
|
||||
|
||||
public int compare(String s1, String s2) {
|
||||
public static int compare(String s1, String s2) {
|
||||
int thisMarker = 0;
|
||||
int thatMarker = 0;
|
||||
int s1Length = s1.length();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package third_parties.ezvcard_android;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@@ -474,6 +475,7 @@ public class ContactOperations {
|
||||
}
|
||||
|
||||
private void convertBirthdays(List<NonEmptyContentValues> contentValues, VCard vcard) {
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Birthday birthday : vcard.getBirthdays()) {
|
||||
Date date = birthday.getDate();
|
||||
|
||||
@@ -53,18 +53,12 @@
|
||||
android:icon="@drawable/nav_on_device"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/drawer_item_on_device"/>
|
||||
<item
|
||||
android:id="@+id/nav_recently_added"
|
||||
android:icon="@drawable/nav_recently"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/drawer_item_recently_added"
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@+id/nav_recently_modified"
|
||||
android:icon="@drawable/nav_recently"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/drawer_item_recently_modified"
|
||||
android:visible="false"/>
|
||||
android:visible="true"/>
|
||||
<item
|
||||
android:orderInCategory="0"
|
||||
android:id="@+id/nav_notifications"
|
||||
|
||||
@@ -150,8 +150,10 @@
|
||||
<string name="conflict_already_existing_file">Már létező fájl</string>
|
||||
<string name="conflict_dialog_error">Hiba az ütközési párbeszédablak létrehozásakor!</string>
|
||||
<string name="conflict_file_headline">Ütköző fájl: %1$s</string>
|
||||
<string name="conflict_local_file">Helyi fájl</string>
|
||||
<string name="conflict_message_description">Amennyiben mindkét verziót kiválasztja, a helyi fájl nevéhez egy szám lesz hozzáfűzve.</string>
|
||||
<string name="conflict_new_file">Új fájl</string>
|
||||
<string name="conflict_server_file">Kiszolgálón lévő fájl</string>
|
||||
<string name="contactlist_item_icon">Felhasználó ikon a névjegylistához</string>
|
||||
<string name="contactlist_no_permission">Nincs jogosultság megadva, semmi sem lett importálva.</string>
|
||||
<string name="contacts">Névjegyek</string>
|
||||
@@ -459,6 +461,7 @@
|
||||
<string name="no_email_app_available">Nem érhető el alkalmazás a levélcímek kezeléséhez</string>
|
||||
<string name="no_mutliple_accounts_allowed">Csak egy fiók engedélyezett</string>
|
||||
<string name="no_pdf_app_available">Nincs elérhető alkalmazás PDF kezeléséhez</string>
|
||||
<string name="no_send_app">Nem érhető el alkalmazás a kiválasztott fájlok küldéséhez</string>
|
||||
<string name="no_share_permission_selected">Válasszon legalább egy jogosultságot a megosztáshoz.</string>
|
||||
<string name="note_confirm">Küldés</string>
|
||||
<string name="note_could_not_sent">A jegyzet nem küldhető el</string>
|
||||
@@ -547,6 +550,7 @@
|
||||
<string name="prefs_lock_using_device_credentials">Eszközhitelesítő-adatok</string>
|
||||
<string name="prefs_lock_using_passcode">Számkód</string>
|
||||
<string name="prefs_manage_accounts">Fiókok kezelése</string>
|
||||
<string name="prefs_recommend">Ajánlás egy barátnak</string>
|
||||
<string name="prefs_show_hidden_files">Rejtett fájlok megjelenítése</string>
|
||||
<string name="prefs_sourcecode">Forráskód beszerzése</string>
|
||||
<string name="prefs_storage_path">Adattároló mappa</string>
|
||||
|
||||
@@ -461,6 +461,7 @@
|
||||
<string name="no_email_app_available">Nessuna app disponibile per gestire l\'indirizzo email</string>
|
||||
<string name="no_mutliple_accounts_allowed">Solo un account consentito</string>
|
||||
<string name="no_pdf_app_available">Nessun applicazione disponibile per gestire i PDF</string>
|
||||
<string name="no_send_app">Nessuna app disponibile per inviare i file selezionati</string>
|
||||
<string name="no_share_permission_selected">Seleziona almeno un permesso da condividere.</string>
|
||||
<string name="note_confirm">Invia</string>
|
||||
<string name="note_could_not_sent">Impossibile inviare la nota</string>
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<string name="community_release_candidate_text">Release Candidate (RC) jest zwiastunem nadchodzącej nowej wersji, od której oczekuje się, że będzie stabilna. Można to zapewnić poprzez testowanie indywidualnej konfiguracji. Aby przetestować, zarejestruj się w sklepie Play lub zajrzyj do sekcji \"Wersja\" na F-Droid.</string>
|
||||
<string name="community_testing_bug_text">Znalazłeś błąd? Jest coś, co chciałbyś poprawić?</string>
|
||||
<string name="community_testing_headline">Pomóż nam testować</string>
|
||||
<string name="community_testing_report_text">Zgłoś problem na GitHub</string>
|
||||
<string name="community_testing_report_text">Zgłoś problem na GitHubie</string>
|
||||
<string name="community_testing_version_text">Chcesz pomóc nam w testowaniu następnej wersji?</string>
|
||||
<string name="configure_new_media_folder_detection_notifications">Konfiguruj</string>
|
||||
<string name="confirmation_remove_file_alert">Czy na pewno chcesz usunąć %1$s?</string>
|
||||
@@ -218,7 +218,7 @@
|
||||
<string name="drawer_close">Zamknij pasek boczny</string>
|
||||
<string name="drawer_community">Społeczność</string>
|
||||
<string name="drawer_header_background">Tło nagłówka menu rozwijanego</string>
|
||||
<string name="drawer_item_activities">Aktywności</string>
|
||||
<string name="drawer_item_activities">Aktywność</string>
|
||||
<string name="drawer_item_all_files">Wszystkie pliki</string>
|
||||
<string name="drawer_item_favorites">Ulubione</string>
|
||||
<string name="drawer_item_gallery">Media</string>
|
||||
@@ -261,7 +261,7 @@
|
||||
<string name="error_crash_title">%1$s zatrzymany</string>
|
||||
<string name="error_creating_file_from_template">Błąd podczas tworzenia pliku z szablonu</string>
|
||||
<string name="error_report_issue_action">Raport</string>
|
||||
<string name="error_report_issue_text">Chcesz zgłosić problem? (wymaga konta Github)</string>
|
||||
<string name="error_report_issue_text">Chcesz zgłosić problem? (wymaga konta GitHub)</string>
|
||||
<string name="error_retrieving_file">Błąd podczas pobierania pliku</string>
|
||||
<string name="error_retrieving_templates">Błąd podczas pobierania szablonów</string>
|
||||
<string name="error_starting_direct_camera_upload">Błąd podczas uruchamiania kamery</string>
|
||||
|
||||
@@ -461,6 +461,7 @@
|
||||
<string name="no_email_app_available">E-posta adreslerini işleyecek bir uygulama bulunamadı</string>
|
||||
<string name="no_mutliple_accounts_allowed">Yalnız bir hesap kullanılabilir</string>
|
||||
<string name="no_pdf_app_available">PDF dosyalarını işleyecek bir uygulama bulunamadı</string>
|
||||
<string name="no_send_app">Seçilmiş dosyaların gönderilebileceği bir uygulama bulunamadı</string>
|
||||
<string name="no_share_permission_selected">Lütfen paylaşmak için en az bir izin seçin.</string>
|
||||
<string name="note_confirm">Gönder</string>
|
||||
<string name="note_could_not_sent">Not gönderilemedi</string>
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
<bool name="multiaccount_support">true</bool>
|
||||
|
||||
<!-- Drawer options -->
|
||||
<bool name="recently_added_enabled">false</bool>
|
||||
<bool name="recently_modified_enabled">false</bool>
|
||||
<bool name="shared_enabled">true</bool>
|
||||
<bool name="show_drawer_logout">false</bool>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<string name="drawer_item_home">Home</string>
|
||||
<string name="drawer_item_favorites">Favorites</string>
|
||||
<string name="drawer_item_on_device">On device</string>
|
||||
<string name="drawer_item_recently_added">Recently added</string>
|
||||
<string name="drawer_item_recently_modified">Recently modified</string>
|
||||
<string name="drawer_item_shared">Shared</string>
|
||||
<string name="drawer_item_uploads_list">Uploads</string>
|
||||
@@ -100,7 +99,6 @@
|
||||
<string name="file_list_empty_shared">Files and folders you share will show up here.</string>
|
||||
<string name="file_list_empty_search">Maybe it is in a different folder?</string>
|
||||
<string name="file_list_empty_recently_modified">Found no files modified within the last 7 days</string>
|
||||
<string name="file_list_empty_recently_added">Found no recently added files</string>
|
||||
<string name="trashbin_empty_headline">No deleted files</string>
|
||||
<string name="trashbin_empty_message">You will be able to recover deleted files from here.</string>
|
||||
<string name="upload_list_empty_headline">No uploads available</string>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
Update translations
|
||||
Update Nextcloud Android library
|
||||
@@ -0,0 +1,3 @@
|
||||
Bump versions for fastlane and plugins
|
||||
Update Nextcloud Android library
|
||||
Update 3rd-party dependencies
|
||||
@@ -0,0 +1,7 @@
|
||||
Fix default visibility of recently modified
|
||||
Remove recently added search
|
||||
OCFileListFragment: restore search event on view restored
|
||||
OCFileListFragment: add recently modified to the list of valid search events
|
||||
Update translations
|
||||
Update Nextcloud Android library
|
||||
Update 3rd-party dependencies
|
||||
@@ -0,0 +1,9 @@
|
||||
gplay/AndroidManifest: set exported value for service
|
||||
ezvcard/ContactOperations: suppress locale lint in third_party class
|
||||
build.gradle: Disable some translation errors in lint
|
||||
manifest: Remove unneeded labels
|
||||
BackgroundJobFactory: fix lint due to unchecked build version for ContentObserverJob
|
||||
lint: Fix getLayoutInflater calls
|
||||
build.gradle: Run migrations for AGP 7.1.0
|
||||
Update Nextcloud Android library
|
||||
Update 3rd-party dependencies
|
||||
@@ -0,0 +1,15 @@
|
||||
LocalFileListAdapter: fix case where directory==null
|
||||
FileSortOrder*: convert to Kotlin
|
||||
LocalFileListAdapter: Also change sort order asynchronously
|
||||
AlphaNumComparator: optimize usage and resolve signature problems
|
||||
LocalFileList: load local files asynchronously
|
||||
PassCodeActivity: enable cancel button when re-created in confirmation step
|
||||
Make more PendingIntents immutable
|
||||
Make PendingIntents immutable
|
||||
ManageSpaceActivity: convert to Kotlin while we're here
|
||||
ManageSpaceActivity: kill the app after finishing cleanup
|
||||
ManageSpaceActivity: remove user accounts when clearing data
|
||||
GalleryFragment: force refresh on create, prevent unneeded refresh animations
|
||||
GalleryFragment: prevent NPE when recreating fragment
|
||||
Update translations
|
||||
Update 3rd-party dependencies
|
||||
Reference in new issue
Block a user