mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-02-21 05:51:08 +01:00
show widget labels under the thumbnails too
This commit is contained in:
parent
2943b83083
commit
d23893755a
@ -3,8 +3,7 @@ package com.simplemobiletools.launcher.adapters
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.RelativeLayout
|
||||||
import android.widget.LinearLayout
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
@ -18,6 +17,7 @@ import com.simplemobiletools.launcher.models.WidgetsListItemsHolder
|
|||||||
import com.simplemobiletools.launcher.models.WidgetsListSection
|
import com.simplemobiletools.launcher.models.WidgetsListSection
|
||||||
import kotlinx.android.synthetic.main.item_widget_list_items_holder.view.*
|
import kotlinx.android.synthetic.main.item_widget_list_items_holder.view.*
|
||||||
import kotlinx.android.synthetic.main.item_widget_list_section.view.*
|
import kotlinx.android.synthetic.main.item_widget_list_section.view.*
|
||||||
|
import kotlinx.android.synthetic.main.item_widget_preview.view.*
|
||||||
|
|
||||||
class WidgetsAdapter(
|
class WidgetsAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
@ -67,7 +67,7 @@ class WidgetsAdapter(
|
|||||||
view.widget_list_items_scroll_view.scrollX = 0
|
view.widget_list_items_scroll_view.scrollX = 0
|
||||||
listItem.widgets.forEachIndexed { index, widget ->
|
listItem.widgets.forEachIndexed { index, widget ->
|
||||||
val imageSize = activity.resources.getDimension(R.dimen.widget_preview_size).toInt()
|
val imageSize = activity.resources.getDimension(R.dimen.widget_preview_size).toInt()
|
||||||
val widgetPreview = LayoutInflater.from(activity).inflate(R.layout.item_widget_preview, null) as ImageView
|
val widgetPreview = LayoutInflater.from(activity).inflate(R.layout.item_widget_preview, null)
|
||||||
view.widget_list_items_holder.addView(widgetPreview)
|
view.widget_list_items_holder.addView(widgetPreview)
|
||||||
|
|
||||||
val endMargin = if (index == listItem.widgets.size - 1) {
|
val endMargin = if (index == listItem.widgets.size - 1) {
|
||||||
@ -76,7 +76,12 @@ class WidgetsAdapter(
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
(widgetPreview.layoutParams as LinearLayout.LayoutParams).apply {
|
widgetPreview.widget_title.apply {
|
||||||
|
text = widget.widgetTitle
|
||||||
|
setTextColor(textColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
(widgetPreview.widget_image.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||||
marginStart = activity.resources.getDimension(R.dimen.activity_margin).toInt()
|
marginStart = activity.resources.getDimension(R.dimen.activity_margin).toInt()
|
||||||
marginEnd = endMargin
|
marginEnd = endMargin
|
||||||
width = imageSize
|
width = imageSize
|
||||||
@ -85,7 +90,7 @@ class WidgetsAdapter(
|
|||||||
|
|
||||||
Glide.with(activity)
|
Glide.with(activity)
|
||||||
.load(widget.widgetPreviewImage)
|
.load(widget.widgetPreviewImage)
|
||||||
.into(widgetPreview)
|
.into(widgetPreview.widget_image)
|
||||||
|
|
||||||
widgetPreview.setOnClickListener {
|
widgetPreview.setOnClickListener {
|
||||||
activity.toast(R.string.touch_hold_widget)
|
activity.toast(R.string.touch_hold_widget)
|
||||||
|
@ -1,12 +1,33 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/widget_preview"
|
android:id="@+id/widget_preview_holder"
|
||||||
android:layout_width="@dimen/widget_preview_size"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/widget_preview_size"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:paddingBottom="@dimen/normal_margin">
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:background="@drawable/widget_preview_background"
|
<ImageView
|
||||||
android:padding="@dimen/normal_margin"
|
android:id="@+id/widget_image"
|
||||||
android:scaleType="centerInside"
|
android:layout_width="@dimen/widget_preview_size"
|
||||||
tools:src="@mipmap/ic_launcher" />
|
android:layout_height="@dimen/widget_preview_size"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@drawable/widget_preview_background"
|
||||||
|
android:padding="@dimen/normal_margin"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/widget_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/widget_image"
|
||||||
|
android:layout_alignStart="@+id/widget_image"
|
||||||
|
android:layout_alignEnd="@+id/widget_image"
|
||||||
|
android:layout_marginTop="@dimen/small_margin"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:lines="1"
|
||||||
|
android:textSize="@dimen/smaller_text_size"
|
||||||
|
tools:text="Calendar" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user