diff options
Diffstat (limited to 'library/src/main')
5 files changed, 40 insertions, 31 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt index 14b8c4e..7f71195 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt @@ -34,7 +34,7 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>) : override fun getItemCount() = items.size internal class ChangelogVH(itemView: View) : RecyclerView.ViewHolder(itemView) { - val text: TextView = itemView.findViewById(R.id.kau_changelog_text) as TextView + val text: TextView = itemView.findViewById<TextView>(R.id.kau_changelog_text) } } diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt index dcb9dc5..8d5eca2 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt @@ -42,7 +42,7 @@ abstract class KPrefItemCore(val builder: KPrefAdapterBuilder, desc?.visible()?.setText(description) else desc?.gone() - if (iicon != null) icon?.visible()?.setIcon(iicon, 48) + if (iicon != null) icon?.visible()?.setIcon(iicon, 24) else icon?.gone() innerFrame?.removeAllViews() val textColor = builder.textColor?.invoke() diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt index d47d133..4bb72a8 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt @@ -11,9 +11,10 @@ import com.mikepenz.iconics.typeface.IIcon /** * Created by Allan Wang on 2017-05-29. */ -fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE): Drawable { +fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}): Drawable { val state = ColorStateList.valueOf(color) val icon = IconicsDrawable(c).icon(this).sizeDp(sizeDp) icon.setTintList(state) + icon.builder() return icon }
\ No newline at end of file diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt index bd8478d..72b8573 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt @@ -1,17 +1,14 @@ package ca.allanwang.kau.utils -import android.content.res.ColorStateList import android.graphics.Color import android.support.annotation.ColorInt -import android.support.annotation.ColorRes import android.support.annotation.StringRes import android.support.design.widget.Snackbar -import android.support.v4.content.ContextCompat import android.view.View import android.view.ViewGroup import android.widget.ImageView -import android.widget.ProgressBar import android.widget.TextView +import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon @@ -57,8 +54,8 @@ fun TextView.setTextIfValid(@StringRes id: Int) { if (id > 0) text = context.string(id) } -fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE) { +fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}) { if (icon == null) return - setImageDrawable(icon.toDrawable(context, sizeDp, color)) + setImageDrawable(icon.toDrawable(context, sizeDp = sizeDp, color = color, builder = builder)) } diff --git a/library/src/main/res/layout/kau_preference.xml b/library/src/main/res/layout/kau_preference.xml index 4401145..677b0dc 100644 --- a/library/src/main/res/layout/kau_preference.xml +++ b/library/src/main/res/layout/kau_preference.xml @@ -20,45 +20,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + <!--As per Android N, icons (24dp) are aligned to the left rather than centered--> + <ImageView android:id="@+id/kau_pref_icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_width="56dp" + android:layout_height="56dp" android:layout_marginBottom="4dp" android:layout_marginTop="4dp" android:contentDescription="@string/kau_pref_icon" - android:maxHeight="48dp" - android:maxWidth="48dp" + android:paddingEnd="32dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.5" tools:layout_editor_absoluteX="0dp" /> - <LinearLayout - android:id="@+id/kau_pref_inner_frame" - android:layout_width="wrap_content" - android:layout_height="0dp" - android:layout_marginStart="16dp" - android:gravity="center_vertical|end" - android:orientation="horizontal" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="1.0" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.5" - tools:layout_editor_absoluteX="1dp" /> - <TextView android:id="@+id/kau_pref_title" - android:layout_width="wrap_content" + android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:ellipsize="marquee" android:textAppearance="?android:attr/textAppearanceListItem" android:textColor="?android:attr/textColorPrimary" app:layout_constraintBottom_toTopOf="@+id/kau_pref_desc" - app:layout_constraintEnd_toStartOf="@id/kau_pref_inner_frame" + app:layout_constraintEnd_toStartOf="@+id/kau_pref_inner_frame" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/kau_pref_icon" app:layout_constraintTop_toTopOf="parent" @@ -67,7 +54,7 @@ <TextView android:id="@id/kau_pref_desc" - android:layout_width="wrap_content" + android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:ellipsize="end" @@ -78,9 +65,33 @@ app:layout_constraintEnd_toStartOf="@id/kau_pref_inner_frame" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/kau_pref_icon" - app:layout_constraintTop_toBottomOf="@+id/kau_pref_title" + app:layout_constraintTop_toBottomOf="@id/kau_pref_title" tools:layout_editor_absoluteX="-175dp" /> + <android.support.constraint.Barrier + android:id="@+id/kau_pref_barrier" + android:layout_width="1dp" + android:layout_height="wrap_content" + app:constraint_referenced_ids="kau_pref_title,kau_pref_desc" + app:barrierDirection="end" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" /> + + <LinearLayout + android:id="@id/kau_pref_inner_frame" + android:layout_width="wrap_content" + android:layout_height="0dp" + android:gravity="center_vertical|end" + android:orientation="horizontal" + android:paddingStart="16dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" + app:layout_constraintStart_toEndOf="@id/kau_pref_barrier" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.5" + tools:layout_editor_absoluteX="1dp" /> + </android.support.constraint.ConstraintLayout> </LinearLayout>
\ No newline at end of file |