mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 05:05:31 +03:00
Merge pull request #5496 from nextcloud/fix/5232
properly colorize text preview gradient based on theme (day/night)
This commit is contained in:
commit
3dde163c70
7 changed files with 160 additions and 10 deletions
BIN
screenshots/richworkspaces_dark.png
Normal file
BIN
screenshots/richworkspaces_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
screenshots/richworkspaces_light.png
Normal file
BIN
screenshots/richworkspaces_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -38,6 +38,8 @@ docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ user
|
||||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:add users\""
|
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:add users\""
|
||||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user1\""
|
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user1\""
|
||||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user2\""
|
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user2\""
|
||||||
|
docker exec uiComparison /bin/sh -c "su www-data -c \"git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/\""
|
||||||
|
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ app:enable text\""
|
||||||
docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"
|
docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"
|
||||||
|
|
||||||
## update/create all screenshots
|
## update/create all screenshots
|
||||||
|
|
|
@ -124,7 +124,7 @@ public abstract class AbstractIT {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileDataStorageManager getStorageManager() {
|
protected FileDataStorageManager getStorageManager() {
|
||||||
return new FileDataStorageManager(account, targetContext.getContentResolver());
|
return new FileDataStorageManager(account, targetContext.getContentResolver());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Nextcloud Android client application
|
||||||
|
*
|
||||||
|
* @author Tobias Kaminsky
|
||||||
|
* Copyright (C) 2020 Tobias Kaminsky
|
||||||
|
* Copyright (C) 2020 Nextcloud GmbH
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.owncloud.android.ui.fragment
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import androidx.test.core.app.ActivityScenario
|
||||||
|
import androidx.test.rule.GrantPermissionRule
|
||||||
|
import com.evernote.android.job.JobRequest
|
||||||
|
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||||
|
import com.nextcloud.client.device.PowerManagementService
|
||||||
|
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.owncloud.android.AbstractIT
|
||||||
|
import com.owncloud.android.MainApp
|
||||||
|
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||||
|
import com.owncloud.android.db.OCUpload
|
||||||
|
import com.owncloud.android.files.services.FileUploader
|
||||||
|
import com.owncloud.android.operations.CreateFolderOperation
|
||||||
|
import com.owncloud.android.operations.RefreshFolderOperation
|
||||||
|
import com.owncloud.android.operations.UploadFileOperation
|
||||||
|
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||||
|
import com.owncloud.android.utils.FileStorageUtils
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class OCFileListFragmentIT : AbstractIT() {
|
||||||
|
@get:Rule
|
||||||
|
val permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
|
||||||
|
private val connectivityServiceMock: ConnectivityService = object : ConnectivityService {
|
||||||
|
override fun isInternetWalled(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isOnlineWithWifi(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getActiveNetworkType(): JobRequest.NetworkType {
|
||||||
|
return JobRequest.NetworkType.ANY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val powerManagementServiceMock: PowerManagementService = object : PowerManagementService {
|
||||||
|
override val isPowerSavingEnabled: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
override val isPowerSavingExclusionAvailable: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
override val isBatteryCharging: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showRichWorkspace() {
|
||||||
|
assertTrue(CreateFolderOperation("/test/", true).execute(client, storageManager).isSuccess)
|
||||||
|
|
||||||
|
val ocUpload = OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||||
|
"/test/Readme.md",
|
||||||
|
account.name)
|
||||||
|
val newUpload = UploadFileOperation(
|
||||||
|
UploadsStorageManager(UserAccountManagerImpl.fromContext(targetContext), targetContext.contentResolver),
|
||||||
|
connectivityServiceMock,
|
||||||
|
powerManagementServiceMock,
|
||||||
|
account,
|
||||||
|
null,
|
||||||
|
ocUpload,
|
||||||
|
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||||
|
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||||
|
targetContext,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
newUpload.addRenameUploadListener {}
|
||||||
|
|
||||||
|
newUpload.setRemoteFolderToBeCreated()
|
||||||
|
|
||||||
|
assertTrue(newUpload.execute(client, storageManager).isSuccess)
|
||||||
|
|
||||||
|
assertTrue(RefreshFolderOperation(storageManager.getFileByPath("/test/"),
|
||||||
|
System.currentTimeMillis() / 1000,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
storageManager,
|
||||||
|
account,
|
||||||
|
targetContext).execute(client).isSuccess)
|
||||||
|
|
||||||
|
val sut = ActivityScenario.launch(FileDisplayActivity::class.java)
|
||||||
|
sut.onActivity { activity -> activity.onBrowsedDownTo(storageManager.getFileByPath("/test/")) }
|
||||||
|
|
||||||
|
Thread.sleep(2000)
|
||||||
|
|
||||||
|
sut.onActivity { activity ->
|
||||||
|
com.facebook.testing.screenshot.Screenshot.snapActivity(activity).setName("richworkspaces_light").record()
|
||||||
|
}
|
||||||
|
|
||||||
|
val preferences: AppPreferences = AppPreferencesImpl.fromContext(targetContext)
|
||||||
|
preferences.darkThemeMode = DarkMode.DARK
|
||||||
|
MainApp.setAppTheme(DarkMode.DARK)
|
||||||
|
|
||||||
|
sut.onActivity { activity -> activity.onBackPressed() }
|
||||||
|
|
||||||
|
sut.recreate()
|
||||||
|
|
||||||
|
sut.onActivity { activity -> activity.onBrowsedDownTo(storageManager.getFileByPath("/test/")) }
|
||||||
|
|
||||||
|
Thread.sleep(2000)
|
||||||
|
|
||||||
|
sut.onActivity { activity ->
|
||||||
|
com.facebook.testing.screenshot.Screenshot.snapActivity(activity).setName("richworkspaces_dark").record()
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch back to light mode
|
||||||
|
preferences.darkThemeMode = DarkMode.LIGHT
|
||||||
|
MainApp.setAppTheme(DarkMode.LIGHT)
|
||||||
|
|
||||||
|
sut.onActivity { activity -> activity.onBackPressed() }
|
||||||
|
|
||||||
|
sut.recreate()
|
||||||
|
}
|
||||||
|
}
|
|
@ -335,15 +335,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||||
PreviewTextFragment.setText(headerViewHolder.headerText, text, null, activity, true, true);
|
PreviewTextFragment.setText(headerViewHolder.headerText, text, null, activity, true, true);
|
||||||
headerViewHolder.headerView.setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked());
|
headerViewHolder.headerView.setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked());
|
||||||
|
|
||||||
Shader myShader = new LinearGradient(0,
|
Shader shader = new LinearGradient(0,
|
||||||
400,
|
headerViewHolder.headerText.getHeight()-20,
|
||||||
0,
|
0,
|
||||||
300,
|
headerViewHolder.headerText.getHeight() - 100,
|
||||||
Color.WHITE,
|
activity.getResources().getColor(R.color.bg_default),
|
||||||
Color.BLACK,
|
activity.getResources().getColor(R.color.text_color),
|
||||||
Shader.TileMode.CLAMP);
|
Shader.TileMode.CLAMP
|
||||||
|
);
|
||||||
|
|
||||||
headerViewHolder.headerText.getPaint().setShader(myShader);
|
headerViewHolder.headerText.getPaint().setShader(shader);
|
||||||
} else {
|
} else {
|
||||||
OCFileListGridImageViewHolder gridViewHolder = (OCFileListGridImageViewHolder) holder;
|
OCFileListGridImageViewHolder gridViewHolder = (OCFileListGridImageViewHolder) holder;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
android:id="@+id/headerText"
|
android:id="@+id/headerText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/standard_padding"
|
android:paddingTop="@dimen/standard_padding"
|
||||||
|
android:paddingLeft="@dimen/standard_padding"
|
||||||
|
android:paddingRight="@dimen/standard_padding"
|
||||||
|
android:paddingBottom="@dimen/zero"
|
||||||
android:textColor="@color/text_color" />
|
android:textColor="@color/text_color" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue