Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Update attribute names #41

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"
app:time_input_view_second_visibility="visible"
app:time_input_view_horizontal_bias=".5" />
app:timeInputView_secondVisibility="visible"
app:timeInputView_horizontalBias=".5" />

<com.eygraber.date_time_input.xml.DateInputView
android:id="@+id/outlined_date_input_view"
Expand All @@ -34,9 +34,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"
app:date_input_view_flow_style="spread"
app:date_input_view_horizontal_gap="6dp"
app:time_input_view_horizontal_bias=".5" />
app:dateInputView_flowStyle="spread"
app:dateInputView_horizontalGap="6dp"
app:timeInputView_horizontalBias=".5" />

<com.eygraber.date_time_input.xml.TimeInputView
android:id="@+id/outlined_time_input_view"
Expand All @@ -45,8 +45,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="16dp"
app:time_input_view_second_visibility="visible"
app:time_input_view_horizontal_bias=".5" />
app:timeInputView_secondVisibility="visible"
app:timeInputView_horizontalBias=".5" />

<androidx.compose.ui.platform.ComposeView
android:id="@+id/date_input_composable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,38 +162,38 @@ class DateInputView @JvmOverloads constructor(

styledAttr(attrs, R.styleable.DateInputView, R.attr.dateInputViewStyle) {
val horizontalGap = getDimensionPixelSize(
R.styleable.DateInputView_date_input_view_horizontal_gap,
R.styleable.DateInputView_dateInputView_horizontalGap,
-1
)
if(horizontalGap > -1) {
flowView.setHorizontalGap(horizontalGap)
}

val verticalGap = getDimensionPixelSize(
R.styleable.DateInputView_date_input_view_vertical_gap,
R.styleable.DateInputView_dateInputView_verticalGap,
-1
)
if(verticalGap > -1) {
flowView.setVerticalGap(verticalGap)
}

flowView.setHorizontalBias(
getFloat(R.styleable.DateInputView_date_input_view_horizontal_bias, 0F)
getFloat(R.styleable.DateInputView_dateInputView_horizontalBias, 0F)
)

flowView.setVerticalBias(
getFloat(R.styleable.DateInputView_date_input_view_vertical_bias, 0F)
getFloat(R.styleable.DateInputView_dateInputView_verticalBias, 0F)
)

flowView.setHorizontalStyle(
getInt(R.styleable.DateInputView_date_input_view_flow_style, Flow.CHAIN_SPREAD_INSIDE)
getInt(R.styleable.DateInputView_dateInputView_flowStyle, Flow.CHAIN_SPREAD_INSIDE)
)

flowView.setHorizontalAlign(
getInt(R.styleable.DateInputView_date_input_view_flow_align, Flow.HORIZONTAL_ALIGN_START)
getInt(R.styleable.DateInputView_dateInputView_flowAlign, Flow.HORIZONTAL_ALIGN_START)
)

getDimensionPixelSize(R.styleable.DateInputView_date_input_view_error_margin_start, -1).let { margin ->
getDimensionPixelSize(R.styleable.DateInputView_dateInputView_errorMarginStart, -1).let { margin ->
if(margin >= 0) {
errorView.updateLayoutParams<LayoutParams> {
marginStart = margin
Expand All @@ -205,7 +205,7 @@ class DateInputView @JvmOverloads constructor(
val monthNames =
when(
val resId =
getResourceId(R.styleable.DateInputView_date_input_view_month_names, -1)
getResourceId(R.styleable.DateInputView_dateInputView_monthNames, -1)
) {
-1 -> generateLocalizedMonthNames()
else -> resources.getStringArray(resId).toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,35 +185,35 @@ class TimeInputView @JvmOverloads constructor(

styledAttr(attrs, R.styleable.TimeInputView, R.attr.timeInputViewStyle) {
val horizontalGap = getDimensionPixelSize(
R.styleable.TimeInputView_time_input_view_horizontal_gap,
R.styleable.TimeInputView_timeInputView_horizontalGap,
-1
)
if(horizontalGap > -1) {
flowView.setHorizontalGap(horizontalGap)
}

val verticalGap = getDimensionPixelSize(
R.styleable.TimeInputView_time_input_view_vertical_gap,
R.styleable.TimeInputView_timeInputView_verticalGap,
-1
)
if(verticalGap > -1) {
flowView.setVerticalGap(verticalGap)
}

flowView.setHorizontalBias(
getFloat(R.styleable.TimeInputView_time_input_view_horizontal_bias, 0F)
getFloat(R.styleable.TimeInputView_timeInputView_horizontalBias, 0F)
)

flowView.setVerticalBias(
getFloat(R.styleable.TimeInputView_time_input_view_vertical_bias, 0F)
getFloat(R.styleable.TimeInputView_timeInputView_verticalBias, 0F)
)

flowView.setHorizontalAlign(
getInt(R.styleable.TimeInputView_time_input_view_flow_align, Flow.HORIZONTAL_ALIGN_START)
getInt(R.styleable.TimeInputView_timeInputView_flowAlign, Flow.HORIZONTAL_ALIGN_START)
)

val secondVisibility = when(
getInt(R.styleable.TimeInputView_time_input_view_second_visibility, View.VISIBLE)
getInt(R.styleable.TimeInputView_timeInputView_secondVisibility, View.VISIBLE)
) {
0 -> View.VISIBLE
1 -> View.INVISIBLE
Expand All @@ -223,7 +223,7 @@ class TimeInputView @JvmOverloads constructor(
secondGroupView.visibility = secondVisibility

getDimensionPixelSize(
R.styleable.TimeInputView_time_input_view_error_margin_start, -1
R.styleable.TimeInputView_timeInputView_errorMarginStart, -1
).let { margin ->
if(margin >= 0) {
errorView.updateLayoutParams<LayoutParams> {
Expand Down
30 changes: 15 additions & 15 deletions xml/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@
<attr name="textInputExposedDropdownMenuStyle" format="reference" />

<declare-styleable name="DateInputView">
<attr name="date_input_view_error_margin_start" format="dimension" />
<attr name="dateInputView_errorMarginStart" format="dimension" />

<attr name="date_input_view_month_names" format="reference" />
<attr name="dateInputView_monthNames" format="reference" />

<attr name="date_input_view_flow_style" format="enum">
<attr name="dateInputView_flowStyle" format="enum">
<enum name="spread" value="0"/>
<enum name="spread_inside" value="1"/>
<enum name="packed" value="2"/>
</attr>

<attr name="date_input_view_flow_align" format="enum">
<attr name="dateInputView_flowAlign" format="enum">
<enum name="start" value="0"/>
<enum name="end" value="1"/>
<enum name="center" value="2"/>
</attr>

<attr name="date_input_view_horizontal_bias" format="float" />
<attr name="date_input_view_vertical_bias" format="float" />
<attr name="dateInputView_horizontalBias" format="float" />
<attr name="dateInputView_verticalBias" format="float" />

<attr name="date_input_view_horizontal_gap" format="dimension" />
<attr name="date_input_view_vertical_gap" format="dimension" />
<attr name="dateInputView_horizontalGap" format="dimension" />
<attr name="dateInputView_verticalGap" format="dimension" />
</declare-styleable>

<declare-styleable name="TimeInputView">
<attr name="time_input_view_second_visibility" format="enum">
<attr name="timeInputView_secondVisibility" format="enum">
<enum name="visible" value="0"/>
<enum name="invisible" value="1"/>
<enum name="gone" value="2"/>
</attr>

<attr name="time_input_view_error_margin_start" format="dimension" />
<attr name="timeInputView_errorMarginStart" format="dimension" />

<attr name="time_input_view_flow_align" format="enum">
<attr name="timeInputView_flowAlign" format="enum">
<enum name="start" value="0"/>
<enum name="end" value="1"/>
<enum name="center" value="2"/>
</attr>

<attr name="time_input_view_horizontal_bias" format="float" />
<attr name="time_input_view_vertical_bias" format="float" />
<attr name="timeInputView_horizontalBias" format="float" />
<attr name="timeInputView_verticalBias" format="float" />

<attr name="time_input_view_horizontal_gap" format="dimension" />
<attr name="time_input_view_vertical_gap" format="dimension" />
<attr name="timeInputView_horizontalGap" format="dimension" />
<attr name="timeInputView_verticalGap" format="dimension" />
</declare-styleable>
</resources>