mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-04-20 19:45:17 +00:00
0.8.3
This commit is contained in:
parent
002149cd3f
commit
f85fc9d8bb
9 changed files with 132 additions and 70 deletions
35
.idea/misc.xml
generated
35
.idea/misc.xml
generated
|
@ -5,6 +5,41 @@
|
|||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="10">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="9">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
|
|
Binary file not shown.
|
@ -189,7 +189,8 @@ class AddSiteViewModel(
|
|||
}
|
||||
|
||||
// Validate timeout
|
||||
if (timeout.value.isNullOrLessThan(1)) {
|
||||
val timeout = timeout.value ?: 10_000
|
||||
if (timeout < 0) {
|
||||
timeoutError.value = R.string.please_enter_networkTimeout
|
||||
errorCount++
|
||||
} else {
|
||||
|
@ -232,7 +233,7 @@ class AddSiteViewModel(
|
|||
validationIntervalMs = getCheckIntervalMs(),
|
||||
validationMode = validationMode.value!!,
|
||||
validationArgs = getValidationArgs(),
|
||||
networkTimeout = timeout.value!!,
|
||||
networkTimeout = timeout,
|
||||
disabled = false
|
||||
)
|
||||
|
||||
|
|
|
@ -108,8 +108,17 @@ class MainViewModel(
|
|||
emptyTextVisibility.value = false
|
||||
isLoading.value = true
|
||||
|
||||
val result = withContext(ioDispatcher) {
|
||||
database.allSites(forTags)
|
||||
val unfiltered = withContext(ioDispatcher) {
|
||||
database.allSites()
|
||||
}
|
||||
var result = unfiltered
|
||||
|
||||
if (forTags.isNotEmpty()) {
|
||||
result = result.filter { site ->
|
||||
val itemTags = site.tags.toLowerCase()
|
||||
.split(",")
|
||||
itemTags.any { tag -> forTags.contains(tag) }
|
||||
}
|
||||
}
|
||||
|
||||
sites.value = result
|
||||
|
@ -117,11 +126,9 @@ class MainViewModel(
|
|||
isLoading.value = false
|
||||
emptyTextVisibility.value = result.isEmpty()
|
||||
|
||||
if (forTags.isEmpty()) {
|
||||
val tagsValues = pullOutTags(result)
|
||||
tags.value = tagsValues
|
||||
tagsListVisibility.value = tagsValues.isNotEmpty()
|
||||
}
|
||||
val tagsValues = pullOutTags(unfiltered)
|
||||
tags.value = tagsValues
|
||||
tagsListVisibility.value = tagsValues.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,8 @@ class ViewSiteViewModel(
|
|||
}
|
||||
|
||||
// Validate timeout
|
||||
if (timeout.value.isNullOrLessThan(1)) {
|
||||
val timeout = timeout.value ?: 10_000
|
||||
if (timeout < 0) {
|
||||
timeoutError.value = R.string.please_enter_networkTimeout
|
||||
errorCount++
|
||||
} else {
|
||||
|
@ -312,7 +313,7 @@ class ViewSiteViewModel(
|
|||
validationIntervalMs = getCheckIntervalMs(),
|
||||
validationMode = validationMode.value!!,
|
||||
validationArgs = getValidationArgs(),
|
||||
networkTimeout = timeout.value!!,
|
||||
networkTimeout = timeout,
|
||||
disabled = false
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
android:paddingBottom="@dimen/content_inset"
|
||||
android:paddingLeft="@dimen/content_inset"
|
||||
android:paddingRight="@dimen/content_inset"
|
||||
android:paddingTop="@dimen/content_inset_half"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
|
@ -35,7 +36,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-4dp"
|
||||
android:layout_marginRight="-4dp"
|
||||
android:layout_marginTop="@dimen/content_inset"
|
||||
android:nextFocusDown="@+id/urlTiLayout"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
@ -44,27 +45,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:hint="@string/site_name"
|
||||
android:inputType="textPersonName|textCapWords|textAutoCorrect"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/tagsTiLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-4dp"
|
||||
android:layout_marginRight="-4dp"
|
||||
android:layout_marginTop="@dimen/content_inset_less"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/inputTags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits=",.?-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
android:hint="@string/site_tags_hint"
|
||||
android:inputType="textPersonName|textCapWords|textAutoCorrect"
|
||||
android:nextFocusDown="@+id/inputUrl"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
|
@ -77,6 +58,7 @@
|
|||
android:layout_marginLeft="-4dp"
|
||||
android:layout_marginRight="-4dp"
|
||||
android:layout_marginTop="@dimen/content_inset_half"
|
||||
android:nextFocusDown="@+id/tagsTiLayout"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
@ -85,6 +67,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:hint="@string/site_url"
|
||||
android:inputType="textUri"
|
||||
android:nextFocusDown="@+id/inputTags"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
|
@ -100,6 +83,31 @@
|
|||
style="@style/NockText.Footnote"
|
||||
/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/tagsTiLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-4dp"
|
||||
android:layout_marginRight="-4dp"
|
||||
android:layout_marginTop="@dimen/content_inset_half"
|
||||
android:nextFocusDown="@+id/urlTiLayout"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/inputTags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits=",.?-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
android:hint="@string/site_tags_hint"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="text|textCapWords"
|
||||
android:nextFocusDown="@+id/inputUrl"
|
||||
android:singleLine="true"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<include layout="@layout/include_divider"/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.interval.ValidationIntervalLayout
|
||||
|
@ -179,6 +187,13 @@
|
|||
style="@style/NockText.Body.Light"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/content_inset_less"
|
||||
android:background="?dividerColor"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
android:paddingBottom="@dimen/content_inset"
|
||||
android:paddingLeft="@dimen/content_inset"
|
||||
android:paddingRight="@dimen/content_inset"
|
||||
android:paddingTop="@dimen/content_inset"
|
||||
android:paddingTop="@dimen/content_inset_half"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -61,30 +61,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:hint="@string/site_name"
|
||||
android:inputType="textPersonName|textCapWords|textAutoCorrect"
|
||||
android:nextFocusDown="@+id/inputUrl"
|
||||
android:singleLine="true"
|
||||
android:transitionName="site_name"
|
||||
tools:ignore="Autofill,UnusedAttribute"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits=",.?-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
android:hint="@string/site_tags_hint"
|
||||
android:inputType="text|textCapWords"
|
||||
android:singleLine="true"
|
||||
tools:ignore="Autofill,UnusedAttribute"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputUrl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/site_url"
|
||||
android:inputType="textUri"
|
||||
android:nextFocusDown="@+id/inputTags"
|
||||
android:singleLine="true"
|
||||
android:transitionName="site_url"
|
||||
tools:ignore="Autofill,UnusedAttribute"
|
||||
|
@ -103,6 +93,19 @@
|
|||
style="@style/NockText.Footnote"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/inputTags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits=",.?-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
android:hint="@string/site_tags_hint"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="text|textCapWords"
|
||||
android:singleLine="true"
|
||||
tools:ignore="Autofill,UnusedAttribute"
|
||||
style="@style/NockText.Body"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -198,6 +201,13 @@
|
|||
style="@style/NockText.Body.Light"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/content_inset_less"
|
||||
android:background="?dividerColor"
|
||||
/>
|
||||
|
||||
<com.afollestad.nocknock.viewcomponents.retrypolicy.RetryPolicyLayout
|
||||
android:id="@+id/retryPolicyLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -52,28 +52,21 @@ abstract class AppDatabase : RoomDatabase() {
|
|||
*
|
||||
* @author Aidan Follestad (@afollestad)
|
||||
*/
|
||||
fun AppDatabase.allSites(tags: List<String> = emptyList()): List<Site> {
|
||||
var all = siteDao().all()
|
||||
if (tags.isNotEmpty()) {
|
||||
all = all.filter { site ->
|
||||
val itemTags = site.tags.toLowerCase()
|
||||
.split(",")
|
||||
return@filter itemTags.any { tag -> tags.contains(tag) }
|
||||
}
|
||||
}
|
||||
return all.map {
|
||||
val settings = siteSettingsDao().forSite(it.id)
|
||||
.single()
|
||||
val lastResult = validationResultsDao().forSite(it.id)
|
||||
.singleOrNull()
|
||||
val retryPolicy = retryPolicyDao().forSite(it.id)
|
||||
.singleOrNull()
|
||||
return@map it.copy(
|
||||
settings = settings,
|
||||
lastResult = lastResult,
|
||||
retryPolicy = retryPolicy
|
||||
)
|
||||
}
|
||||
fun AppDatabase.allSites(): List<Site> {
|
||||
return siteDao().all()
|
||||
.map {
|
||||
val settings = siteSettingsDao().forSite(it.id)
|
||||
.single()
|
||||
val lastResult = validationResultsDao().forSite(it.id)
|
||||
.singleOrNull()
|
||||
val retryPolicy = retryPolicyDao().forSite(it.id)
|
||||
.singleOrNull()
|
||||
return@map it.copy(
|
||||
settings = settings,
|
||||
lastResult = lastResult,
|
||||
retryPolicy = retryPolicy
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,8 @@ ext.versions = [
|
|||
minSdk : 21,
|
||||
compileSdk : 28,
|
||||
buildTools : '28.0.3',
|
||||
publishVersion : '0.8.2b',
|
||||
publishVersionCode : 33,
|
||||
publishVersion : '0.8.3',
|
||||
publishVersionCode : 35,
|
||||
|
||||
// Plugins
|
||||
gradlePlugin : '3.2.1',
|
||||
|
|
Loading…
Add table
Reference in a new issue