Skip to content

Commit

Permalink
make items square
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Dec 16, 2024
1 parent 46e925a commit b4c1e07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
package com.owncloud.android.ui.adapter

import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView
import com.owncloud.android.R
Expand Down Expand Up @@ -64,9 +66,22 @@ class RecommendedFilesAdapter(
val item = recommendations[position]

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 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)
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/list_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/standard_padding"
android:contentDescription="@null"
android:src="@drawable/preview_markdown_gradient_shape" />

<androidx.recyclerview.widget.RecyclerView
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_width="match_parent"
android:layout_height="wrap_content"/>
Expand Down
30 changes: 13 additions & 17 deletions app/src/main/res/layout/recommended_files_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,33 @@
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
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:gravity="center_vertical">
android:gravity="center">

<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="8dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/preview_image_description"
android:src="@drawable/preview_image_gradient_shape" />

<TextView
android:text="aaa"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="16sp"
android:textSize="12sp"
android:textColor="@color/text_color"
android:ellipsize="end"
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>

0 comments on commit b4c1e07

Please sign in to comment.