make items square

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-13 16:13:55 +01:00 committed by Alper Öztürk
parent 6e92a5aab7
commit 450adaf697
3 changed files with 33 additions and 18 deletions

View file

@ -8,11 +8,13 @@
package com.owncloud.android.ui.adapter package com.owncloud.android.ui.adapter
import android.content.Context import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.owncloud.android.R import com.owncloud.android.R
@ -64,9 +66,22 @@ class RecommendedFilesAdapter(
val item = recommendations[position] val item = recommendations[position]
holder.binding.name.text = item.name holder.binding.name.text = item.name
holder.binding.timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp) // holder.binding.timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp)
val thumbnail = getThumbnail(item) val thumbnail = getThumbnail(item)
/*
val centerPixel = thumbnail.getPixel(thumbnail.width / 2, thumbnail.height / 2)
val redValue = Color.red(centerPixel)
val blueValue = Color.blue(centerPixel)
val greenValue = Color.green(centerPixel)
val centerColor = Color.argb(0.8f, redValue.toFloat(), greenValue.toFloat(), blueValue.toFloat())
*/
val containerColor = ContextCompat.getColor(context, R.color.primary)
holder.binding.container.backgroundTintList = ColorStateList.valueOf(containerColor)
holder.binding.icon.setImageBitmap(thumbnail) holder.binding.icon.setImageBitmap(thumbnail)
} }

View file

@ -27,11 +27,15 @@
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingBottom="@dimen/standard_padding"
android:contentDescription="@null" android:contentDescription="@null"
android:src="@drawable/preview_markdown_gradient_shape" /> android:src="@drawable/preview_markdown_gradient_shape" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recommended_files_recycler_view" android:id="@+id/recommended_files_recycler_view"
android:paddingLeft="@dimen/standard_padding"
android:paddingTop="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View file

@ -5,37 +5,33 @@
~ SPDX-License-Identifier: AGPL-3.0-or-later ~ SPDX-License-Identifier: AGPL-3.0-or-later
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="@+id/container"
android:orientation="horizontal" android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginEnd="8dp"
android:background="@drawable/rounded_rect_8dp"
android:orientation="vertical"
android:padding="@dimen/standard_padding" android:padding="@dimen/standard_padding"
android:gravity="center_vertical"> android:gravity="center">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="40dp" android:layout_width="30dp"
android:layout_height="40dp" android:layout_height="30dp"
android:layout_marginEnd="8dp"
android:contentDescription="@string/preview_image_description" android:contentDescription="@string/preview_image_description"
android:src="@drawable/preview_image_gradient_shape" /> android:src="@drawable/preview_image_gradient_shape" />
<TextView <TextView
android:text="aaa"
android:id="@+id/name" android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:textStyle="bold"
android:textSize="16sp" android:textSize="12sp"
android:textColor="@color/text_color" android:textColor="@color/text_color"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"/> android:maxLines="1"/>
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@color/text_color"
android:layout_marginStart="8dp" />
</LinearLayout> </LinearLayout>