mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-04-20 03:25:14 +00:00
Move retry policy input down, add a footer to it
This commit is contained in:
parent
b153622a93
commit
5cd7127e4f
5 changed files with 48 additions and 14 deletions
|
@ -110,13 +110,6 @@
|
|||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_inset_more"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/responseValidationLabel"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -165,6 +158,13 @@
|
|||
style="@style/NockText.Body.Light"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_inset_more"
|
||||
/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/doneBtn"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -131,13 +131,6 @@
|
|||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_inset"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -193,6 +186,13 @@
|
|||
style="@style/NockText.Body.Light"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_inset"
|
||||
/>
|
||||
|
||||
<include layout="@layout/include_divider"/>
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -19,11 +19,14 @@ import android.content.Context
|
|||
import android.util.AttributeSet
|
||||
import android.widget.LinearLayout
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.afollestad.nocknock.utilities.ext.onTextChanged
|
||||
import com.afollestad.nocknock.viewcomponents.R
|
||||
import com.afollestad.nocknock.viewcomponents.ext.asSafeInt
|
||||
import com.afollestad.nocknock.viewcomponents.livedata.attachLiveData
|
||||
import com.afollestad.nocknock.viewcomponents.livedata.lifecycleOwner
|
||||
import kotlinx.android.synthetic.main.retry_policy_layout.view.minutes
|
||||
import kotlinx.android.synthetic.main.retry_policy_layout.view.times
|
||||
import kotlinx.android.synthetic.main.retry_policy_layout.view.retry_policy_desc as description
|
||||
|
||||
/** @author Aidan Follestad (@afollestad) */
|
||||
class RetryPolicyLayout(
|
||||
|
@ -42,5 +45,22 @@ class RetryPolicyLayout(
|
|||
) {
|
||||
times.attachLiveData(lifecycleOwner(), timesData)
|
||||
minutes.attachLiveData(lifecycleOwner(), minutesData)
|
||||
|
||||
times.onTextChanged { invalidateDescriptionText() }
|
||||
minutes.onTextChanged { invalidateDescriptionText() }
|
||||
|
||||
invalidateDescriptionText()
|
||||
}
|
||||
|
||||
private fun invalidateDescriptionText() {
|
||||
val timesInt = times.text.toString()
|
||||
.asSafeInt()
|
||||
val minutesInt = minutes.text.toString()
|
||||
.asSafeInt()
|
||||
description.text = resources.getString(
|
||||
R.string.retry_policy_description,
|
||||
timesInt,
|
||||
minutesInt
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,4 +79,14 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/retry_policy_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:text="@string/retry_policy_description"
|
||||
android:layout_marginTop="@dimen/content_inset_half"
|
||||
style="@style/NockText.Body.Light"
|
||||
/>
|
||||
|
||||
</merge>
|
||||
|
|
|
@ -11,5 +11,9 @@
|
|||
<string name="retry_policy_retry">Retry</string>
|
||||
<string name="retry_policy_times_in">times in</string>
|
||||
<string name="retry_policy_minutes">Minute(s)</string>
|
||||
<string name="retry_policy_description">
|
||||
If a validation fails, perform additional checks sooner by setting the above to non-zero
|
||||
values. After retrying %1$d times over %2$d minutes with no success, you will get a notification.
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue