mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-07 00:18:38 +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"
|
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
|
<TextView
|
||||||
android:id="@+id/responseValidationLabel"
|
android:id="@+id/responseValidationLabel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -165,6 +158,13 @@
|
||||||
style="@style/NockText.Body.Light"
|
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
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/doneBtn"
|
android:id="@+id/doneBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -131,13 +131,6 @@
|
||||||
style="@style/NockText.Body"
|
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
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
@ -193,6 +186,13 @@
|
||||||
style="@style/NockText.Body.Light"
|
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"/>
|
<include layout="@layout/include_divider"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -19,11 +19,14 @@ import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.afollestad.nocknock.utilities.ext.onTextChanged
|
||||||
import com.afollestad.nocknock.viewcomponents.R
|
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.attachLiveData
|
||||||
import com.afollestad.nocknock.viewcomponents.livedata.lifecycleOwner
|
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.minutes
|
||||||
import kotlinx.android.synthetic.main.retry_policy_layout.view.times
|
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) */
|
/** @author Aidan Follestad (@afollestad) */
|
||||||
class RetryPolicyLayout(
|
class RetryPolicyLayout(
|
||||||
|
@ -42,5 +45,22 @@ class RetryPolicyLayout(
|
||||||
) {
|
) {
|
||||||
times.attachLiveData(lifecycleOwner(), timesData)
|
times.attachLiveData(lifecycleOwner(), timesData)
|
||||||
minutes.attachLiveData(lifecycleOwner(), minutesData)
|
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>
|
</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>
|
</merge>
|
||||||
|
|
|
@ -11,5 +11,9 @@
|
||||||
<string name="retry_policy_retry">Retry</string>
|
<string name="retry_policy_retry">Retry</string>
|
||||||
<string name="retry_policy_times_in">times in</string>
|
<string name="retry_policy_times_in">times in</string>
|
||||||
<string name="retry_policy_minutes">Minute(s)</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>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue