diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-21 14:39:00 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-08-30 12:24:19 -0400 |
commit | bf136d76b81835a44a0d9038b2a87806247296e8 (patch) | |
tree | 77e52c71086411aa3fc653dbda6672a186ed5aec | |
parent | 17d18daaf591b4ab27e0a7df0bb1c3126e6488be (diff) | |
download | kau-bf136d76b81835a44a0d9038b2a87806247296e8.tar.gz kau-bf136d76b81835a44a0d9038b2a87806247296e8.tar.bz2 kau-bf136d76b81835a44a0d9038b2a87806247296e8.zip |
Fix/kpref-inner-frame-size (#42)
* Fix kpref item barriers
* Revert and add text constraint
8 files changed, 33 insertions, 12 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt index 889f347..1eeac1a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt @@ -18,4 +18,6 @@ const val KAU_ALL = KAU_HORIZONTAL or KAU_VERTICAL const val KAU_COLLAPSED = 0 const val KAU_COLLAPSING = 1 const val KAU_EXPANDING = 2 -const val KAU_EXPANDED = 3
\ No newline at end of file +const val KAU_EXPANDED = 3 + +const val KAU_ELLIPSIS = '\u2026'
\ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt index cdb49ea..50a3c29 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt @@ -118,4 +118,8 @@ fun postDelayed(delay: Long, action: () -> Unit) { inline val kauIsMainThread: Boolean get() = Looper.myLooper() == Looper.getMainLooper() -class KauException(message: String) : RuntimeException(message)
\ No newline at end of file +class KauException(message: String) : RuntimeException(message) + +fun String.withMaxLength(n: Int): String = + if (length <= n) this + else substring(0, n-1) + KAU_ELLIPSIS
\ No newline at end of file diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt index 6a9f6b0..3afa614 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt @@ -3,7 +3,6 @@ package ca.allanwang.kau.kpref.activity.items import android.view.View import android.widget.SeekBar import android.widget.TextView -import ca.allanwang.kau.kpref.KPrefException import ca.allanwang.kau.kpref.activity.GlobalOptions import ca.allanwang.kau.kpref.activity.R import ca.allanwang.kau.utils.tint diff --git a/kpref-activity/src/main/res/layout/kau_pref_core.xml b/kpref-activity/src/main/res/layout/kau_pref_core.xml index 4b5de56..183c53e 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_core.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_core.xml @@ -81,10 +81,10 @@ <android.support.constraint.Barrier android:id="@id/kau_pref_barrier" - android:layout_width="1dp" - android:layout_height="wrap_content" + android:layout_width="0dp" + android:layout_height="0dp" app:barrierDirection="end" - app:constraint_referenced_ids="kau_pref_title,kau_pref_desc,kau_pref_lower_frame" + app:constraint_referenced_ids="kau_pref_title,kau_pref_desc" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/kpref-activity/src/main/res/layout/kau_pref_text.xml b/kpref-activity/src/main/res/layout/kau_pref_text.xml index bae83f2..40fed2a 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_text.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_text.xml @@ -2,6 +2,9 @@ android:id="@id/kau_pref_inner_content" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:focusable="false" + android:background="@null" android:clickable="false" - android:background="@null" />
\ No newline at end of file + android:ellipsize="end" + android:focusable="false" + android:maxLines="3" + android:maxWidth="150dp" />
\ No newline at end of file diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index 09002d4..1528970 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -16,10 +16,7 @@ import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.bindSearchView import ca.allanwang.kau.swipe.SWIPE_EDGE_LEFT import ca.allanwang.kau.ui.views.RippleCanvas -import ca.allanwang.kau.utils.materialDialog -import ca.allanwang.kau.utils.navigationBarColor -import ca.allanwang.kau.utils.startActivity -import ca.allanwang.kau.utils.toast +import ca.allanwang.kau.utils.* import ca.allanwang.kau.xml.showChangelog import com.mikepenz.google_material_typeface_library.GoogleMaterial @@ -185,6 +182,17 @@ class MainActivity : KPrefActivity() { onClick = { _, _, _ -> kauLaunchAbout(AboutActivity::class.java); false } } + header(R.string.long_prefs) + + checkbox(R.string.checkbox_3, { KPrefSample.check2 }, { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) { + descRes = R.string.kau_lorem_ipsum + } + + text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) { + descRes = R.string.kau_lorem_ipsum + textGetter = { string(R.string.kau_lorem_ipsum) } + } + } fun subPrefs(): KPrefAdapterBuilder.() -> Unit = { diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 086b27b..a887ad3 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -24,4 +24,5 @@ <string name="video_overlay_showcase">Video Overlay Showcase</string> <string name="adapter_showcase">Adapter Showcase</string> <string name="about_kau">KAU (Kotlin Android Utils) is a collection of common extension functions and complex UIs that can be used in almost all apps. It is meant to implement the shared components, so you can focus on what makes your app unique.</string> + <string name="long_prefs">Long Prefs</string> </resources> diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index 3eb5287..1d46757 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -8,6 +8,10 @@ <version title="v3.3.2"/> <item text=":kpref-activity: Add visibility toggle to Core contract. Items can override this to show/hide given preferences based on boolean callbacks." /> + <item text=":kpref-activity: Add width constraint for long text items" /> + <item text="" /> + <item text="" /> + <item text="" /> <version title="v3.3.1"/> <item text=":core: Open up all logger functions" /> |