Compare commits
63
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d09b751bec | ||
|
|
3dbd7d618d | ||
|
|
32b474f3f6 | ||
|
|
381e432cfe | ||
|
|
54b515267c | ||
|
|
5e0bd559af | ||
|
|
ed5668de8a | ||
|
|
9e4b3f9970 | ||
|
|
6b0f2332e0 | ||
|
|
13ea402704 | ||
|
|
76885907cb | ||
|
|
0d7dc9b833 | ||
|
|
cdc6791871 | ||
|
|
885a8e64db | ||
|
|
a0bf64da3c | ||
|
|
269ffb69f5 | ||
|
|
ab5d96b564 | ||
|
|
c0ebadbca2 | ||
|
|
3b9e9c1488 | ||
|
|
10641b850b | ||
|
|
2b1f0e9374 | ||
|
|
6b6a4611de | ||
|
|
b19195b1d2 | ||
|
|
38d1e0698e | ||
|
|
d125252903 | ||
|
|
d9af7e6b81 | ||
|
|
5e4c59a58d | ||
|
|
6801e7813e | ||
|
|
a40dccc943 | ||
|
|
7d3be1a735 | ||
|
|
2c6558f3ed | ||
|
|
6c34f12705 | ||
|
|
49771e8259 | ||
|
|
28e22f060c | ||
|
|
9820090852 | ||
|
|
856a2696f0 | ||
|
|
44506e2b8f | ||
|
|
753974586b | ||
|
|
04e75fba94 | ||
|
|
938e541f0b | ||
|
|
50dfcfa5da | ||
|
|
dc5473f45d | ||
|
|
bac87f20df | ||
|
|
9851ac0d37 | ||
|
|
fced7c976b | ||
|
|
2eec3c7c07 | ||
|
|
c2cf1cc552 | ||
|
|
95dc0344eb | ||
|
|
05afc6c1cf | ||
|
|
83068616f7 | ||
|
|
df1378c093 | ||
|
|
81d8ee6cc7 | ||
|
|
131f9fa8bb | ||
|
|
781f57fc48 | ||
|
|
e92afec910 | ||
|
|
66e5551653 | ||
|
|
c1a4bac83c | ||
|
|
da8ebf8fec | ||
|
|
230b13df73 | ||
|
|
679432a946 | ||
|
|
d15c922c99 | ||
|
|
be73f7b469 | ||
|
|
5c09fe4593 |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:resolute@sha256:513c074113a871b51a8d16ab445c88779d6452d937a164fb5cc479f32668a41d
|
||||
FROM ubuntu:resolute@sha256:da6fc2be547864451aa253836dd926da33623312df4a9a243e35dc877c378a78
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 25
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install python3-defusedxml
|
||||
|
||||
@@ -20,10 +20,6 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: codeql-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
@@ -47,17 +43,18 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
- name: Compile sources
|
||||
run: ./gradlew --no-daemon --no-build-cache :app:compileGplayDebugSources
|
||||
java-version: 25
|
||||
- name: Assemble
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew --no-daemon assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
+10
-10
@@ -1,4 +1,5 @@
|
||||
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
|
||||
# SPDX-License-Identifier: MIT
|
||||
name: "QA"
|
||||
@@ -60,21 +61,21 @@ jobs:
|
||||
./gradlew assembleQaDebug
|
||||
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:"$KS_PASS" --key-pass pass:"$KEY_PASS" --ks-key-alias key0 --ks ".github/workflows/QA_keystore.jks" app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
apk=$(find app/build/outputs/apk/qa/debug -name '*qa-debug*.apk' | head -n1)
|
||||
echo "apk-path=$apk" >> "$GITHUB_OUTPUT"
|
||||
echo "apk-name=$(basename "$apk")" >> "$GITHUB_OUTPUT"
|
||||
echo "apk-size=$(du -h "$apk" | cut -f1)" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "apk-path=$apk"
|
||||
echo "apk-name=$(basename "$apk")"
|
||||
echo "apk-size=$(du -h "$apk" | cut -f1)"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload APK
|
||||
id: upload-apk
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: ${{ steps.build-qa.outputs.apk-path }}
|
||||
if-no-files-found: error
|
||||
path: app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
retention-days: 7
|
||||
archive: false
|
||||
|
||||
- name: Create QR code
|
||||
- name: Create QR Code
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
ARTIFACT_URL: ${{ steps.upload-apk.outputs.artifact-url }}
|
||||
@@ -82,9 +83,8 @@ jobs:
|
||||
sudo apt-get -y install qrencode
|
||||
qrencode -s 8 -o qr.png "$ARTIFACT_URL"
|
||||
|
||||
- name: Upload QR code
|
||||
- name: Upload QR
|
||||
id: upload-qr
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: qr.png
|
||||
@@ -113,4 +113,4 @@ jobs:
|
||||
using your existing install while testing.
|
||||
|
||||
Downloading the file requires a GitHub account, so open this link on the
|
||||
device you want to test on, or transfer the APK to it.
|
||||
device you want to test on, or transfer the APK to it.
|
||||
@@ -42,6 +42,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Your Name <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.client.network
|
||||
|
||||
import at.bitfire.dav4jvm.DavResource
|
||||
import at.bitfire.dav4jvm.Response
|
||||
import at.bitfire.dav4jvm.property.DisplayName
|
||||
import at.bitfire.dav4jvm.property.ResourceType
|
||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||
import com.nextcloud.android.lib.resources.users.UserApi
|
||||
import com.nextcloud.common.OkHttpMethodBase
|
||||
import com.owncloud.android.AbstractIT.nextcloudClient
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import retrofit2.HttpException
|
||||
import retrofit2.Retrofit
|
||||
import java.net.HttpURLConnection
|
||||
|
||||
/**
|
||||
* Showcases Retrofit (OCS/JSON) and dav4jvm (WebDAV) side by side. Both reuse the OkHttpClient of
|
||||
* [nextcloudClient], so TLS, proxy and client-certificate handling stay identical to the existing
|
||||
* `RemoteOperation`s.
|
||||
*/
|
||||
class RetrofitAndDav4jvmIT : AbstractOnServerIT() {
|
||||
@Test
|
||||
fun retrofitFetchesSameUserAsRemoteOperation() {
|
||||
val userApi = buildRetrofit().create(UserApi::class.java)
|
||||
|
||||
val response = userApi.getUser(FORMAT_JSON).execute()
|
||||
|
||||
assertTrue("HTTP ${response.code()}", response.isSuccessful)
|
||||
val user = response.body()?.ocs?.data
|
||||
assertNotNull(user)
|
||||
|
||||
val legacyResult = GetUserInfoRemoteOperation().execute(nextcloudClient)
|
||||
assertTrue(legacyResult.isSuccess)
|
||||
assertEquals(legacyResult.resultData.id, user?.id)
|
||||
assertEquals(legacyResult.resultData.displayName, user?.displayName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun retrofitSuspendFunctionReturnsBodyOrThrowsHttpException() {
|
||||
val userApi = buildRetrofit().create(UserApi::class.java)
|
||||
val unauthorizedApi = buildRetrofit(Credentials.basic(INVALID_LOGIN, INVALID_LOGIN)).create(UserApi::class.java)
|
||||
|
||||
// suspend functions run the call on OkHttp's dispatcher, so no Dispatchers.IO switch is needed
|
||||
val user = runBlocking { userApi.fetchUser(FORMAT_JSON).ocs.data }
|
||||
val error = assertThrows(HttpException::class.java) {
|
||||
runBlocking { unauthorizedApi.fetchUser(FORMAT_JSON) }
|
||||
}
|
||||
|
||||
assertEquals(nextcloudClient.userId, user.id)
|
||||
assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, error.code())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dav4jvmMkColThenPropfindRootListsFolder() {
|
||||
val davHttpClient = buildDavOkHttpClient()
|
||||
val rootUrl = "${nextcloudClient.filesDavUri}/".toHttpUrl()
|
||||
val root = DavResource(davHttpClient, rootUrl)
|
||||
val folder = DavResource(davHttpClient, "$rootUrl$FOLDER_NAME/".toHttpUrl())
|
||||
|
||||
folder.mkCol(xmlBody = null) { }
|
||||
|
||||
val responses = mutableListOf<Pair<Response, Response.HrefRelation>>()
|
||||
root.propfind(DEPTH_ONE, DisplayName.NAME, ResourceType.NAME) { response, relation ->
|
||||
responses += response to relation
|
||||
}
|
||||
|
||||
val self = responses.firstOrNull { (_, relation) -> relation == Response.HrefRelation.SELF }?.first
|
||||
val members = responses.filter { (_, relation) -> relation == Response.HrefRelation.MEMBER }.map { it.first }
|
||||
|
||||
assertTrue(self?.get(ResourceType::class.java)?.types?.contains(ResourceType.COLLECTION) == true)
|
||||
val created = members.firstOrNull { it.hrefName() == FOLDER_NAME }
|
||||
assertNotNull("$FOLDER_NAME missing in PROPFIND result", created)
|
||||
assertTrue(created?.get(ResourceType::class.java)?.types?.contains(ResourceType.COLLECTION) == true)
|
||||
}
|
||||
|
||||
private fun buildRetrofit(credentials: String = nextcloudClient.credentials): Retrofit = Retrofit
|
||||
.Builder()
|
||||
.baseUrl("${nextcloudClient.baseUri}/")
|
||||
.client(authenticatedOkHttpClient(credentials))
|
||||
.addConverterFactory(json.asConverterFactory(JSON_MEDIA_TYPE.toMediaType()))
|
||||
.build()
|
||||
|
||||
private fun authenticatedOkHttpClient(credentials: String): OkHttpClient = nextcloudClient.client
|
||||
.newBuilder()
|
||||
.addInterceptor { chain ->
|
||||
val request =
|
||||
chain
|
||||
.request()
|
||||
.newBuilder()
|
||||
.header(OkHttpMethodBase.AUTHORIZATION, credentials)
|
||||
.header(OkHttpMethodBase.USER_AGENT, OwnCloudClientManagerFactory.getUserAgent())
|
||||
.header(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE)
|
||||
.build()
|
||||
chain.proceed(request)
|
||||
}.build()
|
||||
|
||||
// dav4jvm handles redirects itself and requires the underlying client not to follow them
|
||||
private fun buildDavOkHttpClient(): OkHttpClient = nextcloudClient.client
|
||||
.newBuilder()
|
||||
.followRedirects(false)
|
||||
.addInterceptor { chain ->
|
||||
val request =
|
||||
chain
|
||||
.request()
|
||||
.newBuilder()
|
||||
.header(OkHttpMethodBase.AUTHORIZATION, nextcloudClient.credentials)
|
||||
.header(OkHttpMethodBase.USER_AGENT, OwnCloudClientManagerFactory.getUserAgent())
|
||||
.build()
|
||||
chain.proceed(request)
|
||||
}.build()
|
||||
|
||||
companion object {
|
||||
private const val FORMAT_JSON = "json"
|
||||
private const val JSON_MEDIA_TYPE = "application/json"
|
||||
private const val FOLDER_NAME = "files-dav4jvmShowcase"
|
||||
private const val DEPTH_ONE = 1
|
||||
private const val INVALID_LOGIN = "invalid"
|
||||
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
import com.nextcloud.client.database.entity.toOCUpload
|
||||
import com.nextcloud.client.database.entity.toUploadEntity
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
@@ -188,7 +188,7 @@ class UploadDateTests {
|
||||
minResolution: Long = DateUtils.MINUTE_IN_MILLIS,
|
||||
showFuture: Boolean = false
|
||||
) {
|
||||
val result = DisplayUtils.getRelativeDateTimeString(
|
||||
val result = DisplayTextFormatter.formatRelativeDateTime(
|
||||
context,
|
||||
time,
|
||||
minResolution,
|
||||
|
||||
@@ -1,40 +1,78 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2023 TSI-mc
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nmc.android.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LauncherActivityIT : AbstractIT() {
|
||||
|
||||
private val instrumentation get() = InstrumentationRegistry.getInstrumentation()
|
||||
|
||||
@Test
|
||||
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
|
||||
launchActivity<LauncherActivity>().onActivity { activity ->
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility)
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
}
|
||||
val activity = launchLauncherActivity()
|
||||
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSplashScreenWithTitlesShouldShowTitles() {
|
||||
launchActivity<LauncherActivity>().onActivity { activity ->
|
||||
activity.setSplashTitles("Example", "Cloud")
|
||||
val activity = launchLauncherActivity()
|
||||
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility)
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
instrumentation.runOnMainSync { activity.setSplashTitles("Example", "Cloud") }
|
||||
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSplashScreenWithEmptyTitlesShouldNotDelayNextScreen() {
|
||||
val activity = launchLauncherActivity()
|
||||
|
||||
assertTrue("Splash screen without titles did not open the next screen", activity.awaitFinishing())
|
||||
}
|
||||
|
||||
private fun launchLauncherActivity(): LauncherActivity {
|
||||
val intent = Intent(targetContext, LauncherActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
return instrumentation.startActivitySync(intent) as LauncherActivity
|
||||
}
|
||||
|
||||
private fun LauncherActivity.awaitFinishing(): Boolean {
|
||||
val deadline = SystemClock.uptimeMillis() + FINISH_TIMEOUT_IN_MILLIS
|
||||
var finishing = false
|
||||
|
||||
while (!finishing && SystemClock.uptimeMillis() < deadline) {
|
||||
instrumentation.runOnMainSync { finishing = isFinishing }
|
||||
|
||||
if (!finishing) {
|
||||
Thread.sleep(FINISH_POLL_INTERVAL_IN_MILLIS)
|
||||
}
|
||||
}
|
||||
|
||||
return finishing
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val FINISH_TIMEOUT_IN_MILLIS = 5000L
|
||||
private const val FINISH_POLL_INTERVAL_IN_MILLIS = 50L
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2018 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.operations.RenameFileOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests related to file operations.
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FileIT extends AbstractOnServerIT {
|
||||
|
||||
@Test
|
||||
public void testCreateFolder() {
|
||||
String path = "/testFolder/";
|
||||
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext, getStorageManager());
|
||||
RemoteOperationResult result = syncOp.execute(client);
|
||||
|
||||
assertTrue(result.toString(), result.isSuccess());
|
||||
|
||||
// folder exists
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
assertTrue(file.isFolder());
|
||||
|
||||
// cleanup
|
||||
assertTrue(new RemoveFileOperation(file, false, user, false, targetContext, getStorageManager())
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateNonExistingSubFolder() {
|
||||
String path = "/subFolder/1/2/3/4/5/";
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext, getStorageManager());
|
||||
RemoteOperationResult result = syncOp.execute(client);
|
||||
assertTrue(result.toString(), result.isSuccess());
|
||||
|
||||
// folder exists
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
assertTrue(file.isFolder());
|
||||
|
||||
// cleanup
|
||||
new RemoveFileOperation(file,
|
||||
false,
|
||||
user,
|
||||
false,
|
||||
targetContext,
|
||||
getStorageManager())
|
||||
.execute(client);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteIdNull() {
|
||||
getStorageManager().deleteAllFiles();
|
||||
assertEquals(0, getStorageManager().getAllFiles().size());
|
||||
|
||||
OCFile test = new OCFile("/123.txt");
|
||||
getStorageManager().saveFile(test);
|
||||
assertEquals(1, getStorageManager().getAllFiles().size());
|
||||
|
||||
getStorageManager().deleteAllFiles();
|
||||
assertEquals(0, getStorageManager().getAllFiles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameFolder() throws IOException {
|
||||
String folderPath = "/testRenameFolder/";
|
||||
|
||||
// create folder
|
||||
createFolder(folderPath);
|
||||
|
||||
// upload file inside it
|
||||
uploadFile(getDummyFile("nonEmpty.txt"), folderPath + "text.txt");
|
||||
|
||||
// sync folder
|
||||
assertTrue(new SynchronizeFolderOperation(targetContext,
|
||||
folderPath,
|
||||
user,
|
||||
fileDataStorageManager,
|
||||
false,
|
||||
false)
|
||||
.execute(targetContext)
|
||||
.isSuccess());
|
||||
|
||||
// check if file exists
|
||||
String storagePath1 = fileDataStorageManager.getFileByDecryptedRemotePath(folderPath).getStoragePath();
|
||||
assertTrue(new File(storagePath1).exists());
|
||||
|
||||
String storagePath2 = fileDataStorageManager
|
||||
.getFileByDecryptedRemotePath(folderPath + "text.txt")
|
||||
.getStoragePath();
|
||||
assertTrue(new File(storagePath2).exists());
|
||||
|
||||
shortSleep();
|
||||
|
||||
// Rename
|
||||
assertTrue(
|
||||
new RenameFileOperation(folderPath, "test123", fileDataStorageManager)
|
||||
.execute(targetContext)
|
||||
.isSuccess()
|
||||
);
|
||||
|
||||
// after rename check new location
|
||||
assertTrue(
|
||||
new File(fileDataStorageManager.getFileByDecryptedRemotePath("/test123/").getStoragePath())
|
||||
.exists()
|
||||
);
|
||||
assertTrue(
|
||||
new File(fileDataStorageManager.getFileByDecryptedRemotePath("/test123/text.txt").getStoragePath())
|
||||
.exists()
|
||||
);
|
||||
|
||||
// old files do no exist
|
||||
assertNull(fileDataStorageManager.getFileByDecryptedRemotePath(folderPath));
|
||||
assertNull(fileDataStorageManager.getFileByDecryptedRemotePath(folderPath + "text.txt"));
|
||||
|
||||
// local files also do not exist
|
||||
assertFalse(new File(storagePath1).exists());
|
||||
assertFalse(new File(storagePath2).exists());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2018 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.operations.CreateFolderOperation
|
||||
import com.owncloud.android.operations.RenameFileOperation
|
||||
import com.owncloud.android.operations.SynchronizeFolderOperation
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Tests related to file operations.
|
||||
*
|
||||
* Every test starts with an empty server and an empty local database, and [AbstractOnServerIT.after] wipes both again
|
||||
* afterwards, so no test needs to clean up after itself.
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FileIT : AbstractOnServerIT() {
|
||||
|
||||
@Test
|
||||
fun testCreateFolder() {
|
||||
val path = "/testFolder/"
|
||||
assertNull(storageManager.getFileByDecryptedRemotePath(path))
|
||||
createFolderOrFail(path)
|
||||
assertTrue(localFile(path).isFolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCreateNonExistingSubFolder() {
|
||||
val path = "/subFolder/1/2/3/4/5/"
|
||||
assertNull(storageManager.getFileByDecryptedRemotePath(path))
|
||||
createFolderOrFail(path)
|
||||
assertTrue(localFile(path).isFolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemoteIdNull() {
|
||||
storageManager.deleteAllFiles()
|
||||
assertEquals(0, storageManager.allFiles.size)
|
||||
|
||||
storageManager.saveFile(OCFile("/123.txt"))
|
||||
assertEquals(1, storageManager.allFiles.size)
|
||||
|
||||
storageManager.deleteAllFiles()
|
||||
assertEquals(0, storageManager.allFiles.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRenameFolder() {
|
||||
val folderPath = "/testRenameFolder/"
|
||||
val filePath = folderPath + UPLOADED_FILE_NAME
|
||||
val renamedFolderPath = "/$NEW_FOLDER_NAME/"
|
||||
val renamedFilePath = renamedFolderPath + UPLOADED_FILE_NAME
|
||||
|
||||
// the upload creates the parent folder on the server and in the local database
|
||||
uploadFile(getDummyFile(DUMMY_FILE_NAME), filePath)
|
||||
synchronizeFolder(folderPath)
|
||||
|
||||
val folderCopy = localCopyOf(folderPath)
|
||||
val fileCopy = localCopyOf(filePath)
|
||||
assertTrue("$folderPath was not downloaded", folderCopy.exists())
|
||||
assertTrue("$filePath was not downloaded", fileCopy.exists())
|
||||
|
||||
val result = RenameFileOperation(folderPath, NEW_FOLDER_NAME, storageManager).execute(client)
|
||||
assertTrue("Rename of $folderPath failed: ${result.logMessage}", result.isSuccess)
|
||||
|
||||
assertTrue("$renamedFolderPath has no local copy", localCopyOf(renamedFolderPath).exists())
|
||||
assertTrue("$renamedFilePath has no local copy", localCopyOf(renamedFilePath).exists())
|
||||
|
||||
assertNull(storageManager.getFileByDecryptedRemotePath(folderPath))
|
||||
assertNull(storageManager.getFileByDecryptedRemotePath(filePath))
|
||||
|
||||
assertFalse("$folderPath was not moved locally", folderCopy.exists())
|
||||
assertFalse("$filePath was not moved locally", fileCopy.exists())
|
||||
}
|
||||
|
||||
private fun createFolderOrFail(remotePath: String) {
|
||||
val result = CreateFolderOperation(remotePath, user, targetContext, storageManager).execute(client)
|
||||
assertTrue("Creation of $remotePath failed: ${result.logMessage}", result.isSuccess)
|
||||
}
|
||||
|
||||
private fun synchronizeFolder(remotePath: String) {
|
||||
val result = SynchronizeFolderOperation(
|
||||
targetContext,
|
||||
remotePath,
|
||||
user,
|
||||
storageManager,
|
||||
false,
|
||||
false
|
||||
).execute(client)
|
||||
|
||||
assertTrue("Sync of $remotePath failed: ${result.logMessage}", result.isSuccess)
|
||||
}
|
||||
|
||||
private fun localFile(remotePath: String): OCFile {
|
||||
val file = storageManager.getFileByDecryptedRemotePath(remotePath)
|
||||
assertNotNull("$remotePath is missing from the local database", file)
|
||||
return file!!
|
||||
}
|
||||
|
||||
private fun localCopyOf(remotePath: String): File {
|
||||
val storagePath = localFile(remotePath).storagePath
|
||||
assertFalse("$remotePath has no storage path", storagePath.isNullOrEmpty())
|
||||
return File(storagePath)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DUMMY_FILE_NAME = "nonEmpty.txt"
|
||||
private const val UPLOADED_FILE_NAME = "text.txt"
|
||||
private const val NEW_FOLDER_NAME = "test123"
|
||||
}
|
||||
}
|
||||
@@ -612,7 +612,8 @@ class DialogFragmentIT : AbstractIT() {
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
fda.viewThemeUtils,
|
||||
fda.avatarGenerator
|
||||
)
|
||||
sut.show()
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.model.OCUploadLocalPathData
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.ActivityEditImageBinding
|
||||
@@ -31,7 +32,6 @@ import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.FileActivity
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import java.io.File
|
||||
|
||||
@@ -87,7 +87,7 @@ class EditImageActivity :
|
||||
|
||||
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
||||
if (!result.isSuccessful) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.image_editor_unable_to_edit_image))
|
||||
SnackbarUtil.show(this, getString(R.string.image_editor_unable_to_edit_image))
|
||||
return
|
||||
}
|
||||
val resultUri = result.getUriFilePath(this, false)
|
||||
@@ -113,7 +113,7 @@ class EditImageActivity :
|
||||
|
||||
override fun onSetImageUriComplete(view: CropImageView, uri: Uri, error: Exception?) {
|
||||
if (error != null) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.image_editor_unable_to_edit_image))
|
||||
SnackbarUtil.show(this, getString(R.string.image_editor_unable_to_edit_image))
|
||||
return
|
||||
}
|
||||
view.visibility = View.VISIBLE
|
||||
|
||||
@@ -12,10 +12,11 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.ActivityShowErrorBinding
|
||||
import com.owncloud.android.utils.ClipboardUtil
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
class ShowErrorActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityShowErrorBinding
|
||||
@@ -35,14 +36,9 @@ class ShowErrorActivity : AppCompatActivity() {
|
||||
setSupportActionBar(binding.toolbarInclude.toolbar)
|
||||
supportActionBar!!.title = createErrorTitle()
|
||||
|
||||
val snackbar = DisplayUtils.createSnackbar(
|
||||
binding.errorPageContainer,
|
||||
R.string.error_report_issue_text,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.setAction(R.string.error_report_issue_action) { reportIssue() }
|
||||
|
||||
snackbar.show()
|
||||
SnackbarUtil.create(binding.errorPageContainer, R.string.error_report_issue_text, Snackbar.LENGTH_INDEFINITE)
|
||||
?.setAction(R.string.error_report_issue_action) { reportIssue() }
|
||||
?.show()
|
||||
}
|
||||
|
||||
private fun createErrorTitle() = String.format(getString(R.string.error_crash_title), getString(R.string.app_name))
|
||||
@@ -50,7 +46,7 @@ class ShowErrorActivity : AppCompatActivity() {
|
||||
private fun reportIssue() {
|
||||
ClipboardUtil.copyToClipboard(this, binding.textViewError.text.toString(), true)
|
||||
val issueLink = getString(R.string.report_issue_link)
|
||||
DisplayUtils.startLinkIntent(this, issueLink)
|
||||
IntentUtil.startLinkIntent(this, issueLink)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
+2
-2
@@ -13,6 +13,7 @@ import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.jobs.notification.WorkerNotificationManager
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
@@ -20,7 +21,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.upload.DeleteUploadedFileOperation
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileUtil
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.io.File
|
||||
@@ -122,7 +122,7 @@ class AutoUploadLocalDeletionWorker(
|
||||
): Notification {
|
||||
val notificationContent = context.getString(
|
||||
R.string.autoupload_delete_uploaded_notif_ended_content,
|
||||
DisplayUtils.bytesToHumanReadable(spaceFreed),
|
||||
HumanReadableFormatter.formatBytes(spaceFreed),
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.autoupload_delete_uploaded_notif_ended_content_files,
|
||||
filesRemoved.toInt(),
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.nextcloud.client.network.Connectivity
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.notifications.AppWideNotificationManager
|
||||
import com.nextcloud.model.OCUploadLocalPathData
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.checkWCFRestrictions
|
||||
import com.nextcloud.utils.extensions.createOwncloudClient
|
||||
import com.nextcloud.utils.extensions.getUploadIds
|
||||
@@ -51,7 +52,6 @@ import com.owncloud.android.operations.RemoveFileOperation
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.adapter.uploadList.helper.ConflictHandlingResult
|
||||
import com.owncloud.android.ui.adapter.uploadList.helper.UploadListAdapterActionHandler
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -619,7 +619,7 @@ class FileUploadHelper {
|
||||
MAX_FILE_COUNT,
|
||||
MAX_FILE_COUNT
|
||||
)
|
||||
DisplayUtils.showSnackMessage(activity, message)
|
||||
SnackbarUtil.show(activity, message)
|
||||
}
|
||||
|
||||
class UploadNotificationActionReceiver : BroadcastReceiver() {
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.appinfo.AppInfo
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.mdm.MDMConfig
|
||||
import com.owncloud.android.BuildConfig
|
||||
import com.owncloud.android.R
|
||||
@@ -103,7 +105,7 @@ class FirstRunActivity :
|
||||
val accountName = data?.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)
|
||||
val account = userAccountManager?.getAccountByName(accountName)
|
||||
if (account == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.account_creation_failed)
|
||||
SnackbarUtil.show(this, R.string.account_creation_failed)
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
@@ -156,7 +158,7 @@ class FirstRunActivity :
|
||||
binding.hostOwnServer.visibility = if (isProviderOrOwnInstallationVisible) View.VISIBLE else View.GONE
|
||||
if (isProviderOrOwnInstallationVisible) {
|
||||
binding.hostOwnServer.setOnClickListener {
|
||||
DisplayUtils.startLinkIntent(
|
||||
IntentUtil.startLinkIntent(
|
||||
this,
|
||||
R.string.url_server_install
|
||||
)
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.nextcloud.client.player.model.file.PlaybackFileType
|
||||
import com.nextcloud.client.player.ui.audio.AudioPlayerView
|
||||
import com.nextcloud.client.player.ui.video.VideoPlayerView
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getSerializableArgument
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -33,7 +34,6 @@ import com.owncloud.android.ui.activity.FileActivity
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment
|
||||
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import javax.inject.Inject
|
||||
@@ -136,17 +136,6 @@ class PlayerActivity :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
val videoPlayerView = playerView as? VideoPlayerView ?: return
|
||||
if (isInPictureInPictureMode) {
|
||||
videoPlayerView.hideControls()
|
||||
} else {
|
||||
videoPlayerView.showControls()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
super.onUserLeaveHint()
|
||||
if (canUsePictureInPictureMode()) {
|
||||
@@ -166,14 +155,11 @@ class PlayerActivity :
|
||||
null
|
||||
}
|
||||
|
||||
// Finish the activity if the user closes the PIP window
|
||||
if (!isInPictureInPictureMode && lifecycle.currentState == Lifecycle.State.CREATED) {
|
||||
finish() // Finish the activity if the user closes the PIP window
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
if (!isInPictureInPictureMode) {
|
||||
(playerView as? VideoPlayerView)?.showControls()
|
||||
}
|
||||
}
|
||||
|
||||
private fun canUsePictureInPictureMode(): Boolean =
|
||||
@@ -211,7 +197,7 @@ class PlayerActivity :
|
||||
|
||||
private fun showFileExportStartedMessage() {
|
||||
val message = resources.getQuantityString(R.plurals.export_start, 1, 1)
|
||||
DisplayUtils.showSnackMessage(playerView, message)
|
||||
SnackbarUtil.show(playerView, message)
|
||||
}
|
||||
|
||||
private fun showRemoveFileDialog(file: OCFile) {
|
||||
|
||||
@@ -26,12 +26,12 @@ import com.nextcloud.client.player.model.state.PlaybackState
|
||||
import com.nextcloud.client.player.ui.control.PlayerControlView
|
||||
import com.nextcloud.client.player.ui.pager.PlayerPager
|
||||
import com.nextcloud.client.player.util.WindowWrapper
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import dagger.android.HasAndroidInjector
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -124,7 +124,7 @@ abstract class PlayerView @JvmOverloads constructor(
|
||||
if (error is SourceException) {
|
||||
downloadFile()
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.common_error_unknown)
|
||||
SnackbarUtil.show(this, R.string.common_error_unknown)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ abstract class PlayerView @JvmOverloads constructor(
|
||||
} else {
|
||||
Log_OC.e(TAG, "cannot download file")
|
||||
withContext(Dispatchers.Main) {
|
||||
DisplayUtils.showSnackMessage(this@PlayerView, R.string.player_error_source_not_found)
|
||||
SnackbarUtil.show(this@PlayerView, R.string.player_error_source_not_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,10 @@ import com.nextcloud.client.player.model.state.PlaybackItemMetadata
|
||||
import com.nextcloud.client.player.model.state.PlaybackState
|
||||
import com.nextcloud.client.player.util.PlayerUtil.getPlaybackFile
|
||||
import com.nextcloud.client.player.util.PlayerUtil.putPlaybackFile
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.PlayerAudioFileFragmentBinding
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import dagger.android.support.AndroidSupportInjection
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -132,12 +133,12 @@ open class AudioFileFragment :
|
||||
}
|
||||
|
||||
private fun PlaybackFile.getDetailsText(): String = listOfNotNull(
|
||||
contentLength.takeIf { it > 0 }?.let { DisplayUtils.bytesToHumanReadable(it) },
|
||||
contentLength.takeIf { it > 0 }?.let { HumanReadableFormatter.formatBytes(it) },
|
||||
lastModified.takeIf { it > 0 }?.let(::getLastModifiedText)
|
||||
).joinToString(DETAILS_SEPARATOR)
|
||||
|
||||
private fun getLastModifiedText(lastModified: Long): String {
|
||||
val relativeTimestamp = DisplayUtils.getRelativeTimestamp(context, lastModified)
|
||||
val relativeTimestamp = DisplayTextFormatter.formatRelativeTimestamp(requireContext(), lastModified)
|
||||
return getString(R.string.player_last_modified, relativeTimestamp)
|
||||
}
|
||||
}
|
||||
@@ -8,27 +8,16 @@
|
||||
package com.nextcloud.client.player.ui.video
|
||||
|
||||
import android.content.Context
|
||||
import android.view.MotionEvent
|
||||
import android.view.WindowInsets
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsCompat.Type
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.client.player.model.file.PlaybackFile
|
||||
import com.nextcloud.client.player.ui.PlayerView
|
||||
import com.owncloud.android.R
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
class VideoPlayerView(context: Context) : PlayerView(context) {
|
||||
|
||||
companion object {
|
||||
private const val HIDE_CONTROLS_DELAY = 5000L
|
||||
}
|
||||
|
||||
override val layoutRes get() = R.layout.player_video_view
|
||||
|
||||
override val createFragment: (PlaybackFile) -> Fragment get() = { VideoFileFragment.createInstance(it) }
|
||||
@@ -39,13 +28,6 @@ class VideoPlayerView(context: Context) : PlayerView(context) {
|
||||
topBar.setBackgroundResource(R.drawable.player_video_top_scrim)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (!activity.isInPictureInPictureMode) {
|
||||
showControls()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
cancelHideControlsTimer()
|
||||
@@ -65,45 +47,6 @@ class VideoPlayerView(context: Context) : PlayerView(context) {
|
||||
return WindowInsetsCompat.CONSUMED.toWindowInsets()
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
val isTouchOutsideControls = event.y < playerControlView.y && event.y > topBar.height
|
||||
when {
|
||||
!playerControlView.isVisible -> showControls()
|
||||
isTouchOutsideControls -> hideControls()
|
||||
else -> restartHideControlsTimer()
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
fun showControls() {
|
||||
windowWrapper.showSystemBars()
|
||||
topBar.visibility = VISIBLE
|
||||
playerControlView.visibility = VISIBLE
|
||||
restartHideControlsTimer()
|
||||
}
|
||||
|
||||
fun hideControls() {
|
||||
windowWrapper.hideSystemBars()
|
||||
topBar.visibility = GONE
|
||||
playerControlView.visibility = GONE
|
||||
cancelHideControlsTimer()
|
||||
}
|
||||
|
||||
private fun restartHideControlsTimer() {
|
||||
hideControlsTimerJob?.cancel()
|
||||
|
||||
if (activity.isInPictureInPictureMode) {
|
||||
return
|
||||
}
|
||||
|
||||
hideControlsTimerJob = activity.lifecycleScope.launch {
|
||||
delay(HIDE_CONTROLS_DELAY.milliseconds)
|
||||
hideControls()
|
||||
}
|
||||
}
|
||||
|
||||
private fun cancelHideControlsTimer() {
|
||||
hideControlsTimerJob?.cancel()
|
||||
hideControlsTimerJob = null
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2026 TSI-mc <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
@@ -8,10 +9,15 @@
|
||||
*/
|
||||
package com.nextcloud.client.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.net.toUri
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.dialog.ShareLinkToDialog
|
||||
@@ -44,6 +50,34 @@ object IntentUtil {
|
||||
private fun getExposedFileUris(context: Context, files: Array<OCFile>): ArrayList<Uri> =
|
||||
ArrayList(files.map { it.getExposedFileUri(context) })
|
||||
|
||||
@JvmStatic
|
||||
fun startLinkIntent(activity: Activity, @StringRes link: Int) = startLinkIntent(activity, activity.getString(link))
|
||||
|
||||
@JvmStatic
|
||||
fun startLinkIntent(activity: Activity, url: String?) {
|
||||
if (url.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
startLinkIntent(activity, url.toUri())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startLinkIntent(activity: Activity, uri: Uri) {
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
startIntentIfAppAvailable(intent, activity, R.string.no_browser_available)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startIntentIfAppAvailable(intent: Intent, activity: Activity, @StringRes error: Int) {
|
||||
if (intent.resolveActivity(activity.packageManager) == null) {
|
||||
SnackbarUtil.show(activity, error)
|
||||
return
|
||||
}
|
||||
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
|
||||
fun showShareLinkDialog(activity: FragmentActivity, link: String?) {
|
||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||
putExtra(Intent.EXTRA_TEXT, link)
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.mdm.MDMConfig
|
||||
import com.owncloud.android.R
|
||||
@@ -36,7 +38,6 @@ import com.owncloud.android.ui.activity.DrawerActivity
|
||||
import com.owncloud.android.ui.adapter.UserListAdapter
|
||||
import com.owncloud.android.ui.adapter.UserListItem
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
@@ -64,6 +65,9 @@ class ChooseAccountDialogFragment :
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
@Inject
|
||||
lateinit var avatarGenerator: AvatarGenerator
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
@@ -92,13 +96,11 @@ class ChooseAccountDialogFragment :
|
||||
|
||||
// Defining user picture
|
||||
binding.currentAccount.userIcon.tag = user.accountName
|
||||
DisplayUtils.setAvatar(
|
||||
avatarGenerator.setAccountAvatar(
|
||||
user,
|
||||
this,
|
||||
resources.getDimension(R.dimen.list_item_avatar_icon_radius),
|
||||
resources,
|
||||
binding.currentAccount.userIcon,
|
||||
context
|
||||
binding.currentAccount.userIcon
|
||||
)
|
||||
|
||||
// Defining user texts, accounts, etc.
|
||||
@@ -119,7 +121,8 @@ class ChooseAccountDialogFragment :
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
viewThemeUtils
|
||||
viewThemeUtils,
|
||||
avatarGenerator
|
||||
)
|
||||
|
||||
if (!MDMConfig.multiAccountSupport(requireContext())) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.fragment.app.DialogFragment
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.DialogDataStorageLocationBinding
|
||||
@@ -27,7 +28,6 @@ import com.owncloud.android.datastorage.StoragePoint.PrivacyType
|
||||
import com.owncloud.android.datastorage.StoragePoint.StorageType
|
||||
import com.owncloud.android.ui.dialog.extensions.themeButtons
|
||||
import com.owncloud.android.ui.model.ExtendedSettingsActivityDialog
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
@@ -121,8 +121,8 @@ class ChooseStorageLocationDialogFragment :
|
||||
return String.format(
|
||||
getString(R.string.file_migration_free_space),
|
||||
typeString,
|
||||
DisplayUtils.bytesToHumanReadable(usedSpace),
|
||||
DisplayUtils.bytesToHumanReadable(totalSpace)
|
||||
HumanReadableFormatter.formatBytes(usedSpace),
|
||||
HumanReadableFormatter.formatBytes(totalSpace)
|
||||
)
|
||||
} ?: typeString
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ import com.nextcloud.android.lib.resources.clientintegration.LayoutOrientation
|
||||
import com.nextcloud.android.lib.resources.clientintegration.LayoutRow
|
||||
import com.nextcloud.android.lib.resources.clientintegration.LayoutText
|
||||
import com.nextcloud.android.lib.resources.clientintegration.LayoutURL
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.utils.extensions.getActivity
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
@Composable
|
||||
fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: String) {
|
||||
@@ -103,7 +103,7 @@ private fun DisplayElement(element: Element, baseUrl: String, activity: Activity
|
||||
|
||||
private fun openLink(activity: Activity?, baseUrl: String, relativeUrl: String) {
|
||||
activity?.let {
|
||||
DisplayUtils.startLinkIntent(activity, baseUrl + relativeUrl)
|
||||
IntentUtil.startLinkIntent(activity, baseUrl + relativeUrl)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.core.AsyncRunner
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.setVisibleIf
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.SetOnlineStatusBottomSheetBinding
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.BaseActivity
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -114,7 +114,7 @@ class SetOnlineStatusBottomSheet(val currentStatus: Status?) :
|
||||
}
|
||||
|
||||
activity?.let {
|
||||
DisplayUtils.showSnackMessage(it, R.string.set_online_status_bottom_sheet_error_message)
|
||||
SnackbarUtil.show(it, R.string.set_online_status_bottom_sheet_error_message)
|
||||
}
|
||||
clearTopStatus()
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.core.AsyncRunner
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.SetStatusMessageBottomSheetBinding
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
@@ -37,7 +39,6 @@ import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.ui.activity.BaseActivity
|
||||
import com.owncloud.android.ui.adapter.PredefinedStatusClickListener
|
||||
import com.owncloud.android.ui.adapter.PredefinedStatusListAdapter
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import com.vanniktech.emoji.EmojiManager
|
||||
import com.vanniktech.emoji.EmojiPopup
|
||||
@@ -179,7 +180,7 @@ class SetStatusMessageBottomSheet(val user: User, val currentStatus: Status?) :
|
||||
binding.remainingClearTime.apply {
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear)
|
||||
visibility = View.VISIBLE
|
||||
text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
|
||||
text = DisplayTextFormatter.formatRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
|
||||
.toString()
|
||||
.replaceFirstChar { it.lowercase(Locale.getDefault()) }
|
||||
setOnClickListener {
|
||||
@@ -296,7 +297,7 @@ class SetStatusMessageBottomSheet(val user: User, val currentStatus: Status?) :
|
||||
if (boolean) {
|
||||
dismiss()
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(view, view?.resources?.getString(R.string.error_setting_status_message))
|
||||
SnackbarUtil.show(view, view?.resources?.getString(R.string.error_setting_status_message))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ import android.view.View
|
||||
import androidx.core.net.toUri
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.setVisibleIf
|
||||
import com.owncloud.android.databinding.UploadWarningCardBinding
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FilesSyncHelper
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -120,7 +120,7 @@ class UploadWarningCard(
|
||||
FilesSyncHelper.startAutoUploadIgnoringPowerSaving(syncedFolderProvider, backgroundJobManager)
|
||||
}
|
||||
|
||||
DisplayUtils.showSnackMessage(view, result.messageId)
|
||||
SnackbarUtil.show(view, result.messageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,11 @@ import com.google.android.material.textfield.TextInputLayout
|
||||
import com.nextcloud.ui.fileInfo.model.GovernanceEvent
|
||||
import com.nextcloud.ui.fileInfo.model.GovernanceLabel
|
||||
import com.nextcloud.ui.fileInfo.model.GovernanceUiState
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FileInfoFragmentBinding
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.dialog.extensions.themeButtons
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.flow.filterIsInstance
|
||||
import kotlinx.coroutines.flow.first
|
||||
@@ -74,7 +74,7 @@ class GovernanceDetailInfo(
|
||||
viewModel.events.collect { event ->
|
||||
when (event) {
|
||||
GovernanceEvent.PermissionDenied -> {
|
||||
DisplayUtils.showSnackMessage(fragment, R.string.governance_permission_denied)
|
||||
SnackbarUtil.show(fragment, R.string.governance_permission_denied)
|
||||
currentLoadedState()?.let { refresh(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@ import androidx.exifinterface.media.ExifInterface
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.NominatimClient
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.ui.fileInfo.model.ImageMetadata
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.extensions.getSmallThumbnail
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FileInfoFragmentBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -180,7 +181,7 @@ class ImageDetailInfo(private val fragment: FileInfoFragment, private val viewTh
|
||||
}
|
||||
|
||||
fun gatherMetadata(file: OCFile): ImageMetadata {
|
||||
val fileSize = DisplayUtils.bytesToHumanReadable(file.fileLength)
|
||||
val fileSize = HumanReadableFormatter.formatBytes(file.fileLength)
|
||||
val timestamp = maxOf(file.modificationTimestamp, file.creationTimestamp)
|
||||
return if (file.isDown) {
|
||||
gatherLocalMetadata(file, fileSize, timestamp)
|
||||
@@ -269,7 +270,7 @@ class ImageDetailInfo(private val fragment: FileInfoFragment, private val viewTh
|
||||
object : ItemizedIconOverlay.OnItemGestureListener<OverlayItem> {
|
||||
override fun onItemSingleTapUp(index: Int, item: OverlayItem): Boolean {
|
||||
val intent = Intent(Intent.ACTION_VIEW, "geo:0,0?q=$latitude,$longitude".toUri())
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, fragment.activity, R.string.no_map_app_availble)
|
||||
IntentUtil.startIntentIfAppAvailable(intent, fragment.requireActivity(), R.string.no_map_app_availble)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.nextcloud.operations.PostMethod
|
||||
import com.nextcloud.ui.composeActivity.ComposeActivity
|
||||
import com.nextcloud.ui.composeActivity.ComposeDestination
|
||||
import com.nextcloud.utils.GlideHelper
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FileActionsBottomSheetBinding
|
||||
import com.owncloud.android.databinding.FileActionsBottomSheetItemBinding
|
||||
@@ -201,7 +202,7 @@ class ClientIntegration(
|
||||
}
|
||||
|
||||
private suspend fun showMessage(message: String) = withContext(Dispatchers.Main) {
|
||||
DisplayUtils.showSnackMessage(sheet.requireActivity(), message)
|
||||
SnackbarUtil.show(sheet.requireActivity(), message)
|
||||
}
|
||||
|
||||
private fun parseTooltipResult(response: String?): TooltipResponse {
|
||||
|
||||
@@ -34,7 +34,11 @@ import com.nextcloud.android.lib.resources.clientintegration.Endpoint
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.di.ViewModelFactory
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.utils.extensions.setVisibleIf
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailArguments
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FileActionsBottomSheetBinding
|
||||
@@ -45,7 +49,6 @@ import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
@@ -73,6 +76,9 @@ class FileActionsBottomSheet :
|
||||
@Inject
|
||||
lateinit var thumbnailGenerator: ThumbnailGenerator
|
||||
|
||||
@Inject
|
||||
lateinit var avatarGenerator: AvatarGenerator
|
||||
|
||||
private lateinit var viewModel: FileActionsViewModel
|
||||
|
||||
private var _binding: FileActionsBottomSheetBinding? = null
|
||||
@@ -138,7 +144,7 @@ class FileActionsBottomSheet :
|
||||
|
||||
FileActionsViewModel.UiState.Error -> {
|
||||
activity?.let {
|
||||
DisplayUtils.showSnackMessage(it, R.string.error_file_actions)
|
||||
SnackbarUtil.show(it, R.string.error_file_actions)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
@@ -278,14 +284,11 @@ class FileActionsBottomSheet :
|
||||
|
||||
override fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean = false
|
||||
}
|
||||
DisplayUtils.setAvatar(
|
||||
currentUserProvider.user,
|
||||
avatarGenerator.setUserAvatar(
|
||||
lockInfo.lockedBy,
|
||||
listener,
|
||||
resources.getDimension(R.dimen.list_item_avatar_icon_radius),
|
||||
resources,
|
||||
this,
|
||||
requireContext()
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
@@ -302,7 +305,8 @@ class FileActionsBottomSheet :
|
||||
}
|
||||
|
||||
private fun getLockedUntilText(lockInfo: FileActionsViewModel.LockInfo): CharSequence {
|
||||
val relativeTimestamp = DisplayUtils.getRelativeTimestamp(context, lockInfo.lockedUntil!!, true)
|
||||
val relativeTimestamp =
|
||||
DisplayTextFormatter.formatRelativeTimestamp(requireContext(), lockInfo.lockedUntil!!, true)
|
||||
return getString(R.string.lock_expiration_info, relativeTimestamp)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -26,6 +26,7 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.di.ViewModelFactory
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.toOCFile
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailArguments
|
||||
import com.owncloud.android.R
|
||||
@@ -34,7 +35,6 @@ import com.owncloud.android.databinding.FileActionsBottomSheetItemBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import javax.inject.Inject
|
||||
@@ -111,7 +111,7 @@ class TrashbinFileActionsBottomSheet :
|
||||
|
||||
TrashbinFileActionsViewModel.UiState.Error -> {
|
||||
activity?.let {
|
||||
DisplayUtils.showSnackMessage(it, R.string.error_file_actions)
|
||||
SnackbarUtil.show(it, R.string.error_file_actions)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
enum class ByteUnit(val suffix: String, val decimals: Int) {
|
||||
BYTES("B", 0),
|
||||
KILOBYTES("KB", 0),
|
||||
MEGABYTES("MB", 1),
|
||||
GIGABYTES("GB", 1),
|
||||
TERABYTES("TB", 1),
|
||||
PETABYTES("PB", 2),
|
||||
EXABYTES("EB", 2)
|
||||
}
|
||||
@@ -48,6 +48,9 @@ class EditorUtils @Inject constructor(private val arbitraryDataProvider: Arbitra
|
||||
return editors.any { usesOfficeUserAgent(it) && (mimeType in it.mimetypes || mimeType in it.optionalMimetypes) }
|
||||
}
|
||||
|
||||
fun isRichDocumentsDirectEditingAvailable(user: User?): Boolean =
|
||||
getEditors(user)?.any { it.id == RICH_DOCUMENTS_EDITOR_ID } == true
|
||||
|
||||
private fun getEditors(user: User?): Collection<Editor>? {
|
||||
val json = arbitraryDataProvider.getValue(user, ArbitraryDataProvider.DIRECT_EDITING)
|
||||
if (json.isEmpty()) return null
|
||||
@@ -57,6 +60,7 @@ class EditorUtils @Inject constructor(private val arbitraryDataProvider: Arbitra
|
||||
fun usesOfficeUserAgent(editor: Editor?): Boolean = editor?.id in OFFICE_EDITOR_IDS
|
||||
|
||||
companion object {
|
||||
private const val RICH_DOCUMENTS_EDITOR_ID = "richdocuments"
|
||||
private val OFFICE_EDITOR_IDS = setOf("onlyoffice", "eurooffice")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
object HumanReadableFormatter {
|
||||
|
||||
private const val BITS_PER_UNIT = 10
|
||||
|
||||
@JvmStatic
|
||||
fun formatBytes(bytes: Long): String {
|
||||
if (bytes < 0) {
|
||||
return MainApp.string(R.string.common_pending)
|
||||
}
|
||||
|
||||
val highestSetBit = Long.SIZE_BITS - 1 - bytes.countLeadingZeroBits()
|
||||
val unitIndex = (highestSetBit / BITS_PER_UNIT).coerceIn(0, ByteUnit.entries.lastIndex)
|
||||
val unit = ByteUnit.entries[unitIndex]
|
||||
val size = bytes.toDouble() / (1L shl (BITS_PER_UNIT * unitIndex))
|
||||
|
||||
val pattern = "%.${unit.decimals}f"
|
||||
val formattedSize = String.format(Locale.ROOT, pattern, size)
|
||||
return "$formattedSize ${unit.suffix}"
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun formatDateTime(milliseconds: Long): String = DateFormat.getDateTimeInstance().format(Date(milliseconds))
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
|
||||
object SnackbarUtil {
|
||||
|
||||
private val TAG = SnackbarUtil::class.java.simpleName
|
||||
private val mainThreadHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
@JvmStatic
|
||||
fun show(view: View?, @StringRes messageRes: Int, vararg formatArgs: Any?) {
|
||||
show(view, view.message(messageRes, formatArgs))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun show(view: View?, message: CharSequence?) {
|
||||
create(view, message, Snackbar.LENGTH_LONG)?.let { snackbar -> onMainThread(snackbar::show) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: Activity?, @StringRes messageRes: Int, vararg formatArgs: Any?) {
|
||||
val host = activity.hostView()
|
||||
show(host, host.message(messageRes, formatArgs))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: Activity?, message: CharSequence?) {
|
||||
show(activity.hostView(), message)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun show(fragment: Fragment?, @StringRes messageRes: Int, vararg formatArgs: Any?) {
|
||||
val host = fragment?.activity.hostView()
|
||||
show(host, host.message(messageRes, formatArgs))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showIndefinite(fragment: Fragment?, @StringRes messageRes: Int): Snackbar? =
|
||||
create(fragment?.activity.hostView(), messageRes, Snackbar.LENGTH_INDEFINITE)
|
||||
?.also { snackbar -> onMainThread(snackbar::show) }
|
||||
|
||||
@JvmStatic
|
||||
fun showServerOutdated(activity: Activity?, duration: Int) {
|
||||
create(activity.hostView(), R.string.outdated_server, duration)
|
||||
?.setAction(R.string.dismiss) { }
|
||||
?.let { snackbar -> onMainThread(snackbar::show) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun dismiss(snackbar: Snackbar?) {
|
||||
snackbar?.let { onMainThread(snackbar::dismiss) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun create(view: View?, message: CharSequence?, duration: Int): Snackbar? {
|
||||
if (view == null || message == null) {
|
||||
Log_OC.e(TAG, "Snackbar cannot be shown, host view or message is null")
|
||||
return null
|
||||
}
|
||||
|
||||
return Snackbar.make(view, message, duration).anchoredToFloatingActionButton(view)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun create(view: View?, @StringRes messageRes: Int, duration: Int): Snackbar? =
|
||||
create(view, view?.context?.getText(messageRes), duration)
|
||||
|
||||
@Suppress("SpreadOperator")
|
||||
private fun View?.message(@StringRes messageRes: Int, formatArgs: Array<out Any?>): CharSequence? {
|
||||
val context = this?.context ?: return null
|
||||
return when {
|
||||
formatArgs.isEmpty() -> context.getText(messageRes)
|
||||
else -> context.getString(messageRes, *formatArgs)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Activity?.hostView(): View? =
|
||||
this?.takeUnless { it.isFinishing || it.isDestroyed }?.findViewById(android.R.id.content)
|
||||
|
||||
private fun Snackbar.anchoredToFloatingActionButton(host: View): Snackbar = apply {
|
||||
val fab = host.rootView.findViewById<View>(R.id.fab_main)
|
||||
if (fab != null && fab.isVisible && fab.isAttachedToWindow) {
|
||||
anchorView = fab
|
||||
}
|
||||
}
|
||||
|
||||
private fun onMainThread(action: () -> Unit) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
action()
|
||||
} else {
|
||||
mainThreadHandler.post(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.avatar
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
|
||||
interface AvatarGenerationListener {
|
||||
fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any?)
|
||||
|
||||
fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.avatar
|
||||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.ApplicationScope
|
||||
import com.nextcloud.client.di.IoDispatcher
|
||||
import com.nextcloud.client.di.MainDispatcher
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.TextDrawable
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.lang.ref.WeakReference
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Singleton
|
||||
class AvatarGenerator @Inject constructor(
|
||||
private val context: Context,
|
||||
private val accountManager: AccountManager,
|
||||
private val currentAccountProvider: CurrentAccountProvider,
|
||||
private val avatarLoader: AvatarLoader,
|
||||
@param:ApplicationScope private val scope: CoroutineScope,
|
||||
@param:IoDispatcher private val ioDispatcher: CoroutineDispatcher,
|
||||
@param:MainDispatcher private val mainDispatcher: CoroutineDispatcher
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AvatarGenerator"
|
||||
private const val MAX_PARALLEL_DOWNLOADS = 4
|
||||
}
|
||||
|
||||
private val downloadDispatcher = ioDispatcher.limitedParallelism(MAX_PARALLEL_DOWNLOADS)
|
||||
|
||||
fun setAccountAvatar(user: User, listener: AvatarGenerationListener, avatarRadius: Float, callContext: Any) {
|
||||
val userId = accountManager.getUserData(user.toPlatformAccount(), AccountUtils.Constants.KEY_USER_ID)
|
||||
|
||||
if (userId == null) {
|
||||
Log_OC.e(TAG, "user id is null, cannot set avatar")
|
||||
return
|
||||
}
|
||||
|
||||
setUserAvatar(userId, listener, avatarRadius, callContext, user = user)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun setUserAvatar(
|
||||
userId: String,
|
||||
listener: AvatarGenerationListener,
|
||||
avatarRadius: Float,
|
||||
callContext: Any,
|
||||
displayName: String? = userId,
|
||||
user: User = currentAccountProvider.user,
|
||||
avatarBorder: Int = 0
|
||||
) {
|
||||
(callContext as? View)?.contentDescription = user.toPlatformAccount().hashCode().toString()
|
||||
|
||||
val request = AvatarRequest(user, userId, displayName, avatarRadius)
|
||||
val hasUserId = userId.isNotEmpty()
|
||||
|
||||
val placeholder = if (hasUserId) {
|
||||
createInitialAvatar(displayName, avatarRadius - avatarBorder)
|
||||
} else {
|
||||
createLinkAvatar(callContext)
|
||||
}
|
||||
listener.avatarGenerated(placeholder, callContext)
|
||||
|
||||
val listenerReference = WeakReference(listener)
|
||||
scope.launch(ioDispatcher) {
|
||||
if (hasUserId) {
|
||||
avatarLoader.loadCached(request)?.let { deliver(listenerReference, request, it, callContext) }
|
||||
}
|
||||
|
||||
val avatar = withContext(downloadDispatcher) { avatarLoader.load(request) } ?: return@launch
|
||||
deliver(listenerReference, request, avatar, callContext)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun deliver(
|
||||
listenerReference: WeakReference<AvatarGenerationListener>,
|
||||
request: AvatarRequest,
|
||||
avatar: Drawable,
|
||||
callContext: Any
|
||||
) = withContext(mainDispatcher) {
|
||||
val listener = listenerReference.get() ?: return@withContext
|
||||
|
||||
if (listener.shouldCallGeneratedCallback(request.accountName, callContext)) {
|
||||
listener.avatarGenerated(avatar, callContext)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
private fun createInitialAvatar(displayName: String?, radius: Float): Drawable? = try {
|
||||
TextDrawable.createAvatarByUserId(displayName, radius)
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e)
|
||||
ResourcesCompat.getDrawable(context.resources, R.drawable.account_circle_white, null)
|
||||
}
|
||||
|
||||
private fun createLinkAvatar(callContext: Any): Drawable? {
|
||||
val themedContext = (callContext as? View)?.context ?: context
|
||||
|
||||
return ContextCompat.getDrawable(themedContext, R.drawable.ic_link)?.apply {
|
||||
setTint(ContextCompat.getColor(themedContext, R.color.icon_on_nc_grey))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.avatar
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.ThumbnailUtils
|
||||
import android.net.Uri
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.TextDrawable
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import org.apache.commons.httpclient.HttpStatus
|
||||
import org.apache.commons.httpclient.methods.GetMethod
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
class AvatarLoader @Inject constructor(
|
||||
private val context: Context,
|
||||
private val arbitraryDataProvider: ArbitraryDataProvider,
|
||||
private val clock: Clock
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AvatarLoader"
|
||||
private const val AVATAR_TIMESTAMP = "avatarTimestamp"
|
||||
private const val ETAG_HEADER = "ETag"
|
||||
private const val IF_NONE_MATCH_HEADER = "If-None-Match"
|
||||
private val REFRESH_INTERVAL_MILLIS = 1.hours.inWholeMilliseconds
|
||||
}
|
||||
|
||||
private val resources get() = context.resources
|
||||
|
||||
fun loadCached(request: AvatarRequest): Drawable? {
|
||||
val eTag = arbitraryDataProvider.getValue(request.accountName, ThumbnailsCacheManager.AVATAR)
|
||||
val bitmap = ThumbnailsCacheManager.getBitmapFromDiskCache(request.cacheKey(eTag)) ?: return null
|
||||
return BitmapUtils.bitmapToCircularBitmapDrawable(resources, bitmap)
|
||||
}
|
||||
|
||||
fun load(request: AvatarRequest): Drawable? = try {
|
||||
loadOrDownload(request)
|
||||
} catch (_: OutOfMemoryError) {
|
||||
Log_OC.e(TAG, "Out of memory")
|
||||
null
|
||||
} catch (t: Throwable) {
|
||||
Log_OC.e(TAG, "Generation of avatar for ${request.userId} failed", t)
|
||||
ResourcesCompat.getDrawable(resources, R.drawable.account_circle_white, null)
|
||||
}
|
||||
|
||||
private fun loadOrDownload(request: AvatarRequest): Drawable? {
|
||||
val eTag = arbitraryDataProvider.getValue(request.accountName, ThumbnailsCacheManager.AVATAR)
|
||||
val cached = ThumbnailsCacheManager.getBitmapFromDiskCache(request.cacheKey(eTag))
|
||||
|
||||
if (cached != null && !isRefreshDue(request)) {
|
||||
return toDrawable(request, cached)
|
||||
}
|
||||
|
||||
return try {
|
||||
download(request, eTag, cached)
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Downloading avatar for ${request.userId} failed", e)
|
||||
createAccountAvatar(request, cached)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isRefreshDue(request: AvatarRequest): Boolean {
|
||||
val timestamp = arbitraryDataProvider.getLongValue(request.accountName, AVATAR_TIMESTAMP)
|
||||
return clock.currentTime - timestamp >= REFRESH_INTERVAL_MILLIS
|
||||
}
|
||||
|
||||
private fun download(request: AvatarRequest, eTag: String, cached: Bitmap?): Drawable? {
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(request.user.toOwnCloudAccount(), context)
|
||||
ThumbnailsCacheManager.setClient(client)
|
||||
|
||||
val px = resources.getInteger(R.integer.file_avatar_px)
|
||||
val get = GetMethod("${client.baseUri}/index.php/avatar/${Uri.encode(request.userId)}/$px")
|
||||
|
||||
try {
|
||||
if (eTag.isNotEmpty() && cached != null) {
|
||||
get.setRequestHeader(IF_NONE_MATCH_HEADER, eTag)
|
||||
}
|
||||
|
||||
return when (client.executeMethod(get)) {
|
||||
HttpStatus.SC_OK, HttpStatus.SC_CREATED -> readDownloadedAvatar(request, get, px)
|
||||
|
||||
HttpStatus.SC_NOT_MODIFIED -> {
|
||||
client.exhaustResponse(get.responseBodyAsStream)
|
||||
storeRefreshTimestamp(request)
|
||||
toDrawable(request, cached)
|
||||
}
|
||||
|
||||
else -> {
|
||||
client.exhaustResponse(get.responseBodyAsStream)
|
||||
toDrawable(request, cached)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
get.releaseConnection()
|
||||
}
|
||||
}
|
||||
|
||||
private fun readDownloadedAvatar(request: AvatarRequest, get: GetMethod, px: Int): Drawable? {
|
||||
val newETag = get.getResponseHeader(ETAG_HEADER)?.value?.replace("\"", "")
|
||||
newETag?.let {
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(request.accountName, ThumbnailsCacheManager.AVATAR, it)
|
||||
}
|
||||
|
||||
val bitmap = BitmapFactory.decodeStream(get.responseBodyAsStream)
|
||||
val thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px)
|
||||
|
||||
if (thumbnail == null || newETag.isNullOrEmpty()) {
|
||||
return TextDrawable.createAvatar(request.user, request.avatarRadius)
|
||||
}
|
||||
|
||||
val avatar = ThumbnailsCacheManager.handlePNG(thumbnail, px, px)
|
||||
ThumbnailsCacheManager.addBitmapToCache(request.cacheKey(newETag), avatar)
|
||||
storeRefreshTimestamp(request)
|
||||
return toDrawable(request, avatar)
|
||||
}
|
||||
|
||||
private fun storeRefreshTimestamp(request: AvatarRequest) {
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(request.accountName, AVATAR_TIMESTAMP, clock.currentTime)
|
||||
}
|
||||
|
||||
private fun createAccountAvatar(request: AvatarRequest, cached: Bitmap?): Drawable? = try {
|
||||
TextDrawable.createAvatar(request.user, request.avatarRadius)
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Error generating fallback avatar", e)
|
||||
toDrawable(request, cached)
|
||||
}
|
||||
|
||||
private fun toDrawable(request: AvatarRequest, bitmap: Bitmap?): Drawable? =
|
||||
BitmapUtils.bitmapToCircularBitmapDrawable(resources, bitmap) ?: createInitialAvatar(request)
|
||||
|
||||
private fun createInitialAvatar(request: AvatarRequest): Drawable? = try {
|
||||
TextDrawable.createAvatarByUserId(request.displayName, request.avatarRadius)
|
||||
} catch (_: Exception) {
|
||||
ResourcesCompat.getDrawable(resources, R.drawable.ic_user_outline, null)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.avatar
|
||||
|
||||
import com.nextcloud.client.account.User
|
||||
|
||||
data class AvatarRequest(val user: User, val userId: String, val displayName: String?, val avatarRadius: Float) {
|
||||
val serverName: String = user.accountName.substringAfterLast('@')
|
||||
|
||||
val accountName: String = "$userId@$serverName"
|
||||
|
||||
fun cacheKey(eTag: String): String = "a_${userId}_${serverName}_$eTag"
|
||||
}
|
||||
@@ -26,5 +26,11 @@ enum class DateFormatPattern(val pattern: String) {
|
||||
/**
|
||||
* Aug 2026
|
||||
*/
|
||||
MonthWithYear("MMM yyyy")
|
||||
MonthWithYear("MMM yyyy"),
|
||||
|
||||
FullMonthWithYear("MMMM yyyy"),
|
||||
|
||||
FullMonth("MMMM"),
|
||||
|
||||
Year("yyyy")
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import androidx.appcompat.app.ActionBar
|
||||
|
||||
fun ActionBar.setTitleColor(color: Int) {
|
||||
val text = SpannableString(title ?: "")
|
||||
text.setSpan(ForegroundColorSpan(color), 0, text.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
|
||||
title = text
|
||||
}
|
||||
@@ -9,18 +9,18 @@ package com.nextcloud.utils.extensions
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
private const val TAG = "FileExtensions"
|
||||
|
||||
fun OCFile?.logFileSize(tag: String) {
|
||||
val size = DisplayUtils.bytesToHumanReadable(this?.fileLength ?: -1)
|
||||
val size = HumanReadableFormatter.formatBytes(this?.fileLength ?: -1)
|
||||
val rawByte = this?.fileLength ?: -1
|
||||
Log_OC.d(tag, "onSaveInstanceState: $size, raw byte $rawByte")
|
||||
}
|
||||
@@ -48,7 +48,7 @@ fun File?.getSmallThumbnail(): Bitmap? = ThumbnailsCacheManager.getBitmapFromDis
|
||||
fun File?.getSmallThumbnailKey(): String = ThumbnailsCacheManager.PREFIX_THUMBNAIL + hashCode()
|
||||
|
||||
fun File?.logFileSize(tag: String) {
|
||||
val size = DisplayUtils.bytesToHumanReadable(this?.length() ?: -1)
|
||||
val size = HumanReadableFormatter.formatBytes(this?.length() ?: -1)
|
||||
val rawByte = this?.length() ?: -1
|
||||
Log_OC.d(tag, "onSaveInstanceState: $size, raw byte $rawByte")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.nextcloud.utils.extensions
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.e2ee.model.E2EEAction
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -20,7 +21,6 @@ import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragm
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment.Companion.RESULT_REQUEST_KEY
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment.Companion.SUCCESS
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private const val TAG = "OCFileListFragmentExtensions"
|
||||
@@ -39,7 +39,7 @@ fun OCFileListFragment.showEncryptionDialog(remotePath: String?, action: E2EEAct
|
||||
return@isNetworkAndServerAvailable
|
||||
}
|
||||
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
R.string.internet_connection_required_for_encrypted_folder_setup
|
||||
)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
|
||||
fun ActionBar.toggle(show: Boolean) {
|
||||
if (show) {
|
||||
show()
|
||||
} else {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
|
||||
fun Window.showSystemBar(show: Boolean, view: View) {
|
||||
WindowCompat.getInsetsController(this, view).run {
|
||||
val types = WindowInsetsCompat.Type.systemBars()
|
||||
if (show) {
|
||||
show(types)
|
||||
} else {
|
||||
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
hide(types)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Window.showNavigationBar(show: Boolean, view: View) {
|
||||
WindowCompat.getInsetsController(this, view).run {
|
||||
val types = WindowInsetsCompat.Type.navigationBars()
|
||||
if (show) {
|
||||
show(types)
|
||||
} else {
|
||||
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
hide(types)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.share
|
||||
|
||||
import com.nextcloud.android.common.ui.network.auth.ServerCredentials
|
||||
import com.nextcloud.android.common.ui.share.avatar.ShareAvatarRepository
|
||||
import com.nextcloud.android.common.ui.share.model.api.share.Share
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.extensions.supportsUnifiedShare
|
||||
import com.nextcloud.utils.extensions.toServerCredentials
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
import kotlinx.coroutines.sync.withPermit
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* Replaces the sharees PROPFIND reported with the ones the unified share API reports, at the point where the files
|
||||
* are written, so that readers take them straight from the [OCFile].
|
||||
*
|
||||
* This is the preferred approach only while the unified share system does not expose the legacy sharee data through
|
||||
* PROPFIND. Once it is backward compatible and ships the sharees with the file listing again, the listing alone
|
||||
* carries everything the UI needs and these extra requests can go away.
|
||||
*/
|
||||
object UnifiedShareSharees {
|
||||
private const val MAX_CONCURRENT_REQUESTS = 8
|
||||
|
||||
private val unifiedShareSupport = ConcurrentHashMap<String, Boolean>()
|
||||
|
||||
suspend fun fill(user: User, files: List<OCFile>) {
|
||||
if (files.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
val credentials = user.toServerCredentials() ?: return@withContext
|
||||
if (!supportsUnifiedShare(user.accountName, credentials)) {
|
||||
return@withContext
|
||||
}
|
||||
|
||||
val repository = ShareAvatarRepository(credentials)
|
||||
val requestLimit = Semaphore(MAX_CONCURRENT_REQUESTS)
|
||||
|
||||
files
|
||||
.map { file ->
|
||||
async {
|
||||
requestLimit.withPermit {
|
||||
runCatching { repository.fetchSharees(file) }
|
||||
}
|
||||
}
|
||||
}
|
||||
.awaitAll()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun fillBlocking(user: User, files: List<OCFile>) {
|
||||
runCatching {
|
||||
runBlocking { fill(user, files) }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun supportsUnifiedShare(accountName: String, credentials: ServerCredentials): Boolean {
|
||||
unifiedShareSupport[accountName]?.let { return it }
|
||||
|
||||
// a failed capability request stays uncached so that the next listing can resolve it again
|
||||
val supported = runCatching { credentials.supportsUnifiedShare() }.getOrNull() ?: return false
|
||||
unifiedShareSupport[accountName] = supported
|
||||
|
||||
return supported
|
||||
}
|
||||
|
||||
private suspend fun ShareAvatarRepository.fetchSharees(file: OCFile) {
|
||||
file.sharees = fetchShareAvatars(file.localId.toString())?.toAvatarSharees().orEmpty()
|
||||
}
|
||||
|
||||
private fun List<Share>.toAvatarSharees(): List<ShareeUser> = asSequence()
|
||||
.flatMap { share -> share.invitedRecipients }
|
||||
.distinctBy { recipient -> recipient.value }
|
||||
.map { recipient -> ShareeUser(recipient.value, recipient.displayName, ShareType.USER) }
|
||||
.toList()
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.text
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateUtils
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.date.DateFormatPattern
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
object DisplayTextFormatter {
|
||||
|
||||
private const val DATE_TIME_SEPARATOR = ","
|
||||
private const val TIME_SEPARATOR = ':'
|
||||
private const val DATE_TIME_PARTS_SIZE = 2
|
||||
private const val ACCOUNT_HOST_SEPARATOR = '@'
|
||||
|
||||
@JvmStatic
|
||||
fun formatAccountName(user: User): String {
|
||||
val host = user.accountName.substringAfterLast(ACCOUNT_HOST_SEPARATOR)
|
||||
val displayName = user.toOwnCloudAccount().displayName
|
||||
return "$displayName$ACCOUNT_HOST_SEPARATOR${DisplayUtils.convertIdn(host, false)}"
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun formatRelativeTimestamp(context: Context, timestamp: Long, showFuture: Boolean = false): CharSequence =
|
||||
formatRelativeDateTime(context, timestamp, DateUtils.SECOND_IN_MILLIS, showFuture = showFuture)
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun formatRelativeDateTime(
|
||||
context: Context,
|
||||
time: Long,
|
||||
minResolution: Long,
|
||||
transitionResolution: Long = DateUtils.WEEK_IN_MILLIS,
|
||||
flags: Int = 0,
|
||||
showFuture: Boolean = false
|
||||
): CharSequence {
|
||||
val elapsed = System.currentTimeMillis() - time
|
||||
return when {
|
||||
!showFuture && elapsed < 0 -> HumanReadableFormatter.formatDateTime(time)
|
||||
|
||||
minResolution == DateUtils.MINUTE_IN_MILLIS && elapsed in 1 until DateUtils.MINUTE_IN_MILLIS ->
|
||||
context.getString(R.string.file_list_seconds_ago)
|
||||
|
||||
else -> DateUtils.getRelativeDateTimeString(context, time, minResolution, transitionResolution, flags)
|
||||
.toString()
|
||||
.withoutTimeOfDay()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun formatDate(timestamp: Long, pattern: DateFormatPattern, context: Context = MainApp.getAppContext()): String {
|
||||
val locale = context.resources.configuration.locales[0]
|
||||
return SimpleDateFormat(pattern.pattern, locale).format(Date(timestamp))
|
||||
}
|
||||
|
||||
private fun String.withoutTimeOfDay(): String {
|
||||
val parts = split(DATE_TIME_SEPARATOR)
|
||||
if (parts.size != DATE_TIME_PARTS_SIZE || parts.any(String::isBlank)) {
|
||||
return this
|
||||
}
|
||||
|
||||
val (first, second) = parts
|
||||
val firstHasTime = TIME_SEPARATOR in first
|
||||
val secondHasTime = TIME_SEPARATOR in second
|
||||
|
||||
return when {
|
||||
secondHasTime && !firstHasTime -> first
|
||||
firstHasTime && !secondHasTime -> second
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,13 @@ import android.text.style.StyleSpan
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.chip.ChipDrawable
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import thirdparties.fresco.BetterImageSpan
|
||||
|
||||
class RichSubjectFormatter(private val context: Context, private val currentAccountProvider: CurrentAccountProvider) :
|
||||
DisplayUtils.AvatarGenerationListener {
|
||||
class RichSubjectFormatter(private val context: Context, private val avatarGenerator: AvatarGenerator) :
|
||||
AvatarGenerationListener {
|
||||
|
||||
fun format(richSubject: String, paramForTag: (String) -> RichSubjectParam?): SpannableStringBuilder {
|
||||
var text = richSubject
|
||||
@@ -59,11 +59,11 @@ class RichSubjectFormatter(private val context: Context, private val currentAcco
|
||||
return ssb
|
||||
}
|
||||
|
||||
override fun avatarGenerated(avatarDrawable: Drawable, callContext: Any) {
|
||||
override fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any?) {
|
||||
(callContext as? ChipDrawable)?.chipIcon = avatarDrawable
|
||||
}
|
||||
|
||||
override fun shouldCallGeneratedCallback(tag: String, callContext: Any): Boolean = true
|
||||
override fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean = true
|
||||
|
||||
private fun SpannableStringBuilder.applyMentionSpan(param: RichSubjectParam, start: Int, end: Int) {
|
||||
val name = param.name
|
||||
@@ -71,15 +71,12 @@ class RichSubjectFormatter(private val context: Context, private val currentAcco
|
||||
val span = MentionChipSpan(chip, BetterImageSpan.ALIGN_CENTER, param.id.orEmpty(), name)
|
||||
|
||||
param.id?.let { id ->
|
||||
DisplayUtils.setAvatar(
|
||||
currentAccountProvider.user,
|
||||
avatarGenerator.setUserAvatar(
|
||||
id,
|
||||
name,
|
||||
this@RichSubjectFormatter,
|
||||
context.resources.getDimension(R.dimen.avatar_icon_radius),
|
||||
context.resources,
|
||||
chip,
|
||||
context
|
||||
displayName = name
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,32 +10,42 @@ package com.nmc.android.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.android.common.ui.util.extensions.applyEdgeToEdgeWithSystemBarPadding
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.utils.mdm.MDMConfig
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity
|
||||
import com.owncloud.android.databinding.ActivitySplashBinding
|
||||
import com.owncloud.android.ui.activity.BaseActivity
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
class LauncherActivity : BaseActivity() {
|
||||
class LauncherActivity :
|
||||
AppCompatActivity(),
|
||||
Injectable {
|
||||
|
||||
private lateinit var binding: ActivitySplashBinding
|
||||
|
||||
@Inject
|
||||
lateinit var accountManager: UserAccountManager
|
||||
|
||||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// Mandatory to call this before super method to show system launch screen for api level 31+
|
||||
installSplashScreen()
|
||||
applyEdgeToEdgeWithSystemBarPadding()
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -56,30 +66,42 @@ class LauncherActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun updateTitleVisibility() {
|
||||
if (TextUtils.isEmpty(resources.getString(R.string.splashScreenBold))) {
|
||||
if (resources.getString(R.string.splashScreenBold).isEmpty()) {
|
||||
binding.splashScreenBold.visibility = View.GONE
|
||||
}
|
||||
if (TextUtils.isEmpty(resources.getString(R.string.splashScreenNormal))) {
|
||||
if (resources.getString(R.string.splashScreenNormal).isEmpty()) {
|
||||
binding.splashScreenNormal.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasBrandedTitle(): Boolean = resources.getString(R.string.splashScreenBold).isNotEmpty() ||
|
||||
resources.getString(R.string.splashScreenNormal).isNotEmpty()
|
||||
|
||||
private fun scheduleSplashScreen() {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
if (user.isPresent) {
|
||||
if (MDMConfig.enforceProtection(this) && appPreferences.lockPreference == SettingsActivity.LOCK_NONE) {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
} else {
|
||||
startActivity(Intent(this, FileDisplayActivity::class.java))
|
||||
}
|
||||
} else {
|
||||
startActivity(Intent(this, AuthenticatorActivity::class.java))
|
||||
lifecycleScope.launch {
|
||||
if (hasBrandedTitle()) {
|
||||
delay(SPLASH_DURATION)
|
||||
}
|
||||
finish()
|
||||
}, SPLASH_DURATION)
|
||||
|
||||
openNextScreen()
|
||||
}
|
||||
}
|
||||
|
||||
private fun openNextScreen() {
|
||||
val nextScreen = when {
|
||||
accountManager.user.isAnonymous -> AuthenticatorActivity::class.java
|
||||
|
||||
MDMConfig.enforceProtection(this) &&
|
||||
appPreferences.lockPreference == SettingsActivity.LOCK_NONE -> SettingsActivity::class.java
|
||||
|
||||
else -> FileDisplayActivity::class.java
|
||||
}
|
||||
|
||||
startActivity(Intent(this, nextScreen))
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SPLASH_DURATION = 1500L
|
||||
private val SPLASH_DURATION = 1500.milliseconds
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import com.nextcloud.client.onboarding.OnboardingService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.common.PlainClient;
|
||||
import com.nextcloud.operations.PostMethod;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.BundleExtensionsKt;
|
||||
import com.nextcloud.utils.mdm.MDMConfig;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -425,7 +426,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
*/
|
||||
private void anonymouslyPostLoginRequest(String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_empty_base_url);
|
||||
SnackbarUtil.show(this, R.string.authenticator_activity_empty_base_url);
|
||||
return;
|
||||
}
|
||||
baseUrl = url;
|
||||
@@ -433,7 +434,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
singleThreadExecutor.execute(() -> {
|
||||
String response = getResponseOfAnonymouslyPostLoginRequest();
|
||||
if (TextUtils.isEmpty(response)) {
|
||||
DisplayUtils.showSnackMessage(AuthenticatorActivity.this, R.string.authenticator_activity_empty_response_message);
|
||||
SnackbarUtil.show(AuthenticatorActivity.this, R.string.authenticator_activity_empty_response_message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,7 +470,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
Log_OC.e(TAG, "Both AuthObject and fallback parsing failed, returning default login URL");
|
||||
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_login_error);
|
||||
SnackbarUtil.show(this, R.string.authenticator_activity_login_error);
|
||||
return getResources().getString(R.string.webview_login_url);
|
||||
}
|
||||
|
||||
@@ -488,7 +489,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private void launchDefaultWebBrowser(String url) {
|
||||
if (url == null || url.isBlank()) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.invalid_url);
|
||||
SnackbarUtil.show(this, R.string.invalid_url);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -515,7 +516,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
Log_OC.e(TAG, "External browser launch failed: " + e);
|
||||
}
|
||||
|
||||
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found);
|
||||
SnackbarUtil.show(this, R.string.authenticator_activity_no_web_browser_found);
|
||||
}
|
||||
|
||||
private Pair<String, String> extractPollUrlAndToken() {
|
||||
@@ -888,7 +889,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (data != null && data.toString().startsWith(getString(R.string.login_data_own_scheme))) {
|
||||
if (!MDMConfig.INSTANCE.multiAccountSupport(this) &&
|
||||
accountManager.getAccounts().length == 1) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.no_mutliple_accounts_allowed);
|
||||
SnackbarUtil.show(this, R.string.no_mutliple_accounts_allowed);
|
||||
finish();
|
||||
return;
|
||||
} else {
|
||||
@@ -953,7 +954,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (!bindService(new Intent(this, OperationsService.class),
|
||||
mOperationsServiceConnection,
|
||||
Context.BIND_AUTO_CREATE)) {
|
||||
DisplayUtils.showSnackMessage(accountSetupBinding.scroll, R.string.error_cant_bind_to_operations_service);
|
||||
SnackbarUtil.show(accountSetupBinding.scroll, R.string.error_cant_bind_to_operations_service);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -1088,7 +1089,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
} catch (AccountNotFoundException e) {
|
||||
Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
|
||||
DisplayUtils.showSnackMessage(accountSetupBinding.scroll, R.string.auth_account_does_not_exist);
|
||||
SnackbarUtil.show(accountSetupBinding.scroll, R.string.auth_account_does_not_exist);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -1342,7 +1343,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
private void showErrorAndFinishActivity() {
|
||||
DisplayUtils.showSnackMessage(this, mAuthStatusText);
|
||||
SnackbarUtil.show(this, mAuthStatusText);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -1378,7 +1379,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
} catch (AccountNotFoundException e) {
|
||||
Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
|
||||
DisplayUtils.showSnackMessage(accountSetupBinding.scroll, R.string.auth_account_does_not_exist);
|
||||
SnackbarUtil.show(accountSetupBinding.scroll, R.string.auth_account_does_not_exist);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -1420,7 +1421,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (accountSetupWebviewBinding != null) {
|
||||
anonymouslyPostLoginRequest(mServerInfo.mBaseUrl + WEB_LOGIN);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.auth_access_failed, result.getLogMessage(this));
|
||||
SnackbarUtil.show(this, R.string.auth_access_failed, result.getLogMessage(this));
|
||||
|
||||
// init webView again
|
||||
updateAuthStatusIconAndText(result);
|
||||
@@ -1620,7 +1621,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
if (!MDMConfig.INSTANCE.multiAccountSupport(this) &&
|
||||
accountManager.getAccounts().length == 1) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.no_mutliple_accounts_allowed);
|
||||
SnackbarUtil.show(this, R.string.no_mutliple_accounts_allowed);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1803,6 +1804,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
*/
|
||||
@Override
|
||||
public void onFailedSavingCertificate() {
|
||||
DisplayUtils.showSnackMessage(this, R.string.ssl_validator_not_saved);
|
||||
SnackbarUtil.show(this, R.string.ssl_validator_not_saved);
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ package com.owncloud.android.authentication
|
||||
|
||||
import android.os.Bundle
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.mdm.MDMConfig
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
class DeepLinkLoginActivity :
|
||||
AuthenticatorActivity(),
|
||||
@@ -20,7 +20,7 @@ class DeepLinkLoginActivity :
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (!MDMConfig.multiAccountSupport(this) && accountManager.accounts.size == 1) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.no_mutliple_accounts_allowed)
|
||||
SnackbarUtil.show(this, R.string.no_mutliple_accounts_allowed)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class DeepLinkLoginActivity :
|
||||
|
||||
loginDialog?.showDeepLinkDialog(loginUrlInfo)
|
||||
} catch (_: IllegalArgumentException) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.direct_login_failed)
|
||||
SnackbarUtil.show(this, R.string.direct_login_failed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,13 @@
|
||||
*/
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.nextcloud.utils.date.DateFormatPattern
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
|
||||
data class GalleryItems(val date: Long, val rows: List<GalleryRow>) {
|
||||
override fun toString(): String {
|
||||
val month = DisplayUtils.getDateByPattern(
|
||||
date,
|
||||
DisplayUtils.MONTH_PATTERN
|
||||
)
|
||||
val year = DisplayUtils.getDateByPattern(
|
||||
date,
|
||||
DisplayUtils.YEAR_PATTERN
|
||||
)
|
||||
val month = DisplayTextFormatter.formatDate(date, DateFormatPattern.FullMonth)
|
||||
val year = DisplayTextFormatter.formatDate(date, DateFormatPattern.Year)
|
||||
return "$month/$year with $rows rows"
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
@@ -52,12 +51,10 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.ui.adapter.DiskLruImageCache;
|
||||
import com.owncloud.android.ui.fragment.FileFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
@@ -78,7 +75,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import static com.nextcloud.utils.extensions.ThumbnailsCacheManagerExtensionsKt.getExifOrientation;
|
||||
@@ -104,8 +100,6 @@ public final class ThumbnailsCacheManager {
|
||||
private static final String PNG_MIMETYPE = "image/png";
|
||||
private static final String CACHE_FOLDER = "thumbnailCache";
|
||||
public static final String AVATAR = "avatar";
|
||||
private static final String AVATAR_TIMESTAMP = "avatarTimestamp";
|
||||
private static final String ETAG = "ETag";
|
||||
|
||||
private static final Object mThumbnailsDiskCacheLock = new Object();
|
||||
private static volatile DiskLruImageCache mThumbnailCache;
|
||||
@@ -902,169 +896,6 @@ public final class ThumbnailsCacheManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static class AvatarGenerationTask extends AsyncTask<String, Void, Drawable> {
|
||||
private final WeakReference<AvatarGenerationListener> mAvatarGenerationListener;
|
||||
private final Object mCallContext;
|
||||
private final Resources mResources;
|
||||
private final float mAvatarRadius;
|
||||
private final User user;
|
||||
private final String mUserId;
|
||||
private final String displayName;
|
||||
private final String mServerName;
|
||||
@SuppressLint("StaticFieldLeak") private final Context mContext;
|
||||
|
||||
|
||||
public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener,
|
||||
Object callContext,
|
||||
User user,
|
||||
Resources resources,
|
||||
float avatarRadius,
|
||||
String userId,
|
||||
String displayName,
|
||||
String serverName,
|
||||
Context context) {
|
||||
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
|
||||
mCallContext = callContext;
|
||||
this.user = user;
|
||||
mResources = resources;
|
||||
mAvatarRadius = avatarRadius;
|
||||
mUserId = userId;
|
||||
this.displayName = displayName;
|
||||
mServerName = serverName;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("Dm")
|
||||
@Override
|
||||
protected Drawable doInBackground(String... params) {
|
||||
Drawable thumbnail = null;
|
||||
|
||||
try {
|
||||
thumbnail = doAvatarInBackground();
|
||||
} catch (OutOfMemoryError oome) {
|
||||
Log_OC.e(TAG, "Out of memory");
|
||||
} catch (Throwable t) {
|
||||
// the app should never break due to a problem with avatars
|
||||
thumbnail = ResourcesCompat.getDrawable(mResources, R.drawable.account_circle_white, null);
|
||||
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
|
||||
}
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Drawable drawable) {
|
||||
if (drawable != null) {
|
||||
AvatarGenerationListener listener = mAvatarGenerationListener.get();
|
||||
if (listener != null) {
|
||||
String accountName = mUserId + "@" + mServerName;
|
||||
if (listener.shouldCallGeneratedCallback(accountName, mCallContext)) {
|
||||
listener.avatarGenerated(drawable, mCallContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull
|
||||
Drawable doAvatarInBackground() {
|
||||
Bitmap avatar;
|
||||
|
||||
String accountName = mUserId + "@" + mServerName;
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProviderImpl(mContext);
|
||||
|
||||
String eTag = arbitraryDataProvider.getValue(accountName, ThumbnailsCacheManager.AVATAR);
|
||||
long timestamp = arbitraryDataProvider.getLongValue(accountName, ThumbnailsCacheManager.AVATAR_TIMESTAMP);
|
||||
String avatarKey = "a_" + mUserId + "_" + mServerName + "_" + eTag;
|
||||
avatar = getBitmapFromDiskCache(avatarKey);
|
||||
|
||||
// Download avatar from server, only if older than 60 min or avatar does not exist
|
||||
if (System.currentTimeMillis() - timestamp >= 60 * 60 * 1000 || avatar == null) {
|
||||
GetMethod get = null;
|
||||
try {
|
||||
if (user != null) {
|
||||
OwnCloudAccount ocAccount = user.toOwnCloudAccount();
|
||||
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, mContext);
|
||||
}
|
||||
|
||||
int px = mResources.getInteger(R.integer.file_avatar_px);
|
||||
String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px;
|
||||
Log_OC.d("Avatar", "URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
|
||||
// only use eTag if available and corresponding avatar is still there
|
||||
// (might be deleted from cache)
|
||||
if (!eTag.isEmpty() && avatar != null) {
|
||||
get.setRequestHeader("If-None-Match", eTag);
|
||||
}
|
||||
|
||||
int status = mClient.executeMethod(get);
|
||||
|
||||
// we are using eTag to download a new avatar only if it changed
|
||||
switch (status) {
|
||||
case HttpStatus.SC_OK:
|
||||
case HttpStatus.SC_CREATED:
|
||||
// new avatar
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
|
||||
String newETag = null;
|
||||
if (get.getResponseHeader(ETAG) != null) {
|
||||
newETag = get.getResponseHeader(ETAG).getValue().replace("\"", "");
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(accountName, AVATAR, newETag);
|
||||
}
|
||||
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
avatar = ThumbnailUtils.extractThumbnail(bitmap, px, px);
|
||||
|
||||
// Add avatar to cache
|
||||
if (avatar != null && !TextUtils.isEmpty(newETag)) {
|
||||
avatar = handlePNG(avatar, px, px);
|
||||
String newImageKey = "a_" + mUserId + "_" + mServerName + "_" + newETag;
|
||||
addBitmapToCache(newImageKey, avatar);
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(accountName,
|
||||
ThumbnailsCacheManager.AVATAR_TIMESTAMP,
|
||||
System.currentTimeMillis());
|
||||
} else {
|
||||
return TextDrawable.createAvatar(user, mAvatarRadius);
|
||||
}
|
||||
break;
|
||||
|
||||
case HttpStatus.SC_NOT_MODIFIED:
|
||||
// old avatar
|
||||
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(accountName,
|
||||
ThumbnailsCacheManager.AVATAR_TIMESTAMP,
|
||||
System.currentTimeMillis());
|
||||
break;
|
||||
default:
|
||||
// everything else
|
||||
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
return TextDrawable.createAvatar(user, mAvatarRadius);
|
||||
} catch (Exception e1) {
|
||||
Log_OC.e(TAG, "Error generating fallback avatar");
|
||||
}
|
||||
} finally {
|
||||
if (get != null) {
|
||||
get.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (avatar == null) {
|
||||
try {
|
||||
return TextDrawable.createAvatarByUserId(displayName, mAvatarRadius);
|
||||
} catch (Exception e1) {
|
||||
return ResourcesCompat.getDrawable(mResources, R.drawable.ic_user_outline, null);
|
||||
}
|
||||
} else {
|
||||
return BitmapUtils.bitmapToCircularBitmapDrawable(mResources, avatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean cancelPotentialThumbnailWork(Object file, ImageView imageView) {
|
||||
final ThumbnailGenerationTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.utils.ResultParser;
|
||||
import com.nextcloud.utils.e2ee.E2EVersionHelper;
|
||||
import com.nextcloud.utils.share.UnifiedShareSharees;
|
||||
import com.nextcloud.utils.extensions.StringExtensionsKt;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
||||
@@ -629,6 +630,8 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
updateFileNameForEncryptedFile(fileDataStorageManager, metadata, mLocalFolder);
|
||||
}
|
||||
|
||||
UnifiedShareSharees.fillBlocking(user, updatedFiles);
|
||||
|
||||
fileDataStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
|
||||
|
||||
mChildren = updatedFiles;
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.utils.share.UnifiedShareSharees;
|
||||
import com.nextcloud.client.jobs.download.FileDownloadHelper;
|
||||
import com.nextcloud.client.jobs.folderDownload.FolderDownloadWorkerNotificationManager;
|
||||
import com.nextcloud.utils.extensions.ExtensionsKt;
|
||||
@@ -349,6 +350,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
// save updated contents in local database
|
||||
UnifiedShareSharees.fillBlocking(user, updatedFiles);
|
||||
|
||||
storageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
|
||||
mLocalFolder.setLastSyncDateForData(System.currentTimeMillis());
|
||||
storageManager.saveFile(mLocalFolder);
|
||||
|
||||
@@ -19,12 +19,13 @@ import androidx.core.graphics.drawable.DrawableCompat
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.GlideHelper.loadCircularBitmapIntoImageView
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -47,19 +48,47 @@ class AvatarGroupLayout @JvmOverloads constructor(
|
||||
@Px
|
||||
private val overlapPx: Int = DisplayUtils.convertDpToPixel(24f, context)
|
||||
|
||||
var boundFileId: Long? = null
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
displayedSharees = null
|
||||
}
|
||||
field = value
|
||||
}
|
||||
|
||||
private var displayedSharees: List<ShareeUser>? = null
|
||||
|
||||
init {
|
||||
checkNotNull(borderDrawable)
|
||||
DrawableCompat.setTint(borderDrawable, ContextCompat.getColor(context, R.color.bg_default))
|
||||
}
|
||||
|
||||
@Suppress("LongMethod", "TooGenericExceptionCaught")
|
||||
fun setAvatars(user: User, sharees: MutableList<ShareeUser>, viewThemeUtils: ViewThemeUtils) {
|
||||
fun setAvatars(
|
||||
user: User,
|
||||
sharees: List<ShareeUser>,
|
||||
viewThemeUtils: ViewThemeUtils,
|
||||
avatarGenerator: AvatarGenerator
|
||||
) {
|
||||
if (sharees == displayedSharees) {
|
||||
return
|
||||
}
|
||||
displayedSharees = sharees
|
||||
|
||||
val context = getContext()
|
||||
removeAllViews()
|
||||
|
||||
if (sharees.isEmpty()) {
|
||||
visibility = GONE
|
||||
return
|
||||
}
|
||||
visibility = VISIBLE
|
||||
|
||||
var avatarLayoutParams: LayoutParams?
|
||||
val shareeSize = min(sharees.size, MAX_AVATAR_COUNT)
|
||||
val resources = context.resources
|
||||
val avatarRadius = resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val serverName = user.accountName.substringAfterLast('@')
|
||||
var sharee: ShareeUser
|
||||
|
||||
var avatarCount = 0
|
||||
@@ -102,17 +131,15 @@ class AvatarGroupLayout @JvmOverloads constructor(
|
||||
)
|
||||
|
||||
else -> {
|
||||
avatar.tag = sharee
|
||||
DisplayUtils.setAvatar(
|
||||
user,
|
||||
avatar.tag = "${sharee.userId}@$serverName"
|
||||
avatarGenerator.setUserAvatar(
|
||||
sharee.userId!!,
|
||||
sharee.displayName,
|
||||
this,
|
||||
avatarRadius,
|
||||
resources,
|
||||
avatar,
|
||||
context,
|
||||
avatarBorderSize
|
||||
displayName = sharee.displayName,
|
||||
user = user,
|
||||
avatarBorder = avatarBorderSize
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -166,11 +193,11 @@ class AvatarGroupLayout @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any) {
|
||||
override fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any?) {
|
||||
(callContext as ImageView).setImageDrawable(avatarDrawable)
|
||||
}
|
||||
|
||||
override fun shouldCallGeneratedCallback(tag: String?, callContext: Any): Boolean =
|
||||
override fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean =
|
||||
(callContext as ImageView).tag == tag
|
||||
|
||||
companion object {
|
||||
|
||||
+7
-4
@@ -14,22 +14,25 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.common.NextcloudClient
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.owncloud.android.databinding.VersionListItemBinding
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.owncloud.android.lib.resources.files.model.FileVersion
|
||||
import com.owncloud.android.ui.interfaces.ActivityListInterface
|
||||
import com.owncloud.android.ui.interfaces.VersionListInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.util.Date
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class ActivityAndVersionListAdapter(
|
||||
context: FragmentActivity,
|
||||
currentAccountProvider: CurrentAccountProvider,
|
||||
activityListInterface: ActivityListInterface,
|
||||
private val versionListInterface: VersionListInterface.View,
|
||||
viewThemeUtils: ViewThemeUtils
|
||||
) : ActivityListAdapter(context, currentAccountProvider, activityListInterface, true, viewThemeUtils) {
|
||||
viewThemeUtils: ViewThemeUtils,
|
||||
avatarGenerator: AvatarGenerator
|
||||
) : ActivityListAdapter(context, currentAccountProvider, activityListInterface, true, viewThemeUtils, avatarGenerator) {
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun setActivityAndVersionItems(items: MutableList<Any?>, newClient: NextcloudClient?, clear: Boolean) {
|
||||
@@ -71,7 +74,7 @@ class ActivityAndVersionListAdapter(
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is VersionViewHolder) {
|
||||
val fileVersion = values[position] as FileVersion
|
||||
holder.binding.size.text = DisplayUtils.bytesToHumanReadable(fileVersion.fileLength)
|
||||
holder.binding.size.text = HumanReadableFormatter.formatBytes(fileVersion.fileLength)
|
||||
holder.binding.time.text = DateFormat.format("HH:mm", Date(fileVersion.modifiedTimestamp).time)
|
||||
holder.binding.restore.setOnClickListener { versionListInterface.onRestoreClicked(fileVersion) }
|
||||
} else {
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.common.NextcloudClient
|
||||
import com.nextcloud.utils.GlideHelper
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.text.RichSubjectFormatter
|
||||
import com.nextcloud.utils.text.RichSubjectParam
|
||||
import com.owncloud.android.MainApp
|
||||
@@ -39,7 +41,6 @@ import com.owncloud.android.lib.resources.activities.model.RichObject
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject
|
||||
import com.owncloud.android.ui.activities.StickyHeaderAdapter
|
||||
import com.owncloud.android.ui.interfaces.ActivityListInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -50,13 +51,14 @@ import kotlin.math.floor
|
||||
import kotlin.math.log
|
||||
import kotlin.math.pow
|
||||
|
||||
@Suppress("MagicNumber", "TooManyFunctions")
|
||||
@Suppress("MagicNumber", "TooManyFunctions", "LongParameterList")
|
||||
open class ActivityListAdapter(
|
||||
protected val context: FragmentActivity,
|
||||
private val currentAccountProvider: CurrentAccountProvider,
|
||||
private val activityListInterface: ActivityListInterface,
|
||||
private val isDetailView: Boolean,
|
||||
private val viewThemeUtils: ViewThemeUtils
|
||||
private val viewThemeUtils: ViewThemeUtils,
|
||||
private val avatarGenerator: AvatarGenerator
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(),
|
||||
StickyHeaderAdapter {
|
||||
|
||||
@@ -64,7 +66,7 @@ open class ActivityListAdapter(
|
||||
val values: MutableList<Any> = mutableListOf()
|
||||
private val px = getThumbnailDimension()
|
||||
private var cachedNextcloudClient: NextcloudClient? = null
|
||||
private val richSubjectFormatter by lazy { RichSubjectFormatter(context, currentAccountProvider) }
|
||||
private val richSubjectFormatter by lazy { RichSubjectFormatter(context, avatarGenerator) }
|
||||
|
||||
// region Public Methods
|
||||
@Suppress("NotifyDataSetChanged")
|
||||
@@ -79,12 +81,10 @@ open class ActivityListAdapter(
|
||||
|
||||
fun getHeaderDateString(context: Context, modificationTimestamp: Long): CharSequence =
|
||||
if ((System.currentTimeMillis() - modificationTimestamp) < DateUtils.WEEK_IN_MILLIS) {
|
||||
DisplayUtils.getRelativeDateTimeString(
|
||||
DisplayTextFormatter.formatRelativeDateTime(
|
||||
context,
|
||||
modificationTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
DateUtils.DAY_IN_MILLIS
|
||||
)
|
||||
} else {
|
||||
DateFormat.format(
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FilesFolderPickerBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -28,7 +29,6 @@ import com.owncloud.android.ui.fragment.FileFragment
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment
|
||||
import com.owncloud.android.ui.fragment.albums.AlbumsFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter
|
||||
|
||||
class AlbumsPickerActivity :
|
||||
@@ -179,7 +179,7 @@ class AlbumsPickerActivity :
|
||||
fileListFragment?.refreshAlbums()
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, resources)
|
||||
)
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.jobs.upload.UploadNotificationManager
|
||||
import com.nextcloud.client.jobs.utils.UploadErrorNotificationManager
|
||||
import com.nextcloud.model.HTTPStatusCodes
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getDecryptedPath
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.extensions.logFileSize
|
||||
@@ -40,7 +41,6 @@ import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictsResolveDialog.Decision
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictsResolveDialog.OnConflictDecisionMadeListener
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictResolveDialogFactory
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -359,7 +359,7 @@ class ConflictsResolveActivity :
|
||||
}
|
||||
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
DisplayUtils.showSnackMessage(this@ConflictsResolveActivity, message)
|
||||
SnackbarUtil.show(this@ConflictsResolveActivity, message)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +59,17 @@ import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.nextcloud.client.player.media3.PlaybackModel;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.utils.IntentUtil;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.composeActivity.ComposeActivity;
|
||||
import com.nextcloud.ui.composeActivity.ComposeDestination;
|
||||
import com.nextcloud.utils.GlideHelper;
|
||||
import com.nextcloud.utils.HumanReadableFormatter;
|
||||
import com.nextcloud.utils.LinkHelper;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator;
|
||||
import com.nextcloud.utils.extensions.ActivityExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.DrawerActivityExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.NavigationViewExtensionsKt;
|
||||
@@ -100,7 +105,6 @@ import com.owncloud.android.ui.fragment.albums.AlbumItemsFragment;
|
||||
import com.owncloud.android.ui.fragment.albums.AlbumsFragment;
|
||||
import com.owncloud.android.ui.navigation.NavigatorActivity;
|
||||
import com.owncloud.android.ui.navigation.NavigatorScreen;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinFragment;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.DrawableUtil;
|
||||
@@ -141,7 +145,7 @@ import kotlin.Unit;
|
||||
* generation.
|
||||
*/
|
||||
public abstract class DrawerActivity extends ToolbarActivity
|
||||
implements DisplayUtils.AvatarGenerationListener, Injectable {
|
||||
implements AvatarGenerationListener, Injectable {
|
||||
|
||||
private static final String TAG = DrawerActivity.class.getSimpleName();
|
||||
private static final String KEY_IS_ACCOUNT_CHOOSER_ACTIVE = "IS_ACCOUNT_CHOOSER_ACTIVE";
|
||||
@@ -237,6 +241,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
@Inject
|
||||
protected ClientFactory clientFactory;
|
||||
|
||||
@Inject
|
||||
public AvatarGenerator avatarGenerator;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
@@ -828,7 +835,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
|
||||
if (link.getRedirect()) {
|
||||
DisplayUtils.startLinkIntent(DrawerActivity.this, link.getUrl());
|
||||
IntentUtil.startLinkIntent(DrawerActivity.this, link.getUrl());
|
||||
} else {
|
||||
Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.getName());
|
||||
@@ -938,12 +945,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
if (GetUserInfoRemoteOperation.SPACE_UNLIMITED == quotaValue) {
|
||||
mQuotaTextPercentage.setText(String.format(
|
||||
getString(R.string.drawer_quota_unlimited),
|
||||
DisplayUtils.bytesToHumanReadable(usedSpace)));
|
||||
HumanReadableFormatter.formatBytes(usedSpace)));
|
||||
} else {
|
||||
mQuotaTextPercentage.setText(String.format(
|
||||
getString(R.string.drawer_quota),
|
||||
DisplayUtils.bytesToHumanReadable(usedSpace),
|
||||
DisplayUtils.bytesToHumanReadable(totalSpace)));
|
||||
HumanReadableFormatter.formatBytes(usedSpace),
|
||||
HumanReadableFormatter.formatBytes(totalSpace)));
|
||||
}
|
||||
|
||||
mQuotaProgressBar.setProgress(relative);
|
||||
@@ -1457,7 +1464,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
DeepLinkConstants deepLinkType = DeepLinkConstants.Companion.fromPath(path);
|
||||
if (deepLinkType == null) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.invalid_url));
|
||||
SnackbarUtil.show(this, getString(R.string.invalid_url));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.webkit.WebView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.IntentExtensionsKt;
|
||||
import com.nextcloud.utils.thumbnail.VideoOverlayGenerator;
|
||||
@@ -34,7 +35,6 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.SyncedFolderObserver;
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider;
|
||||
import com.owncloud.android.ui.asynctasks.TextEditorLoadUrlTask;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.RichDocumentDownloader;
|
||||
import com.owncloud.android.utils.WebViewUtil;
|
||||
@@ -86,17 +86,19 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if (this.getWebView().getVisibility() != View.VISIBLE) {
|
||||
Snackbar snackbar = DisplayUtils.createSnackbar(findViewById(android.R.id.content),
|
||||
R.string.timeout_richDocuments, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.common_cancel, v -> closeView());
|
||||
|
||||
viewThemeUtils.material.themeSnackbar(snackbar);
|
||||
setLoadingSnackbar(snackbar);
|
||||
snackbar.show();
|
||||
Snackbar snackbar = SnackbarUtil.create(findViewById(android.R.id.content),
|
||||
R.string.timeout_richDocuments,
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
if (snackbar != null) {
|
||||
snackbar.setAction(R.string.common_cancel, v -> closeView());
|
||||
viewThemeUtils.material.themeSnackbar(snackbar);
|
||||
setLoadingSnackbar(snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
}, 10 * 1000);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this,R.string.richdocuments_failed_to_load_document);
|
||||
SnackbarUtil.show(this, R.string.richdocuments_failed_to_load_document);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -154,7 +156,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
activity.startActivityForResult(intent, REQUEST_LOCAL_FILE);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
uploadMessage = null;
|
||||
DisplayUtils.showSnackMessage(EditorWebView.this, R.string.editor_web_view_cannot_open_file);
|
||||
SnackbarUtil.show(EditorWebView.this, R.string.editor_web_view_cannot_open_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,7 +167,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
setFile(IntentExtensionsKt.getParcelableArgument(getIntent(), ExternalSiteWebView.EXTRA_FILE, OCFile.class));
|
||||
|
||||
if (getFile() == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.richdocuments_failed_to_load_document);
|
||||
SnackbarUtil.show(this, R.string.richdocuments_failed_to_load_document);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -28,13 +28,13 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.IntentExtensionsKt;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -259,7 +259,7 @@ public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity implem
|
||||
// nothing else to do in this activity
|
||||
finish();
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(findViewById(android.R.id.content), R.string.foreign_files_fail);
|
||||
SnackbarUtil.show(findViewById(android.R.id.content), R.string.foreign_files_fail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.nextcloud.client.utils.IntentUtil;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.ExternalsiteWebviewBinding;
|
||||
@@ -60,7 +62,7 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
|
||||
if (!WebViewUtil.available(this)) {
|
||||
super.onCreate(savedInstanceState);
|
||||
DisplayUtils.showSnackMessage(this, R.string.webview_not_available);
|
||||
SnackbarUtil.show(this, R.string.webview_not_available);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@@ -149,7 +151,7 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
if (!request.isRedirect()) {
|
||||
DisplayUtils.startLinkIntent(self, request.getUrl());
|
||||
IntentUtil.startLinkIntent(self, request.getUrl());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,9 @@ import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.network.NetworkChangeListener;
|
||||
import com.nextcloud.client.player.ui.PlayerActivity;
|
||||
import com.nextcloud.client.utils.IntentUtil;
|
||||
import com.nextcloud.utils.EditorUtils;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.ActivityExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.BundleExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
||||
@@ -96,7 +98,6 @@ import com.owncloud.android.ui.fragment.filesRepository.RemoteFilesRepository;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
||||
import com.owncloud.android.utils.ClipboardUtil;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
@@ -390,7 +391,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
requestCredentialsUpdate();
|
||||
|
||||
if (result.getCode() == ResultCode.UNAUTHORIZED) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
);
|
||||
}
|
||||
@@ -410,7 +411,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
updateFileFromDB();
|
||||
|
||||
} else if (result.getCode() != ResultCode.CANCELLED) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
);
|
||||
}
|
||||
@@ -423,7 +424,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
updateFileFromDB();
|
||||
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this,
|
||||
SnackbarUtil.show(this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result,
|
||||
operation,
|
||||
getResources()));
|
||||
@@ -500,7 +501,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
startActivityForResult(updateAccountCredentials, REQUEST_CODE__UPDATE_CREDENTIALS);
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.auth_account_does_not_exist);
|
||||
SnackbarUtil.show(this, R.string.auth_account_does_not_exist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +535,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
|
||||
} else {
|
||||
if (!operation.getTransferWasRequested()) {
|
||||
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result,
|
||||
SnackbarUtil.show(this, ErrorMessageAdapter.getErrorCauseMessage(result,
|
||||
operation, getResources()));
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
@@ -727,20 +728,20 @@ public abstract class FileActivity extends DrawerActivity
|
||||
}
|
||||
|
||||
if (latestVersion == -1 || currentVersion == -1) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.dev_version_no_information_available, Snackbar.LENGTH_LONG);
|
||||
SnackbarUtil.show(activity, R.string.dev_version_no_information_available);
|
||||
}
|
||||
if (latestVersion > currentVersion) {
|
||||
String devApkLink = activity.getString(R.string.dev_link) + latestVersion + ".apk";
|
||||
if (openDirectly) {
|
||||
DisplayUtils.startLinkIntent(activity, devApkLink);
|
||||
IntentUtil.startLinkIntent(activity, devApkLink);
|
||||
} else {
|
||||
Snackbar.make(activity.findViewById(android.R.id.content), R.string.dev_version_new_version_available,
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(activity.getString(R.string.version_dev_download), v -> DisplayUtils.startLinkIntent(activity, devApkLink)).show();
|
||||
.setAction(activity.getString(R.string.version_dev_download), v -> IntentUtil.startLinkIntent(activity, devApkLink)).show();
|
||||
}
|
||||
} else {
|
||||
if (!inBackground) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.dev_version_no_new_version_available, Snackbar.LENGTH_LONG);
|
||||
SnackbarUtil.show(activity, R.string.dev_version_no_new_version_available);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -804,7 +805,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
sharingFragment.onUpdateShareInformation(result);
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
|
||||
SnackbarUtil.show(this, R.string.note_could_not_sent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +887,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
if (ocFileListFragment.getAdapterFiles().contains(file)) {
|
||||
ocFileListFragment.updateOCFile(file);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.file_activity_shared_file_cannot_be_updated);
|
||||
SnackbarUtil.show(this, R.string.file_activity_shared_file_cannot_be_updated);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -965,7 +966,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
if (!existingSharees.contains(shareType + "_" + shareWith)) {
|
||||
doShareWith(shareWith, shareType);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.sharee_already_added_to_file));
|
||||
SnackbarUtil.show(this, getString(R.string.sharee_already_added_to_file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.model.OCUploadLocalPathData
|
||||
import com.nextcloud.model.WorkerState.OfflineOperationsCompleted
|
||||
import com.nextcloud.ui.composeActivity.ComposeProcessTextAlias
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.extensions.getSerializableArgument
|
||||
import com.nextcloud.utils.extensions.isActive
|
||||
@@ -158,7 +159,6 @@ import com.owncloud.android.ui.preview.PreviewTextFragment
|
||||
import com.owncloud.android.ui.preview.PreviewTextStringFragment
|
||||
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment.Companion.newInstance
|
||||
import com.owncloud.android.utils.DataHolderUtil
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
@@ -492,7 +492,7 @@ class FileDisplayActivity :
|
||||
optionalCapability.get().hasValidSubscription.isTrue
|
||||
)
|
||||
) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this, Snackbar.LENGTH_LONG)
|
||||
SnackbarUtil.showServerOutdated(this, Snackbar.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ class FileDisplayActivity :
|
||||
}
|
||||
|
||||
if (!file.renameTo(renamedFile)) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this@FileDisplayActivity,
|
||||
R.string.error_uploading_direct_camera_upload
|
||||
)
|
||||
@@ -1136,7 +1136,7 @@ class FileDisplayActivity :
|
||||
)
|
||||
}
|
||||
if (isValidFolderPath == false) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
R.string.file_name_validator_error_contains_reserved_names_or_invalid_characters
|
||||
)
|
||||
@@ -1161,7 +1161,7 @@ class FileDisplayActivity :
|
||||
}
|
||||
} else {
|
||||
Log_OC.d(TAG, "User clicked on 'Update' with no selection")
|
||||
DisplayUtils.showSnackMessage(this, R.string.filedisplay_no_file_selected)
|
||||
SnackbarUtil.show(this, R.string.filedisplay_no_file_selected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1627,7 +1627,7 @@ class FileDisplayActivity :
|
||||
}
|
||||
|
||||
private fun handleRemovedFolder(syncFolderRemotePath: String?) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.sync_current_folder_was_removed, syncFolderRemotePath)
|
||||
SnackbarUtil.show(this, R.string.sync_current_folder_was_removed, syncFolderRemotePath)
|
||||
fileListFragment?.let {
|
||||
it.parentFolderFinder.getParentOnFirstParentRemoved(syncFolderRemotePath, storageManager)?.let { target ->
|
||||
it.listDirectory(target, MainApp.isOnlyOnDevice())
|
||||
@@ -1780,7 +1780,7 @@ class FileDisplayActivity :
|
||||
}
|
||||
if (renamedInUpload && !uploadedRemotePath.isNullOrBlank()) {
|
||||
val newName = File(uploadedRemotePath).name
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this@FileDisplayActivity,
|
||||
R.string.filedetails_renamed_in_upload_msg,
|
||||
newName
|
||||
@@ -2368,7 +2368,7 @@ class FileDisplayActivity :
|
||||
leftFragment.getFileDetailActivitiesFragment().reload()
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.file_version_restored_error)
|
||||
SnackbarUtil.show(this, R.string.file_version_restored_error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2381,7 +2381,7 @@ class FileDisplayActivity :
|
||||
private fun onMoveFileOperationFinish(operation: MoveFileOperation?, result: RemoteOperationResult<*>) {
|
||||
if (!result.isSuccess) {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
)
|
||||
@@ -2403,7 +2403,7 @@ class FileDisplayActivity :
|
||||
refreshGalleryFragmentIfNeeded()
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
)
|
||||
@@ -2423,7 +2423,7 @@ class FileDisplayActivity :
|
||||
val optionalUser = user
|
||||
val renamedFile = operation.file
|
||||
if (!result.isSuccess || optionalUser.isEmpty) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
)
|
||||
@@ -2520,9 +2520,9 @@ class FileDisplayActivity :
|
||||
} else {
|
||||
try {
|
||||
if (RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS == result.code) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.folder_already_exists)
|
||||
SnackbarUtil.show(this, R.string.folder_already_exists)
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
)
|
||||
@@ -3046,13 +3046,11 @@ class FileDisplayActivity :
|
||||
val existingAccountName = existingUser.accountName
|
||||
mSwitchAccountButton.tag = existingAccountName
|
||||
|
||||
DisplayUtils.setAvatar(
|
||||
avatarGenerator.setAccountAvatar(
|
||||
existingUser,
|
||||
this,
|
||||
getResources().getDimension(R.dimen.nav_drawer_menu_avatar_radius),
|
||||
getResources(),
|
||||
mSwitchAccountButton,
|
||||
this
|
||||
mSwitchAccountButton
|
||||
)
|
||||
val userChanged = (existingAccountName != lastDisplayedAccountName)
|
||||
if (userChanged) {
|
||||
@@ -3086,7 +3084,7 @@ class FileDisplayActivity :
|
||||
}
|
||||
|
||||
private fun handleOpenFileViaIntent(intent: Intent) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.retrieving_file))
|
||||
SnackbarUtil.show(this, getString(R.string.retrieving_file))
|
||||
|
||||
val userName = intent.getStringExtra(KEY_ACCOUNT)
|
||||
val fileId = intent.getStringExtra(KEY_FILE_ID)
|
||||
@@ -3106,7 +3104,7 @@ class FileDisplayActivity :
|
||||
accountClicked(optionalUser.get())
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found))
|
||||
SnackbarUtil.show(this, getString(R.string.associated_account_not_found))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3118,7 +3116,7 @@ class FileDisplayActivity :
|
||||
if (match == null) {
|
||||
handleDeepLink(uri)
|
||||
} else if (match.users.isEmpty()) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found))
|
||||
SnackbarUtil.show(this, getString(R.string.associated_account_not_found))
|
||||
} else if (match.users.size == SINGLE_USER_SIZE) {
|
||||
openFile(match.users[0], match.fileId)
|
||||
} else {
|
||||
@@ -3210,7 +3208,7 @@ class FileDisplayActivity :
|
||||
|
||||
private fun onFileRequestError(throwable: Throwable?) {
|
||||
dismissLoadingDialog()
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.error_retrieving_file))
|
||||
SnackbarUtil.show(this, getString(R.string.error_retrieving_file))
|
||||
Log_OC.e(TAG, "Requesting file from remote failed!", throwable)
|
||||
}
|
||||
|
||||
@@ -3253,7 +3251,7 @@ class FileDisplayActivity :
|
||||
file = current
|
||||
updateActionBarTitleAndHomeButton(null)
|
||||
} else {
|
||||
fragment.view?.let { DisplayUtils.showSnackMessage(it, message) }
|
||||
fragment.view?.let { SnackbarUtil.show(it, message) }
|
||||
}
|
||||
|
||||
selectedFile?.let(fragment::onItemClicked)
|
||||
@@ -3273,7 +3271,7 @@ class FileDisplayActivity :
|
||||
val account = accountManager.getUser(accountName).orElse(null)
|
||||
?: run {
|
||||
Log_OC.w(TAG, "user is not present")
|
||||
DisplayUtils.showSnackMessage(this@FileDisplayActivity, R.string.account_not_found)
|
||||
SnackbarUtil.show(this@FileDisplayActivity, R.string.account_not_found)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.fileNameValidator.FileNameValidator
|
||||
import com.owncloud.android.R
|
||||
@@ -47,7 +48,6 @@ import com.owncloud.android.ui.fragment.EmptyListState
|
||||
import com.owncloud.android.ui.fragment.FileFragment
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment
|
||||
import com.owncloud.android.utils.DataHolderUtil
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.PathUtils
|
||||
@@ -401,7 +401,7 @@ open class FolderPickerActivity :
|
||||
checkButtonStates(isFolderPathValid)
|
||||
|
||||
if (!isFolderPathValid) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
R.string.file_name_validator_error_contains_reserved_names_or_invalid_characters
|
||||
)
|
||||
@@ -521,7 +521,7 @@ open class FolderPickerActivity :
|
||||
fileListFragment?.onItemClicked(storageManager.getFileByPath(operation.remotePath))
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
this,
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, resources)
|
||||
)
|
||||
@@ -623,7 +623,7 @@ open class FolderPickerActivity :
|
||||
}
|
||||
|
||||
private fun browseRootForRemovedFolder() {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
activity,
|
||||
R.string.sync_current_folder_was_removed,
|
||||
currentFolder?.fileName
|
||||
|
||||
@@ -123,7 +123,8 @@ class ManageAccountsActivity :
|
||||
multipleAccountsSupported,
|
||||
true,
|
||||
true,
|
||||
viewThemeUtils
|
||||
viewThemeUtils,
|
||||
avatarGenerator
|
||||
)
|
||||
|
||||
recyclerView = findViewById(R.id.account_list)
|
||||
@@ -272,7 +273,8 @@ class ManageAccountsActivity :
|
||||
multipleAccountsSupported,
|
||||
false,
|
||||
true,
|
||||
viewThemeUtils
|
||||
viewThemeUtils,
|
||||
avatarGenerator
|
||||
)
|
||||
recyclerView?.adapter = userListAdapter
|
||||
runOnUiThread { userListAdapter?.notifyDataSetChanged() }
|
||||
@@ -331,7 +333,8 @@ class ManageAccountsActivity :
|
||||
multipleAccountsSupported,
|
||||
false,
|
||||
true,
|
||||
viewThemeUtils
|
||||
viewThemeUtils,
|
||||
avatarGenerator
|
||||
)
|
||||
recyclerView?.adapter = userListAdapter
|
||||
} else {
|
||||
|
||||
+9
-8
@@ -54,6 +54,7 @@ import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.model.OCUploadLocalPathData;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.BundleExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.IntentExtensionsKt;
|
||||
@@ -260,7 +261,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
if (mAccountManager.getAccountsByType(MainApp.getAccountType(this)).length == 0) {
|
||||
final var message = String.format(getString(R.string.uploader_wrn_no_account_text),
|
||||
getString(R.string.app_name));
|
||||
DisplayUtils.showSnackMessage(this, message);
|
||||
SnackbarUtil.show(this, message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,13 +321,13 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
String filenameErrorMessage = FileNameValidator.INSTANCE.checkFileName(file.getFileName(), optionalCapabilities.get(), this);
|
||||
if (filenameErrorMessage != null) {
|
||||
DisplayUtils.showSnackMessage(this, filenameErrorMessage);
|
||||
SnackbarUtil.show(this, filenameErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.isEncrypted() &&
|
||||
!FileOperationsHelper.isEndToEndEncryptionSetup(this, getUser().orElseThrow(IllegalAccessError::new))) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.e2e_not_yet_setup);
|
||||
SnackbarUtil.show(this, R.string.e2e_not_yet_setup);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -937,7 +938,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
private void startSyncFolderOperation(OCFile folder) {
|
||||
if (folder == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.receive_external_files_activity_start_sync_folder_is_not_exists_message);
|
||||
SnackbarUtil.show(this, R.string.receive_external_files_activity_start_sync_folder_is_not_exists_message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -947,7 +948,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
long currentSyncTime = System.currentTimeMillis();
|
||||
final var optionalUser = getUser();
|
||||
if (optionalUser.isEmpty()) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.user_information_retrieval_error);
|
||||
SnackbarUtil.show(this, R.string.user_information_retrieval_error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1038,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
public void uploadFiles() {
|
||||
if (mStreamsToUpload == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.receive_external_files_activity_unable_to_find_file_to_upload);
|
||||
SnackbarUtil.show(this, R.string.receive_external_files_activity_unable_to_find_file_to_upload);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1109,7 +1110,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
populateDirectoryList(null);
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
|
||||
SnackbarUtil.show(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
|
||||
} catch (NotFoundException e) {
|
||||
Log_OC.e(TAG, "Error while trying to show fail message ", e);
|
||||
}
|
||||
@@ -1258,7 +1259,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
if (currentDir == null) {
|
||||
// current folder was removed from the server
|
||||
DisplayUtils.showSnackMessage(getActivity(), R.string.sync_current_folder_was_removed, getCurrentFolder().getFileName());
|
||||
SnackbarUtil.show(getActivity(), R.string.sync_current_folder_was_removed, getCurrentFolder().getFileName());
|
||||
browseToRoot();
|
||||
} else {
|
||||
if (currentFile == null && !mFile.isFolder()) {
|
||||
|
||||
@@ -18,11 +18,11 @@ import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RequestCredentialsActivity extends Activity {
|
||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||
finishWithResult(KEY_CHECK_RESULT_CANCEL);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.default_credentials_wrong);
|
||||
SnackbarUtil.show(this, R.string.default_credentials_wrong);
|
||||
requestCredentials();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class RequestCredentialsActivity extends Activity {
|
||||
if (DeviceCredentialUtils.areCredentialsAvailable(this)) {
|
||||
requestCredentials();
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_lock_device_credentials_not_setup);
|
||||
SnackbarUtil.show(this, R.string.prefs_lock_device_credentials_not_setup);
|
||||
finishWithResult(KEY_CHECK_RESULT_CANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.net.toUri
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -28,7 +29,6 @@ import com.owncloud.android.operations.RichDocumentsCreateAssetOperation
|
||||
import com.owncloud.android.ui.asynctasks.PrintAsyncTask
|
||||
import com.owncloud.android.ui.asynctasks.RichDocumentsLoadUrlTask
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.RichDocumentDownloadAsParser
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
|
||||
@@ -101,7 +101,7 @@ class RichDocumentsEditorWebView : EditorWebView() {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
runOnUiThread { DisplayUtils.showSnackMessage(this, "Inserting image failed!") }
|
||||
runOnUiThread { SnackbarUtil.show(this, "Inserting image failed!") }
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class RichDocumentsEditorWebView : EditorWebView() {
|
||||
private fun printFile(url: Uri) {
|
||||
val account = accountManager.currentOwnCloudAccount
|
||||
if (account == null) {
|
||||
DisplayUtils.showSnackMessage(webView, getString(R.string.failed_to_print))
|
||||
SnackbarUtil.show(webView, getString(R.string.failed_to_print))
|
||||
return
|
||||
}
|
||||
val targetFile = File(FileStorageUtils.getTemporalPath(account.name) + "/print.pdf")
|
||||
|
||||
@@ -52,6 +52,8 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.nextcloud.client.utils.IntentUtil;
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.nextcloud.utils.extensions.ContextExtensionsKt;
|
||||
import com.nextcloud.utils.mdm.MDMConfig;
|
||||
import com.owncloud.android.BuildConfig;
|
||||
@@ -76,7 +78,6 @@ import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.ui.model.ExtendedSettingsActivityDialog;
|
||||
import com.owncloud.android.utils.ClipboardUtil;
|
||||
import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
@@ -250,7 +251,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
Preference pChangelogLink = findPreference("changelog_link");
|
||||
if (pChangelogLink != null) {
|
||||
pChangelogLink.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.dev_changelog);
|
||||
IntentUtil.startLinkIntent(this, R.string.dev_changelog);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -295,7 +296,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
if (licenseEnabled) {
|
||||
licensePreference.setSummary(R.string.prefs_gpl_v2);
|
||||
licensePreference.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.license_url);
|
||||
IntentUtil.startLinkIntent(this, R.string.license_url);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -316,7 +317,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
Intent intent;
|
||||
if (MimeTypeUtil.isPDF(mimeType)) {
|
||||
intent = new Intent(Intent.ACTION_VIEW, privacyUrl);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_pdf_app_available);
|
||||
IntentUtil.startIntentIfAppAvailable(intent, this, R.string.no_pdf_app_available);
|
||||
} else {
|
||||
intent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_TITLE,
|
||||
@@ -343,7 +344,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
if (sourcecodePreference != null) {
|
||||
if (sourcecodeEnabled) {
|
||||
sourcecodePreference.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.sourcecode_url);
|
||||
IntentUtil.startLinkIntent(this, R.string.sourcecode_url);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -401,7 +402,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
String imprintWeb = getString(R.string.url_imprint);
|
||||
|
||||
if (!imprintWeb.isEmpty()) {
|
||||
DisplayUtils.startLinkIntent(this, imprintWeb);
|
||||
IntentUtil.startLinkIntent(this, imprintWeb);
|
||||
}
|
||||
//ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
|
||||
return true;
|
||||
@@ -480,7 +481,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
i.putExtra("EXTRA_USER", user);
|
||||
startActivityForResult(i, ACTION_E2E);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.e2e_offline);
|
||||
SnackbarUtil.show(this, R.string.e2e_offline);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -606,7 +607,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
|
||||
preference.setOnPreferenceClickListener(p -> {
|
||||
if (!connectivityService.getConnectivity().isConnected()) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.e2e_offline);
|
||||
SnackbarUtil.show(this, R.string.e2e_offline);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -632,9 +633,9 @@ public class SettingsActivity extends PreferenceActivity
|
||||
private void onRenewE2ECertificateResult(Preference preference, E2ECertificateRenewalResult result) {
|
||||
if (result instanceof E2ECertificateRenewalResult.Success) {
|
||||
updateRenewE2ECertificateSummary(preference);
|
||||
DisplayUtils.showSnackMessage(this, R.string.renew_e2e_certificate_success);
|
||||
SnackbarUtil.show(this, R.string.renew_e2e_certificate_success);
|
||||
} else if (result instanceof E2ECertificateRenewalResult.Failure) {
|
||||
DisplayUtils.showSnackMessage(this, ((E2ECertificateRenewalResult.Failure) result).getMessageId());
|
||||
SnackbarUtil.show(this, ((E2ECertificateRenewalResult.Failure) result).getMessageId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +666,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
if (pHelp != null) {
|
||||
if (helpEnabled) {
|
||||
pHelp.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.url_help);
|
||||
IntentUtil.startLinkIntent(this, R.string.url_help);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -742,7 +743,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
launchDavDroidLogin();
|
||||
} catch (Throwable t) {
|
||||
Log_OC.e(TAG, "Error while setting up DavX5", t);
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
activity,
|
||||
R.string.prefs_davx5_setup_error);
|
||||
}
|
||||
@@ -914,9 +915,9 @@ public class SettingsActivity extends PreferenceActivity
|
||||
startActivityForResult(i, ACTION_REQUEST_PASSCODE);
|
||||
} else if (LOCK_DEVICE_CREDENTIALS.equals(lock)) {
|
||||
if (!DeviceCredentialUtils.areCredentialsAvailable(getApplicationContext())) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_lock_device_credentials_not_setup);
|
||||
SnackbarUtil.show(this, R.string.prefs_lock_device_credentials_not_setup);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_lock_device_credentials_enabled);
|
||||
SnackbarUtil.show(this, R.string.prefs_lock_device_credentials_enabled);
|
||||
changeLockSetting(LOCK_DEVICE_CREDENTIALS);
|
||||
}
|
||||
}
|
||||
@@ -1054,9 +1055,9 @@ public class SettingsActivity extends PreferenceActivity
|
||||
startActivity(installIntent);
|
||||
} else {
|
||||
// no f-droid market app or Play store installed --> launch browser for f-droid url
|
||||
DisplayUtils.startLinkIntent(this, "https://f-droid.org/packages/at.bitfire.davdroid/");
|
||||
IntentUtil.startLinkIntent(this, "https://f-droid.org/packages/at.bitfire.davdroid/");
|
||||
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_calendar_contacts_no_store_error);
|
||||
SnackbarUtil.show(this, R.string.prefs_calendar_contacts_no_store_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1097,25 +1098,25 @@ public class SettingsActivity extends PreferenceActivity
|
||||
}
|
||||
appPrefs.apply();
|
||||
changeLockSetting(LOCK_PASSCODE);
|
||||
DisplayUtils.showSnackMessage(this, R.string.pass_code_stored);
|
||||
SnackbarUtil.show(this, R.string.pass_code_stored);
|
||||
}
|
||||
} else if (requestCode == ACTION_CONFIRM_PASSCODE && resultCode == RESULT_OK) {
|
||||
if (data.getBooleanExtra(PassCodeActivity.KEY_CHECK_RESULT, false)) {
|
||||
changeLockSetting(LOCK_NONE);
|
||||
|
||||
DisplayUtils.showSnackMessage(this, R.string.pass_code_removed);
|
||||
SnackbarUtil.show(this, R.string.pass_code_removed);
|
||||
if (!LOCK_NONE.equals(pendingLock)) {
|
||||
enableLock(pendingLock);
|
||||
}
|
||||
}
|
||||
} else if (requestCode == ACTION_REQUEST_CODE_DAVDROID_SETUP && resultCode == RESULT_OK) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_calendar_contacts_sync_setup_successful);
|
||||
SnackbarUtil.show(this, R.string.prefs_calendar_contacts_sync_setup_successful);
|
||||
} else if (requestCode == ACTION_CONFIRM_DEVICE_CREDENTIALS && resultCode == RESULT_OK &&
|
||||
data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT,
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_FALSE) ==
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
|
||||
changeLockSetting(LOCK_NONE);
|
||||
DisplayUtils.showSnackMessage(this, R.string.credentials_disabled);
|
||||
SnackbarUtil.show(this, R.string.credentials_disabled);
|
||||
if (!LOCK_NONE.equals(pendingLock)) {
|
||||
enableLock(pendingLock);
|
||||
}
|
||||
@@ -1161,7 +1162,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
@VisibleForTesting
|
||||
public void handleMnemonicRequest(Intent data) {
|
||||
if (data == null) {
|
||||
DisplayUtils.showSnackMessage(this, "Error retrieving mnemonic!");
|
||||
SnackbarUtil.show(this, "Error retrieving mnemonic!");
|
||||
} else {
|
||||
if (data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT,
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_FALSE) ==
|
||||
|
||||
@@ -11,10 +11,10 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
/**
|
||||
* Only needed for SettingsActivity
|
||||
@@ -26,7 +26,7 @@ class SetupEncryptionActivity : AppCompatActivity() {
|
||||
val user = intent?.getParcelableArgument("EXTRA_USER", User::class.java)
|
||||
|
||||
if (user == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.error_showing_encryption_dialog)
|
||||
SnackbarUtil.show(this, R.string.error_showing_encryption_dialog)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.ShareActivityBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -32,7 +33,6 @@ import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.operations.GetSharesForFileOperation
|
||||
import com.owncloud.android.ui.fragment.FileDetailSharingFragment
|
||||
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -122,7 +122,7 @@ class ShareActivity :
|
||||
with(binding) {
|
||||
shareFileName.text = getString(R.string.share_file, file.fileName)
|
||||
viewThemeUtils.platform.colorViewBackground(shareHeaderDivider)
|
||||
shareFileSize.text = DisplayUtils.bytesToHumanReadable(file.fileLength)
|
||||
shareFileSize.text = HumanReadableFormatter.formatBytes(file.fileLength)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class ShareActivity :
|
||||
val length = (result.data.first() as? RemoteFile)?.length ?: return@launch
|
||||
file.fileLength = length
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.shareFileSize.text = DisplayUtils.bytesToHumanReadable(length)
|
||||
binding.shareFileSize.text = HumanReadableFormatter.formatBytes(length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ import androidx.webkit.WebViewFeature
|
||||
import com.nextcloud.android.common.ui.util.PlatformThemeUtil
|
||||
import com.nextcloud.client.appinfo.AppInfo
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.asynctasks.TextEditorLoadUrlTask
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import javax.inject.Inject
|
||||
|
||||
class TextEditorWebView : EditorWebView() {
|
||||
@@ -50,7 +50,7 @@ class TextEditorWebView : EditorWebView() {
|
||||
super.postOnCreate()
|
||||
|
||||
if (!user.isPresent) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.failed_to_start_editor)
|
||||
SnackbarUtil.show(this, R.string.failed_to_start_editor)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
@@ -251,12 +251,10 @@ public class UserInfoActivity extends DrawerActivity implements Injectable {
|
||||
private void populateUserInfoUi(UserInfo userInfo) {
|
||||
binding.userinfoUsername.setText(user.getAccountName());
|
||||
binding.userinfoIcon.setTag(user.getAccountName());
|
||||
DisplayUtils.setAvatar(user,
|
||||
this,
|
||||
mCurrentAccountAvatarRadiusDimension,
|
||||
getResources(),
|
||||
binding.userinfoIcon,
|
||||
this);
|
||||
avatarGenerator.setAccountAvatar(user,
|
||||
this,
|
||||
mCurrentAccountAvatarRadiusDimension,
|
||||
binding.userinfoIcon);
|
||||
|
||||
if (userInfo != null && !TextUtils.isEmpty(userInfo.getDisplayName())) {
|
||||
binding.userinfoFullName.setText(userInfo.getDisplayName());
|
||||
|
||||
@@ -23,7 +23,9 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter
|
||||
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.date.DateFormatPattern
|
||||
import com.nextcloud.utils.extensions.toGalleryItems
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.GalleryHeaderBinding
|
||||
@@ -36,7 +38,6 @@ import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
@@ -185,10 +186,10 @@ class GalleryAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPopupText(p0: View, position: Int): CharSequence = DisplayUtils.getDateByPattern(
|
||||
override fun getPopupText(p0: View, position: Int): CharSequence = DisplayTextFormatter.formatDate(
|
||||
files[getRelativePosition(position).section()].date,
|
||||
context,
|
||||
DisplayUtils.MONTH_YEAR_PATTERN
|
||||
DateFormatPattern.FullMonthWithYear,
|
||||
context
|
||||
)
|
||||
|
||||
override fun onBindHeaderViewHolder(holder: SectionedViewHolder?, section: Int, expanded: Boolean) {
|
||||
@@ -196,15 +197,15 @@ class GalleryAdapter(
|
||||
val headerViewHolder = holder as GalleryHeaderViewHolder
|
||||
val galleryItem = files[section]
|
||||
|
||||
headerViewHolder.binding.month.text = DisplayUtils.getDateByPattern(
|
||||
headerViewHolder.binding.month.text = DisplayTextFormatter.formatDate(
|
||||
galleryItem.date,
|
||||
context,
|
||||
DisplayUtils.MONTH_PATTERN
|
||||
DateFormatPattern.FullMonth,
|
||||
context
|
||||
)
|
||||
headerViewHolder.binding.year.text = DisplayUtils.getDateByPattern(
|
||||
headerViewHolder.binding.year.text = DisplayTextFormatter.formatDate(
|
||||
galleryItem.date,
|
||||
context,
|
||||
DisplayUtils.YEAR_PATTERN
|
||||
DateFormatPattern.Year,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ package com.owncloud.android.ui.adapter
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.InternalTwoWaySyncViewHolderBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
class InternalTwoWaySyncViewHolder(val binding: InternalTwoWaySyncViewHolderBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
@@ -25,7 +26,7 @@ class InternalTwoWaySyncViewHolder(val binding: InternalTwoWaySyncViewHolderBind
|
||||
internalTwoWaySyncAdapter: InternalTwoWaySyncAdapter
|
||||
) {
|
||||
binding.run {
|
||||
size.text = DisplayUtils.bytesToHumanReadable(folder.fileLength)
|
||||
size.text = HumanReadableFormatter.formatBytes(folder.fileLength)
|
||||
name.text = folder.decryptedFileName
|
||||
|
||||
if (folder.internalFolderSyncResult.isEmpty()) {
|
||||
@@ -40,7 +41,7 @@ class InternalTwoWaySyncViewHolder(val binding: InternalTwoWaySyncViewHolderBind
|
||||
if (folder.internalFolderSyncTimestamp == 0L) {
|
||||
syncTimestamp.text = context.getString(R.string.internal_two_way_sync_not_yet)
|
||||
} else {
|
||||
syncTimestamp.text = DisplayUtils.getRelativeTimestamp(
|
||||
syncTimestamp.text = DisplayTextFormatter.formatRelativeTimestamp(
|
||||
context,
|
||||
folder.internalFolderSyncTimestamp
|
||||
)
|
||||
|
||||
@@ -27,8 +27,10 @@ import androidx.core.view.size
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.utils.extensions.setVisibleIf
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.text.RichSubjectFormatter
|
||||
import com.nextcloud.utils.text.RichSubjectParam
|
||||
import com.owncloud.android.R
|
||||
@@ -39,7 +41,6 @@ import com.owncloud.android.lib.resources.notifications.models.RichObject
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.fragment.notifications.NotificationsAdapterItemClick
|
||||
import com.owncloud.android.ui.fragment.notifications.NotificationsFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@@ -47,12 +48,12 @@ class NotificationListAdapter(
|
||||
private val fragment: NotificationsFragment,
|
||||
private val viewThemeUtils: ViewThemeUtils,
|
||||
private val itemClick: NotificationsAdapterItemClick,
|
||||
private val accountManager: CurrentAccountProvider
|
||||
private val avatarGenerator: AvatarGenerator
|
||||
) : RecyclerView.Adapter<NotificationListAdapter.NotificationViewHolder>() {
|
||||
|
||||
private val notificationsList = ArrayList<Notification>()
|
||||
private val richSubjectFormatter by lazy {
|
||||
RichSubjectFormatter(fragment.requireContext(), accountManager)
|
||||
RichSubjectFormatter(fragment.requireContext(), avatarGenerator)
|
||||
}
|
||||
|
||||
// region Adapter overrides
|
||||
@@ -81,7 +82,7 @@ class NotificationListAdapter(
|
||||
// region Bind helpers
|
||||
|
||||
private fun bindDateTime(holder: NotificationViewHolder, notification: Notification) {
|
||||
val timestamp = DisplayUtils.getRelativeTimestamp(
|
||||
val timestamp = DisplayTextFormatter.formatRelativeTimestamp(
|
||||
fragment.requireContext(),
|
||||
notification.getDatetime().time
|
||||
)
|
||||
@@ -96,7 +97,7 @@ class NotificationListAdapter(
|
||||
setTypeface(typeface, Typeface.BOLD)
|
||||
text = subject
|
||||
setOnClickListener {
|
||||
DisplayUtils.startLinkIntent(fragment.requireActivity(), notification.getLink())
|
||||
IntentUtil.startLinkIntent(fragment.requireActivity(), notification.getLink())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -34,10 +34,14 @@ import com.nextcloud.client.database.entity.OfflineOperationEntity;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.model.OfflineOperationType;
|
||||
import com.nextcloud.utils.HumanReadableFormatter;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator;
|
||||
import com.nextcloud.utils.e2ee.E2EVersionHelper;
|
||||
import com.nextcloud.utils.extensions.ImageViewExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.ViewExtensionsKt;
|
||||
import com.nextcloud.utils.mdm.MDMConfig;
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.GridItemBinding;
|
||||
@@ -57,6 +61,7 @@ import com.owncloud.android.lib.resources.tags.Tag;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.ui.activity.DrawerActivity;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.adapter.helper.AvatarShareesProvider;
|
||||
import com.owncloud.android.ui.adapter.helper.OCFileListAdapterDataProvider;
|
||||
import com.owncloud.android.ui.adapter.helper.OCFileListAdapterHelper;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
@@ -95,7 +100,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
implements DisplayUtils.AvatarGenerationListener,
|
||||
implements AvatarGenerationListener,
|
||||
CommonOCFileListAdapterInterface, PopupTextProvider {
|
||||
|
||||
private final String userId;
|
||||
@@ -135,7 +140,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private final List<OCFile> recommendedFiles = new ArrayList<>();
|
||||
private RecommendedFilesAdapter recommendedFilesAdapter;
|
||||
private final OCFileListAdapterHelper helper = new OCFileListAdapterHelper();
|
||||
private final AvatarShareesProvider avatarShareesProvider = new AvatarShareesProvider();
|
||||
private final ThumbnailGenerator thumbnailGenerator;
|
||||
private final AvatarGenerator avatarGenerator;
|
||||
|
||||
public OCFileListAdapter(
|
||||
Activity activity,
|
||||
@@ -147,8 +154,10 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
boolean argHideItemOptions,
|
||||
boolean gridView,
|
||||
final ViewThemeUtils viewThemeUtils,
|
||||
ThumbnailGenerator thumbnailGenerator) {
|
||||
ThumbnailGenerator thumbnailGenerator,
|
||||
AvatarGenerator avatarGenerator) {
|
||||
this.thumbnailGenerator = thumbnailGenerator;
|
||||
this.avatarGenerator = avatarGenerator;
|
||||
this.ocFileListFragmentInterface = ocFileListFragmentInterface;
|
||||
this.activity = activity;
|
||||
this.preferences = preferences;
|
||||
@@ -601,6 +610,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
final var sharedAvatars = holder.getSharedAvatars();
|
||||
|
||||
if (!(file.isSharedWithMe() || file.isSharedWithSharee()) || isMultiSelect() || gridView || hideItemOptions) {
|
||||
sharedAvatars.setBoundFileId(null);
|
||||
sharedAvatars.setVisibility(View.GONE);
|
||||
if (sharedAvatars.getChildCount() > 0) {
|
||||
sharedAvatars.removeAllViews();
|
||||
@@ -608,16 +618,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
return;
|
||||
}
|
||||
|
||||
sharedAvatars.setVisibility(View.VISIBLE);
|
||||
if (sharedAvatars.getChildCount() > 0) {
|
||||
sharedAvatars.removeAllViews();
|
||||
}
|
||||
final long fileId = file.getFileId();
|
||||
sharedAvatars.setBoundFileId(fileId);
|
||||
sharedAvatars.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
||||
|
||||
helper.getAvatarSharees(file, user, userId, avatars -> {
|
||||
sharedAvatars.setAvatars(user, avatars, viewThemeUtils);
|
||||
sharedAvatars.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
sharedAvatars.setAvatars(user, avatarShareesProvider.get(file, userId), viewThemeUtils, avatarGenerator);
|
||||
}
|
||||
|
||||
private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
|
||||
@@ -674,12 +679,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
final long modificationTimestamp = file.getModificationTimestamp();
|
||||
if (modificationTimestamp > 0) {
|
||||
holder.getLastModification().setText(DisplayUtils.getRelativeTimestamp(activity,
|
||||
modificationTimestamp));
|
||||
holder.getLastModification().setText(
|
||||
DisplayTextFormatter.formatRelativeTimestamp(activity, modificationTimestamp));
|
||||
holder.getLastModification().setVisibility(View.VISIBLE);
|
||||
} else if (file.getFirstShareTimestamp() > 0) {
|
||||
holder.getLastModification().setText(
|
||||
DisplayUtils.getRelativeTimestamp(activity, file.getFirstShareTimestamp())
|
||||
DisplayTextFormatter.formatRelativeTimestamp(activity, file.getFirstShareTimestamp())
|
||||
);
|
||||
holder.getLastModification().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@@ -743,7 +748,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
private String getFileSizeText(OCFile file, long size) {
|
||||
if (!file.isOfflineOperation()) {
|
||||
return DisplayUtils.bytesToHumanReadable(size);
|
||||
return HumanReadableFormatter.formatBytes(size);
|
||||
}
|
||||
|
||||
OfflineOperationEntity entity = mStorageManager.getOfflineEntityFromOCFile(file);
|
||||
@@ -1046,7 +1051,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
Date date = new Date(milliseconds);
|
||||
return dateFormat.format(date);
|
||||
case SIZE:
|
||||
return DisplayUtils.bytesToHumanReadable(file.getFileLength());
|
||||
return HumanReadableFormatter.formatBytes(file.getFileLength());
|
||||
default:
|
||||
Log_OC.d(TAG, "getPopupText: Unsupported sort order: " + sortOrder.getType());
|
||||
return "";
|
||||
|
||||
@@ -9,10 +9,10 @@ package com.owncloud.android.ui.adapter
|
||||
|
||||
import android.content.Context
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.PredefinedStatusBinding
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
private const val ONE_SECOND_IN_MILLIS = 1000
|
||||
|
||||
@@ -28,7 +28,7 @@ class PredefinedStatusViewHolder(private val binding: PredefinedStatusBinding) :
|
||||
} else {
|
||||
val clearAt = status.clearAt!!
|
||||
if (clearAt.type.equals("period")) {
|
||||
binding.clearAt.text = DisplayUtils.getRelativeTimestamp(
|
||||
binding.clearAt.text = DisplayTextFormatter.formatRelativeTimestamp(
|
||||
context,
|
||||
System.currentTimeMillis() + clearAt.time.toInt() * ONE_SECOND_IN_MILLIS,
|
||||
true
|
||||
|
||||
@@ -15,6 +15,8 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.databinding.UploaderListItemLayoutBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -24,10 +26,8 @@ import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.AsyncThumbnailDrawable
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.ThumbnailGenerationTask
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.ThumbnailGenerationTaskObject
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.util.Objects
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class ReceiveExternalFilesAdapter(
|
||||
@@ -80,10 +80,11 @@ class ReceiveExternalFilesAdapter(
|
||||
val file = filteredFiles[position]
|
||||
|
||||
viewHolder.binding.filename.text = file.fileName
|
||||
viewHolder.binding.lastMod.text = DisplayUtils.getRelativeTimestamp(context, file.modificationTimestamp)
|
||||
viewHolder.binding.lastMod.text =
|
||||
DisplayTextFormatter.formatRelativeTimestamp(context, file.modificationTimestamp)
|
||||
|
||||
if (!file.isFolder) {
|
||||
viewHolder.binding.fileSize.text = DisplayUtils.bytesToHumanReadable(file.fileLength)
|
||||
viewHolder.binding.fileSize.text = HumanReadableFormatter.formatBytes(file.fileLength)
|
||||
}
|
||||
|
||||
viewHolder.binding.fileSize.visibility = if (file.isFolder) {
|
||||
|
||||
@@ -19,6 +19,8 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator;
|
||||
import com.nextcloud.utils.extensions.ImageViewExtensionsKt;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.FileDetailsShareShareItemBinding;
|
||||
@@ -26,7 +28,6 @@ import com.owncloud.android.datamodel.quickPermission.QuickPermissionType;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.ui.fragment.util.SharePermissionManager;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -39,6 +40,7 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||
private Context context;
|
||||
private ViewThemeUtils viewThemeUtils;
|
||||
private boolean encrypted;
|
||||
private AvatarGenerator avatarGenerator;
|
||||
|
||||
public ShareViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@@ -48,18 +50,20 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||
User user,
|
||||
Context context,
|
||||
final ViewThemeUtils viewThemeUtils,
|
||||
boolean encrypted) {
|
||||
boolean encrypted,
|
||||
AvatarGenerator avatarGenerator) {
|
||||
this(binding.getRoot());
|
||||
this.binding = binding;
|
||||
this.user = user;
|
||||
this.context = context;
|
||||
this.viewThemeUtils = viewThemeUtils;
|
||||
this.encrypted = encrypted;
|
||||
this.avatarGenerator = avatarGenerator;
|
||||
}
|
||||
|
||||
public void bind(OCShare share,
|
||||
ShareeListAdapterListener listener,
|
||||
DisplayUtils.AvatarGenerationListener avatarListener,
|
||||
AvatarGenerationListener avatarListener,
|
||||
String userId,
|
||||
float avatarRadiusDimension) {
|
||||
this.avatarRadiusDimension = avatarRadiusDimension;
|
||||
@@ -93,14 +97,12 @@ class ShareViewHolder extends RecyclerView.ViewHolder {
|
||||
float avatarRadius = context.getResources().getDimension(R.dimen.list_item_avatar_icon_radius);
|
||||
|
||||
if (share.getShareWith() != null) {
|
||||
DisplayUtils.setAvatar(user,
|
||||
share.getShareWith(),
|
||||
share.getSharedWithDisplayName(),
|
||||
avatarListener,
|
||||
avatarRadius,
|
||||
context.getResources(),
|
||||
binding.icon,
|
||||
context);
|
||||
avatarGenerator.setUserAvatar(share.getShareWith(),
|
||||
avatarListener,
|
||||
avatarRadius,
|
||||
binding.icon,
|
||||
share.getSharedWithDisplayName(),
|
||||
user);
|
||||
}
|
||||
|
||||
binding.icon.setOnClickListener(v -> listener.showProfileBottomSheet(user, share.getShareWith()));
|
||||
|
||||
@@ -18,6 +18,8 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.utils.mdm.MDMConfig.shareViaLink
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.FileDetailsShareInternalShareLinkBinding
|
||||
@@ -29,7 +31,6 @@ import com.owncloud.android.datamodel.SharesType
|
||||
import com.owncloud.android.lib.resources.shares.OCShare
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.ui.activity.FileActivity
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -45,7 +46,8 @@ class ShareeListAdapter(
|
||||
private val user: User?,
|
||||
private val viewThemeUtils: ViewThemeUtils,
|
||||
private val encrypted: Boolean,
|
||||
private val sharesType: SharesType?
|
||||
private val sharesType: SharesType?,
|
||||
private val avatarGenerator: AvatarGenerator
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder?>(),
|
||||
AvatarGenerationListener {
|
||||
private val avatarRadiusDimension: Float = fileActivity.getResources().getDimension(R.dimen.user_icon_radius)
|
||||
@@ -86,7 +88,7 @@ class ShareeListAdapter(
|
||||
|
||||
else -> {
|
||||
val binding = FileDetailsShareShareItemBinding.inflate(inflater, parent, false)
|
||||
ShareViewHolder(binding, user, fileActivity, viewThemeUtils, encrypted)
|
||||
ShareViewHolder(binding, user, fileActivity, viewThemeUtils, encrypted, avatarGenerator)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,11 +154,10 @@ class ShareeListAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldCallGeneratedCallback(tag: String, callContext: Any?): Boolean {
|
||||
override fun shouldCallGeneratedCallback(tag: String?, callContext: Any?): Boolean {
|
||||
if (callContext is ImageView) {
|
||||
// needs to be changed once federated users have avatars
|
||||
return callContext.tag.toString() == tag.split("@".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
.toTypedArray()[0]
|
||||
return callContext.tag.toString() == tag?.substringBefore('@')
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -20,8 +20,10 @@ import android.widget.ImageView;
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.utils.HumanReadableFormatter;
|
||||
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.ViewExtensionsKt;
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter;
|
||||
import com.nextcloud.utils.thumbnail.VideoOverlayGenerator;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.ListFooterBinding;
|
||||
@@ -32,7 +34,6 @@ import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
import com.owncloud.android.ui.interfaces.TrashbinActivityInterface;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
@@ -137,7 +138,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
trashbinFileViewHolder.binding.Filename.setText(file.getFileName());
|
||||
|
||||
// fileSize
|
||||
trashbinFileViewHolder.binding.fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||
trashbinFileViewHolder.binding.fileSize.setText(HumanReadableFormatter.formatBytes(file.getFileLength()));
|
||||
|
||||
// originalLocation
|
||||
String location;
|
||||
@@ -150,8 +151,8 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
trashbinFileViewHolder.binding.originalLocation.setText(location);
|
||||
|
||||
// deletion time
|
||||
trashbinFileViewHolder.binding.deletionTimestamp.setText(DisplayUtils.getRelativeTimestamp(context,
|
||||
file.getDeletionTimestamp() * 1000));
|
||||
trashbinFileViewHolder.binding.deletionTimestamp.setText(
|
||||
DisplayTextFormatter.formatRelativeTimestamp(context, file.getDeletionTimestamp() * 1000));
|
||||
|
||||
// checkbox
|
||||
if (isCheckedFile(file)) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import android.widget.ImageView;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener;
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator;
|
||||
import com.nextcloud.utils.mdm.MDMConfig;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.AccountActionBinding;
|
||||
@@ -39,7 +41,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
implements DisplayUtils.AvatarGenerationListener {
|
||||
implements AvatarGenerationListener {
|
||||
private static final String TAG = UserListAdapter.class.getSimpleName();
|
||||
|
||||
private final float accountAvatarRadiusDimension;
|
||||
@@ -55,6 +57,7 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
private final boolean showDotsMenu;
|
||||
private boolean highlightCurrentlyActiveAccount;
|
||||
private final ViewThemeUtils viewThemeUtils;
|
||||
private final AvatarGenerator avatarGenerator;
|
||||
|
||||
public UserListAdapter(Context context,
|
||||
UserAccountManager accountManager,
|
||||
@@ -63,7 +66,8 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
boolean showAddAccount,
|
||||
boolean showDotsMenu,
|
||||
boolean highlightCurrentlyActiveAccount,
|
||||
final ViewThemeUtils viewThemeUtils) {
|
||||
final ViewThemeUtils viewThemeUtils,
|
||||
AvatarGenerator avatarGenerator) {
|
||||
this.context = context;
|
||||
this.accountManager = accountManager;
|
||||
this.values = values;
|
||||
@@ -76,6 +80,7 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
this.showDotsMenu = showDotsMenu;
|
||||
this.viewThemeUtils = viewThemeUtils;
|
||||
this.highlightCurrentlyActiveAccount = highlightCurrentlyActiveAccount;
|
||||
this.avatarGenerator = avatarGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +223,7 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
public void bind(User user,
|
||||
boolean userListItemEnabled,
|
||||
boolean highlightCurrentlyActiveAccount,
|
||||
DisplayUtils.AvatarGenerationListener avatarGenerationListener) {
|
||||
AvatarGenerationListener avatarGenerationListener) {
|
||||
setData(user);
|
||||
setUser(user);
|
||||
setUsername(user);
|
||||
@@ -269,16 +274,14 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
*
|
||||
* @param user the account
|
||||
*/
|
||||
private void setAvatar(User user, DisplayUtils.AvatarGenerationListener avatarGenerationListener) {
|
||||
private void setAvatar(User user, AvatarGenerationListener avatarGenerationListener) {
|
||||
try {
|
||||
View viewItem = binding.userIcon;
|
||||
viewItem.setTag(user.getAccountName());
|
||||
DisplayUtils.setAvatar(user,
|
||||
avatarGenerationListener,
|
||||
accountAvatarRadiusDimension,
|
||||
context.getResources(),
|
||||
viewItem,
|
||||
context);
|
||||
avatarGenerator.setAccountAvatar(user,
|
||||
avatarGenerationListener,
|
||||
accountAvatarRadiusDimension,
|
||||
viewItem);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error calculating RGB value for account list item.", e);
|
||||
// use user icon as a fallback
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nextcloud.utils.date.DateFormatPattern
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailArguments
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import com.owncloud.android.R
|
||||
@@ -22,7 +23,6 @@ import com.owncloud.android.databinding.AlbumsListItemBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.albums.PhotoAlbumEntry
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class AlbumsAdapter(
|
||||
@@ -52,7 +52,7 @@ class AlbumsAdapter(
|
||||
R.plurals.album_items_text,
|
||||
file.nbItems,
|
||||
file.nbItems,
|
||||
DisplayUtils.getDateByPattern(file.createdDate, DateFormatPattern.MonthWithYear.pattern)
|
||||
DisplayTextFormatter.formatDate(file.createdDate, DateFormatPattern.MonthWithYear)
|
||||
)
|
||||
|
||||
gridViewHolder.albumName.setCompoundDrawablesWithIntrinsicBounds(
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.adapter.helper
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
|
||||
class AvatarShareesProvider {
|
||||
|
||||
fun get(file: OCFile, userId: String?): List<ShareeUser> {
|
||||
val sharees = file.sharees
|
||||
|
||||
val ownerSharee = file.ownerId
|
||||
?.takeIf { it.isNotEmpty() && it != userId }
|
||||
?.let { ShareeUser(it, file.ownerDisplayName, ShareType.USER) }
|
||||
?.takeIf { it !in sharees }
|
||||
|
||||
return listOfNotNull(ownerSharee) + sharees.asReversed()
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,12 @@
|
||||
|
||||
package com.owncloud.android.ui.adapter.helper
|
||||
|
||||
import com.nextcloud.android.common.ui.share.avatar.ShareAvatarRepository
|
||||
import com.nextcloud.android.common.ui.share.model.api.share.Share
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.database.entity.FileEntity
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.utils.extensions.filterFilenames
|
||||
import com.nextcloud.utils.extensions.isTempFile
|
||||
import com.nextcloud.utils.extensions.supportsUnifiedShare
|
||||
import com.nextcloud.utils.extensions.toServerCredentials
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -61,38 +54,6 @@ class OCFileListAdapterHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun getAvatarSharees(file: OCFile, user: User?, userId: String?, onComplete: (List<ShareeUser>) -> Unit) {
|
||||
scope.launch {
|
||||
val credentials = user?.toServerCredentials()
|
||||
val result = if (credentials != null && credentials.supportsUnifiedShare()) {
|
||||
ShareAvatarRepository(
|
||||
credentials
|
||||
).fetchShareAvatars(file.localId.toString())?.toAvatarSharees().orEmpty()
|
||||
} else {
|
||||
file.toLocalSharees(userId)
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
onComplete(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun OCFile.toLocalSharees(userId: String?): List<ShareeUser> {
|
||||
val ownerSharee = ownerId
|
||||
?.takeIf { it.isNotEmpty() && it != userId }
|
||||
?.let { ShareeUser(it, ownerDisplayName, ShareType.USER) }
|
||||
?.takeIf { it !in sharees }
|
||||
|
||||
return listOfNotNull(ownerSharee) + sharees.asReversed()
|
||||
}
|
||||
|
||||
private fun List<Share>.toAvatarSharees(): List<ShareeUser> = asSequence()
|
||||
.flatMap { share -> share.invitedRecipients }
|
||||
.distinctBy { recipient -> recipient.value }
|
||||
.map { recipient -> ShareeUser(recipient.value, recipient.displayName, ShareType.USER) }
|
||||
.toList()
|
||||
|
||||
suspend fun prepareFileList(
|
||||
directory: OCFile,
|
||||
dataProvider: OCFileListAdapterDataProvider,
|
||||
|
||||
+4
-3
@@ -10,9 +10,10 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.ui.interfaces.LocalFileListFragmentInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.io.File
|
||||
|
||||
@@ -76,9 +77,9 @@ internal class LocalFileListItemBinder(
|
||||
} else {
|
||||
holder.fileSize.visibility = View.VISIBLE
|
||||
holder.fileSeparator.visibility = View.VISIBLE
|
||||
holder.fileSize.text = DisplayUtils.bytesToHumanReadable(file.length())
|
||||
holder.fileSize.text = HumanReadableFormatter.formatBytes(file.length())
|
||||
}
|
||||
|
||||
holder.lastModification.text = DisplayUtils.getRelativeTimestamp(activity, file.lastModified())
|
||||
holder.lastModification.text = DisplayTextFormatter.formatRelativeTimestamp(activity, file.lastModified())
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,14 @@ import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.utils.HumanReadableFormatter
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getStatusText
|
||||
import com.nextcloud.utils.extensions.isLastResultConflictError
|
||||
import com.nextcloud.utils.extensions.setVisibleIf
|
||||
import com.nextcloud.utils.extensions.sortedByUploadOrder
|
||||
import com.nextcloud.utils.extensions.toFile
|
||||
import com.nextcloud.utils.text.DisplayTextFormatter
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.UploadListHeaderBinding
|
||||
@@ -45,7 +48,6 @@ import com.owncloud.android.ui.adapter.uploadList.helper.UploadListAdapterHelper
|
||||
import com.owncloud.android.ui.adapter.uploadList.helper.UploadListItemOnClick
|
||||
import com.owncloud.android.ui.adapter.uploadList.model.UploadListSection
|
||||
import com.owncloud.android.ui.adapter.uploadList.model.UploadListType
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -235,7 +237,7 @@ class UploadListAdapter(
|
||||
)
|
||||
if (showNotExistMessage) {
|
||||
withContext(Dispatchers.Main) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.upload_action_file_not_exist_message)
|
||||
SnackbarUtil.show(activity, R.string.upload_action_file_not_exist_message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +277,7 @@ class UploadListAdapter(
|
||||
fileSizeFormat = "%s, "
|
||||
}
|
||||
|
||||
val fileSizeInBytes = DisplayUtils.bytesToHumanReadable(item.fileSize)
|
||||
val fileSizeInBytes = HumanReadableFormatter.formatBytes(item.fileSize)
|
||||
val uploadFileSize = String.format(fileSizeFormat, fileSizeInBytes)
|
||||
holder.binding.uploadFileSize.text = uploadFileSize
|
||||
} else {
|
||||
@@ -296,12 +298,10 @@ class UploadListAdapter(
|
||||
holder.binding.uploadDate.setVisibleIf(showDate)
|
||||
|
||||
if (showDate) {
|
||||
holder.binding.uploadDate.text = DisplayUtils.getRelativeDateTimeString(
|
||||
holder.binding.uploadDate.text = DisplayTextFormatter.formatRelativeDateTime(
|
||||
activity,
|
||||
updateTime,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
DateUtils.MINUTE_IN_MILLIS
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class UploadListAdapter(
|
||||
holder.binding.uploadAccount.visibility = View.VISIBLE
|
||||
val optionalUser = accountManager.getUser(item.accountName)
|
||||
holder.binding.uploadAccount.text = if (optionalUser.isPresent) {
|
||||
DisplayUtils.getAccountNameDisplayText(optionalUser.get())
|
||||
DisplayTextFormatter.formatAccountName(optionalUser.get())
|
||||
} else {
|
||||
item.accountName
|
||||
}
|
||||
@@ -478,7 +478,7 @@ class UploadListAdapter(
|
||||
if (file != null) {
|
||||
uploadHelper.retryUpload(item, user.get())
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(
|
||||
SnackbarUtil.show(
|
||||
activity,
|
||||
R.string.local_file_not_found_message
|
||||
)
|
||||
|
||||
+5
-5
@@ -11,6 +11,7 @@ import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.core.content.FileProvider
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.OCUpload
|
||||
@@ -19,7 +20,6 @@ import com.owncloud.android.ui.activity.ConflictsResolveActivity
|
||||
import com.owncloud.android.ui.activity.FileActivity
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import java.io.File
|
||||
@@ -52,13 +52,13 @@ class UploadListAdapterHelper(private val activity: FileActivity) {
|
||||
return
|
||||
}
|
||||
|
||||
DisplayUtils.showSnackMessage(activity, R.string.local_file_not_found_message)
|
||||
SnackbarUtil.show(activity, R.string.local_file_not_found_message)
|
||||
}
|
||||
|
||||
fun onUploadedItemClick(upload: OCUpload) {
|
||||
val file = activity.storageManager.getFileByEncryptedRemotePath(upload.remotePath)
|
||||
if (file == null) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.error_retrieving_file)
|
||||
SnackbarUtil.show(activity, R.string.error_retrieving_file)
|
||||
Log_OC.i(TAG, "Could not find uploaded file on remote.")
|
||||
return
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class UploadListAdapterHelper(private val activity: FileActivity) {
|
||||
fun openFileWithDefault(localPath: String) {
|
||||
val uri = contentUriFor(localPath)
|
||||
if (uri == null) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.error_retrieving_file)
|
||||
SnackbarUtil.show(activity, R.string.error_retrieving_file)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class UploadListAdapterHelper(private val activity: FileActivity) {
|
||||
}
|
||||
activity.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.file_list_no_app_for_file_type)
|
||||
SnackbarUtil.show(activity, R.string.file_list_no_app_for_file_type)
|
||||
Log_OC.i(TAG, "Could not find app for opening the local file: $e")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import android.print.PrintAttributes;
|
||||
import android.print.PrintDocumentAdapter;
|
||||
import android.print.PrintManager;
|
||||
|
||||
import com.nextcloud.utils.SnackbarUtil;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.activity.RichDocumentsEditorWebView;
|
||||
import com.owncloud.android.ui.adapter.PrintAdapter;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
@@ -129,7 +129,7 @@ public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
||||
PrintManager printManager = (PrintManager) richDocumentsWebView.getSystemService(PRINT_SERVICE);
|
||||
|
||||
if (!result || printManager == null) {
|
||||
DisplayUtils.showSnackMessage(richDocumentsWebView,
|
||||
SnackbarUtil.show(richDocumentsWebView,
|
||||
richDocumentsWebView.getString(R.string.failed_to_print));
|
||||
|
||||
return;
|
||||
|
||||
@@ -11,21 +11,24 @@ import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.android.lib.resources.profile.GetHoverCardRemoteOperation
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class RetrieveHoverCardAsyncTask(
|
||||
private val user: User,
|
||||
private val userId: String,
|
||||
private val activity: FragmentActivity,
|
||||
private val clientFactory: ClientFactory,
|
||||
private val viewThemeUtils: ViewThemeUtils
|
||||
private val viewThemeUtils: ViewThemeUtils,
|
||||
private val avatarGenerator: AvatarGenerator
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "RetrieveHoverCardAsyncTask"
|
||||
@@ -51,7 +54,7 @@ class RetrieveHoverCardAsyncTask(
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
if (result?.actions.isNullOrEmpty()) {
|
||||
DisplayUtils.showSnackMessage(activity, R.string.no_actions)
|
||||
SnackbarUtil.show(activity, R.string.no_actions)
|
||||
return@withContext
|
||||
}
|
||||
|
||||
@@ -59,7 +62,8 @@ class RetrieveHoverCardAsyncTask(
|
||||
activity,
|
||||
user,
|
||||
result,
|
||||
viewThemeUtils
|
||||
viewThemeUtils,
|
||||
avatarGenerator
|
||||
)
|
||||
.show()
|
||||
}
|
||||
|
||||
@@ -20,13 +20,15 @@ import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
import com.nextcloud.client.player.media3.PlaybackModel
|
||||
import com.nextcloud.client.utils.IntentUtil
|
||||
import com.nextcloud.utils.avatar.AvatarGenerationListener
|
||||
import com.nextcloud.utils.avatar.AvatarGenerator
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.AccountRemovalDialogBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.ui.dialog.extensions.themeButtons
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -44,6 +46,9 @@ class AccountRemovalDialog :
|
||||
@Inject
|
||||
lateinit var playbackModel: PlaybackModel
|
||||
|
||||
@Inject
|
||||
lateinit var avatarGenerator: AvatarGenerator
|
||||
|
||||
private var user: User? = null
|
||||
private lateinit var alertDialog: AlertDialog
|
||||
private var _binding: AccountRemovalDialogBinding? = null
|
||||
@@ -131,7 +136,7 @@ class AccountRemovalDialog :
|
||||
user?.let { user ->
|
||||
stopMediaPlayerAndHidePip()
|
||||
if (binding.radioRequestDeletion.isChecked) {
|
||||
DisplayUtils.startLinkIntent(activity, user.server.uri.toString() + DROP_ACCOUNT_URI)
|
||||
IntentUtil.startLinkIntent(requireActivity(), user.server.uri.toString() + DROP_ACCOUNT_URI)
|
||||
} else {
|
||||
backgroundJobManager.startAccountRemovalJob(user.accountName, false)
|
||||
}
|
||||
@@ -149,13 +154,11 @@ class AccountRemovalDialog :
|
||||
try {
|
||||
val imageView = binding.userIcon
|
||||
imageView.tag = user!!.accountName
|
||||
DisplayUtils.setAvatar(
|
||||
avatarGenerator.setAccountAvatar(
|
||||
user!!,
|
||||
this,
|
||||
resources.getDimension(R.dimen.list_item_avatar_icon_radius),
|
||||
resources,
|
||||
imageView,
|
||||
context
|
||||
imageView
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
||||
+6
-6
@@ -24,6 +24,7 @@ import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.extensions.getTypedActivity
|
||||
import com.nextcloud.utils.fileNameValidator.FileNameValidator
|
||||
@@ -43,7 +44,6 @@ import com.owncloud.android.ui.activity.ExternalSiteWebView
|
||||
import com.owncloud.android.ui.activity.RichDocumentsEditorWebView
|
||||
import com.owncloud.android.ui.adapter.RichDocumentsTemplateAdapter
|
||||
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog.Companion.newInstance
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.KeyboardUtils
|
||||
import com.owncloud.android.utils.NextcloudServer
|
||||
@@ -237,15 +237,15 @@ class ChooseRichDocumentsTemplateDialogFragment :
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val selectedTemplate = adapter?.selectedTemplate
|
||||
?: return DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template)
|
||||
?: return SnackbarUtil.show(binding.list, R.string.select_one_template)
|
||||
|
||||
val state = resolveFilenameState()
|
||||
when (state) {
|
||||
is FilenameState.Invalid ->
|
||||
DisplayUtils.showSnackMessage(requireActivity(), state.errorMessage)
|
||||
SnackbarUtil.show(requireActivity(), state.errorMessage)
|
||||
|
||||
is FilenameState.JustExtension ->
|
||||
DisplayUtils.showSnackMessage(binding.list, R.string.enter_filename)
|
||||
SnackbarUtil.show(binding.list, R.string.enter_filename)
|
||||
|
||||
is FilenameState.Valid -> {
|
||||
val name = fileNameText
|
||||
@@ -387,7 +387,7 @@ class ChooseRichDocumentsTemplateDialogFragment :
|
||||
if (!isAdded) return@withContext
|
||||
waitDialog?.dismiss()
|
||||
dismiss()
|
||||
DisplayUtils.showSnackMessage(requireActivity(), stringRes)
|
||||
SnackbarUtil.show(requireActivity(), stringRes)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -411,7 +411,7 @@ class ChooseRichDocumentsTemplateDialogFragment :
|
||||
withContext(Dispatchers.Main) {
|
||||
if (templateList.isEmpty()) {
|
||||
dismiss()
|
||||
DisplayUtils.showSnackMessage(requireActivity(), R.string.error_retrieving_templates)
|
||||
SnackbarUtil.show(requireActivity(), R.string.error_retrieving_templates)
|
||||
return@withContext
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.nextcloud.client.network.ClientFactory.CreationException
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.fileNameValidator.FileNameValidator
|
||||
import com.owncloud.android.MainApp
|
||||
@@ -48,7 +49,6 @@ import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activity.ExternalSiteWebView
|
||||
import com.owncloud.android.ui.activity.TextEditorWebView
|
||||
import com.owncloud.android.ui.adapter.TemplateAdapter
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.KeyboardUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
@@ -227,11 +227,11 @@ class ChooseTemplateDialogFragment :
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val selectedTemplate = adapter?.selectedTemplate
|
||||
?: return DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template)
|
||||
?: return SnackbarUtil.show(binding.list, R.string.select_one_template)
|
||||
|
||||
val state = resolveFilenameState()
|
||||
if (state !is TemplateFilenameState.Valid) {
|
||||
state.errorMessage?.let { DisplayUtils.showSnackMessage(requireActivity(), it.toString()) }
|
||||
state.errorMessage?.let { SnackbarUtil.show(requireActivity(), it.toString()) }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ class ChooseTemplateDialogFragment :
|
||||
path,
|
||||
creator?.editor,
|
||||
creator?.id,
|
||||
template.title
|
||||
template.id
|
||||
).execute(nextcloudClient)
|
||||
if (!result.isSuccess) {
|
||||
return ""
|
||||
@@ -340,7 +340,7 @@ class ChooseTemplateDialogFragment :
|
||||
}
|
||||
|
||||
if (url.isEmpty()) {
|
||||
DisplayUtils.showSnackMessage(fragment.binding.list, R.string.error_creating_file_from_template)
|
||||
SnackbarUtil.show(fragment.binding.list, R.string.error_creating_file_from_template)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ class ChooseTemplateDialogFragment :
|
||||
|
||||
if (templateList.templates.isEmpty()) {
|
||||
fragment.dismiss()
|
||||
DisplayUtils.showSnackMessage(fragment.requireActivity(), R.string.error_retrieving_templates)
|
||||
SnackbarUtil.show(fragment.requireActivity(), R.string.error_retrieving_templates)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.extensions.typedActivity
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.CreateAlbumDialogBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.KeyboardUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import javax.inject.Inject
|
||||
@@ -159,7 +159,7 @@ class CreateAlbumDialogFragment :
|
||||
}
|
||||
|
||||
if (errorMessage != null) {
|
||||
DisplayUtils.showSnackMessage(requireActivity(), errorMessage)
|
||||
SnackbarUtil.show(requireActivity(), errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class CreateAlbumDialogFragment :
|
||||
return@isNetworkAndServerAvailable
|
||||
}
|
||||
|
||||
DisplayUtils.showSnackMessage(requireActivity(), getString(R.string.offline_mode))
|
||||
SnackbarUtil.show(requireActivity(), getString(R.string.offline_mode))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.common.collect.Sets
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.utils.SnackbarUtil
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.nextcloud.utils.extensions.typedActivity
|
||||
@@ -38,7 +39,6 @@ import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.KeyboardUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -187,7 +187,7 @@ class CreateFolderDialogFragment :
|
||||
FileNameValidator.checkFileName(newFolderName, capabilities, requireContext())
|
||||
|
||||
if (errorMessage != null) {
|
||||
DisplayUtils.showSnackMessage(requireActivity(), errorMessage)
|
||||
SnackbarUtil.show(requireActivity(), errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 162 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user