Skip to content

Commit

Permalink
v2.4.1
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Guerinet <julien@guerinet.com>
  • Loading branch information
jguerinet committed Apr 23, 2018
1 parent c267e9f commit 9d9faf7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Version 2.4.1 (2018-04-23)
* `ui`:
* Added extension to set a `View`'s padding with a dimension Id
* Added extension to set a `TextView`'s text size with a dimension Id

## Version 2.4.0 (2018-04-14)
* `io`:
* Deprecated the `IOUtils`, replacing it with extensions
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# org.gradle.parallel=true

# Project properties
suitcase_version=2.4.0
suitcase_version=2.4.1
group=com.guerinet

# Android specific properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.guerinet.suitcase.ui.extensions

import android.support.annotation.ColorInt
import android.support.annotation.DimenRes
import android.util.TypedValue
import android.widget.TextView

/**
Expand All @@ -38,4 +40,11 @@ fun TextView.setDrawableTint(position: Int, @ColorInt color: Int) {
// Set the drawables back
setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], drawables[1], drawables[2],
drawables[3])
}

/**
* Changes the [TextView]'s text size by using the [textSizeId]
*/
fun TextView.setTextSizeId(@DimenRes textSizeId: Int) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.resources.getDimension(textSizeId))
}
42 changes: 42 additions & 0 deletions ui/src/main/java/com/guerinet/suitcase/ui/extensions/View.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2016-2018 Julien Guerinet
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.guerinet.suitcase.ui.extensions

import android.support.annotation.DimenRes
import android.view.View
import android.view.ViewGroup

/**
* [View] extensions
* @author Julien Guerinet
* @since 2.4.1
*/

/**
* Quickly sets the [width] and [height] (warning: this creates new [ViewGroup.LayoutParams])
*/
fun View.setWidthAndHeight(width: Int, height: Int) {
layoutParams = ViewGroup.LayoutParams(width, height)
}

/**
* Sets the padding with [paddingId] on all 4 sides of the view
*/
fun View.setPaddingId(@DimenRes paddingId: Int) {
val padding = resources.getDimensionPixelOffset(paddingId)
setPadding(padding, padding, padding, padding)
}

0 comments on commit 9d9faf7

Please sign in to comment.