Change clouds from grid to list view

This commit is contained in:
Julian Raufelder 2021-03-25 15:08:13 +01:00
parent cf0f447b4d
commit f3342943f9
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
80 changed files with 80 additions and 46 deletions

View File

@ -7,42 +7,54 @@ enum class CloudTypeModel(builder: Builder) {
CRYPTO(Builder("CRYPTO", R.string.cloud_names_crypto)), //
DROPBOX(Builder("DROPBOX", R.string.cloud_names_dropbox) //
.withCloudImageResource(R.drawable.cloud_type_dropbox) //
.withCloudImageLargeResource(R.drawable.cloud_type_dropbox_large)), //
.withCloudImageResource(R.drawable.dropbox) //
.withVaultImageResource(R.drawable.dropbox_vault) //
.withVaultSelectedImageResource(R.drawable.dropbox_vault_selected)), //
GOOGLE_DRIVE(Builder("GOOGLE_DRIVE", R.string.cloud_names_google_drive) //
.withCloudImageResource(R.drawable.cloud_type_google_drive) //
.withCloudImageLargeResource(R.drawable.cloud_type_google_drive_large)), //
.withCloudImageResource(R.drawable.google_drive) //
.withVaultImageResource(R.drawable.google_drive_vault) //
.withVaultSelectedImageResource(R.drawable.google_drive_vault_selected)), //
ONEDRIVE(Builder("ONEDRIVE", R.string.cloud_names_onedrive) //
.withCloudImageResource(R.drawable.cloud_type_onedrive) //
.withCloudImageLargeResource(R.drawable.cloud_type_onedrive_large)), //
.withCloudImageResource(R.drawable.onedrive) //
.withVaultImageResource(R.drawable.onedrive_vault) //
.withVaultSelectedImageResource(R.drawable.onedrive_vault_selected)), //
WEBDAV(Builder("WEBDAV", R.string.cloud_names_webdav) //
.withCloudImageResource(R.drawable.cloud_type_webdav) //
.withCloudImageLargeResource(R.drawable.cloud_type_webdav_large) //
.withCloudImageResource(R.drawable.webdav) //
.withVaultImageResource(R.drawable.webdav_vault) //
.withVaultSelectedImageResource(R.drawable.webdav_vault_selected) //
.withMultiInstances()), //
LOCAL(Builder("LOCAL", R.string.cloud_names_local_storage) //
.withCloudImageResource(R.drawable.storage_type_local) //
.withCloudImageLargeResource(R.drawable.storage_type_local_large) //
.withCloudImageResource(R.drawable.local_fs) //
.withVaultImageResource(R.drawable.local_fs_vault) //
.withVaultSelectedImageResource(R.drawable.local_fs_vault_selected) //
.withMultiInstances());
val cloudName: String = builder.cloudName
val displayNameResource: Int = builder.displayNameResource
val cloudImageResource: Int = builder.cloudImageResource
val cloudImageLargeResource: Int = builder.cloudImageLargeResource
val vaultImageResource: Int = builder.vaultImageResource
val vaultSelectedImageResource: Int = builder.vaultSelectedImageResource
val isMultiInstance: Boolean = builder.multiInstances
private class Builder(val cloudName: String, val displayNameResource: Int) {
var cloudImageResource = 0
var cloudImageLargeResource = 0
var vaultImageResource = 0
var vaultSelectedImageResource = 0
var multiInstances = false
fun withCloudImageResource(cloudImageResource: Int): Builder {
this.cloudImageResource = cloudImageResource
fun withCloudImageResource(cloudImageLargeResource: Int): Builder {
this.cloudImageResource = cloudImageLargeResource
return this
}
fun withCloudImageLargeResource(cloudImageLargeResource: Int): Builder {
this.cloudImageLargeResource = cloudImageLargeResource
fun withVaultImageResource(vaultImageResource: Int): Builder {
this.vaultImageResource = vaultImageResource
return this
}
fun withVaultSelectedImageResource(vaultSelectedImageResource: Int): Builder {
this.vaultSelectedImageResource = vaultSelectedImageResource
return this
}

View File

@ -29,7 +29,7 @@ class ChooseCloudServiceActivity : BaseActivity(), ChooseCloudServiceView {
setSupportActionBar(toolbar)
}
override fun createFragment(): Fragment? = ChooseCloudServiceFragment()
override fun createFragment(): Fragment = ChooseCloudServiceFragment()
override fun getCustomMenuResource(): Int = R.menu.menu_cloud_services

View File

@ -48,7 +48,7 @@ constructor() : RecyclerViewBaseAdapter<VaultModel, BiometricAuthSettingsAdapter
val vaultModel = getItem(position)
itemView.vaultName.text = vaultModel.name
itemView.cloud.setImageResource(vaultModel.cloudType.cloudImageResource)
itemView.cloud.setImageResource(vaultModel.cloudType.vaultImageResource)
itemView.toggleBiometricAuth.isChecked = vaultModel.password != null

View File

@ -48,7 +48,7 @@ internal constructor(context: Context) : RecyclerViewBaseAdapter<CloudModel, Clo
private fun internalBind(cloudModel: CloudModel) {
itemView.settings.setOnClickListener { callback.onCloudSettingsClicked(cloudModel) }
itemView.cloudImage.setImageResource(cloudModel.cloudType().cloudImageResource)
itemView.cloudImage.setImageResource(cloudModel.cloudType().vaultImageResource)
itemView.setOnClickListener { callback.onCloudConnectionClicked(cloudModel) }

View File

@ -5,7 +5,7 @@ import org.cryptomator.presentation.R
import org.cryptomator.presentation.model.CloudTypeModel
import org.cryptomator.presentation.ui.adapter.CloudsAdapter.CloudViewHolder
import javax.inject.Inject
import kotlinx.android.synthetic.main.item_cloud.view.cloud
import kotlinx.android.synthetic.main.item_cloud.view.cloudImage
import kotlinx.android.synthetic.main.item_cloud.view.cloudName
class CloudsAdapter @Inject
@ -28,10 +28,10 @@ constructor() : RecyclerViewBaseAdapter<CloudTypeModel, CloudsAdapter.OnItemClic
override fun bind(position: Int) {
val cloudTypeModel = getItem(position)
itemView.cloud.setImageResource(cloudTypeModel.cloudImageLargeResource)
itemView.cloudImage.setImageResource(cloudTypeModel.cloudImageResource)
itemView.cloudName.setText(cloudTypeModel.displayNameResource)
itemView.cloud.setOnClickListener { callback.onCloudClicked(cloudTypeModel) }
itemView.setOnClickListener { callback.onCloudClicked(cloudTypeModel) }
}
}
}

View File

@ -67,7 +67,7 @@ constructor() : RecyclerViewBaseAdapter<VaultModel, SharedLocationsAdapter.Callb
boundVault = getItem(position)
boundVault?.let {
itemView.cloudImage.setImageResource(it.cloudType.cloudImageResource)
itemView.cloudImage.setImageResource(it.cloudType.vaultImageResource)
itemView.vaultName.text = it.name
val boundVaultSelected = it == selectedVault

View File

@ -60,7 +60,7 @@ internal constructor() : RecyclerViewBaseAdapter<VaultModel, VaultsAdapter.OnIte
itemView.vaultName.text = vaultModel.name
itemView.vaultPath.text = vaultModel.path
itemView.cloudImage.setImageResource(vaultModel.cloudType.cloudImageResource)
itemView.cloudImage.setImageResource(vaultModel.cloudType.vaultImageResource)
if (vaultModel.isLocked) {
itemView.unlockedImage.visibility = View.GONE
@ -68,7 +68,10 @@ internal constructor() : RecyclerViewBaseAdapter<VaultModel, VaultsAdapter.OnIte
itemView.unlockedImage.visibility = View.VISIBLE
}
itemView.setOnClickListener { callback.onVaultClicked(vaultModel) }
itemView.setOnClickListener {
itemView.cloudImage.setImageResource(vaultModel.cloudType.vaultSelectedImageResource)
callback.onVaultClicked(vaultModel)
}
itemView.unlockedImage.setOnClickListener { callback.onVaultLockClicked(vaultModel) }

View File

@ -32,7 +32,7 @@ class CloudConnectionSettingsBottomSheet : BaseBottomSheet<CloudConnectionSettin
else -> throw IllegalStateException("Cloud model is not binded in the view")
}
iv_cloud_image.setImageResource(cloudModel.cloudType().cloudImageResource)
iv_cloud_image.setImageResource(cloudModel.cloudType().vaultImageResource)
change_cloud.setOnClickListener {
callback?.onChangeCloudClicked(cloudModel)
dismiss()

View File

@ -31,7 +31,7 @@ class SettingsVaultBottomSheet : BaseBottomSheet<SettingsVaultBottomSheet.Callba
lock_vault.visibility = LinearLayout.GONE
}
val cloudType = vaultModel.cloudType
cloud_image.setImageResource(cloudType.cloudImageResource)
cloud_image.setImageResource(cloudType.vaultImageResource)
vault_name.text = vaultModel.name
vault_path.text = vaultModel.path

View File

@ -1,6 +1,6 @@
package org.cryptomator.presentation.ui.fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import org.cryptomator.generator.Fragment
import org.cryptomator.presentation.R
import org.cryptomator.presentation.model.CloudTypeModel
@ -36,7 +36,7 @@ class ChooseCloudServiceFragment : BaseFragment() {
private fun setupRecyclerView() {
cloudsAdapter.setCallback(onItemClickListener)
recyclerView.layoutManager = GridLayoutManager(context(), 2)
recyclerView.layoutManager = LinearLayoutManager(context())
recyclerView.adapter = cloudsAdapter
// smoother scrolling
recyclerView.setHasFixedSize(true)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

View File

Before

Width:  |  Height:  |  Size: 765 B

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 962 B

View File

Before

Width:  |  Height:  |  Size: 849 B

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

View File

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

View File

Before

Width:  |  Height:  |  Size: 936 B

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,23 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:gravity="center"
android:orientation="vertical">
android:layout_height="72dp"
android:background="?android:attr/selectableItemBackground">
<ImageButton
android:id="@+id/cloud"
android:layout_width="128dp"
android:layout_height="128dp"
android:background="@android:color/transparent" />
<ImageView
android:id="@+id/cloudImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginStart="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@+id/cloudImage"
android:orientation="vertical">
<TextView
android:id="@+id/cloudName"
style="@style/AppTheme.ListItemDarkTextColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="18sp" />
<!-- using android:singleLine to fix https://code.google.com/p/android/issues/detail?id=33868 -->
</LinearLayout>
<TextView
android:id="@+id/cloudName"
style="@style/AppTheme.ListItemDarkTextColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/cloudImage"
android:background="@color/list_divider" />
</LinearLayout>
</RelativeLayout>