Commit 40ca2561 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Properly disable/enable the content initially

parent 8b0142db
......@@ -2,6 +2,7 @@ package com.frostnerd.smokescreen.dialog
import android.content.Context
import android.content.DialogInterface
import android.view.View
import android.widget.ArrayAdapter
import androidx.annotation.Keep
import androidx.appcompat.app.AlertDialog
......@@ -38,15 +39,20 @@ class HostSourceRefreshDialog(context:Context,
view.refreshNow.setOnClickListener {
runRefresh()
}
view.automaticRefresh.setOnCheckedChangeListener { _, isChecked ->
val changeAutomaticRefreshStatus:(Boolean) -> Unit = { isChecked ->
view.refreshWifiOnly.isEnabled = isChecked
view.timeAmountTil.isEnabled = isChecked
view.timeUnit.isEnabled = isChecked
view.refreshTimeWrap.visibility = if(isChecked) View.VISIBLE else View.INVISIBLE
}
view.automaticRefresh.setOnCheckedChangeListener { _, isChecked ->
changeAutomaticRefreshStatus(isChecked)
}
view.automaticRefresh.isChecked = context.getPreferences().automaticHostRefresh
view.refreshWifiOnly.isChecked = context.getPreferences().automaticHostRefreshWifiOnly
view.timeAmount.setText(context.getPreferences().automaticHostRefreshTimeAmount.toString())
view.timeUnit.setSelection(context.getPreferences().automaticHostRefreshTimeUnit.ordinal)
changeAutomaticRefreshStatus(view.automaticRefresh.isChecked)
val adapter: ArrayAdapter<CharSequence> = ArrayAdapter.createFromResource(
context,
R.array.dialog_hostsourcerefresh_timeunits,
......
......@@ -24,49 +24,56 @@
android:id="@+id/refreshWifiOnly"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/dialog_hostsourcerefresh_refresh_every"
android:layout_height="wrap_content"/>
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/refreshTimeWrap"
android:orientation="vertical"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
<TextView
android:layout_width="wrap_content"
android:id="@+id/timeAmountTil"
android:layout_above="@id/refreshNow"
android:layout_alignParentTop="true"
android:layout_marginTop="12dp"
android:text="@string/dialog_hostsourcerefresh_refresh_every"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/timeAmount"
android:inputType="numberSigned"
android:imeOptions="actionNext"
android:text="12"
android:maxLines="1"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="wrap_content"
android:id="@+id/timeAmountTil"
android:layout_above="@id/refreshNow"
android:layout_alignParentTop="true"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/timeAmount"
android:inputType="numberSigned"
android:imeOptions="actionNext"
android:text="12"
android:maxLines="1"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:layout_width="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@id/timeAmountTil"
android:id="@+id/timeUnit"
android:layout_marginStart="8dp"
android:layout_alignBaseline="@id/timeAmountTil"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:layout_width="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@id/timeAmountTil"
android:id="@+id/timeUnit"
android:layout_marginStart="8dp"
android:layout_alignBaseline="@id/timeAmountTil"
android:layout_height="wrap_content"/>
<Button
android:layout_width="match_parent"
android:background="@drawable/main_roundbuttons"
android:id="@+id/refreshNow"
android:layout_alignParentBottom="true"
android:text="@string/dialog_hostsourcerefresh_refresh_now"
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
android:layout_height="wrap_content"/>
</RelativeLayout>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:background="@drawable/main_roundbuttons"
android:id="@+id/refreshNow"
android:layout_alignParentBottom="true"
android:text="@string/dialog_hostsourcerefresh_refresh_now"
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
android:layout_height="wrap_content"/>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment