Merge pull request #2300 from MilosKozak/maintenance/code-style
add code style to project
This commit is contained in:
commit
469d89bce8
20 changed files with 379 additions and 193 deletions
137
.idea/codeStyles/Project.xml
Normal file
137
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,137 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="AUTODETECT_INDENTS" value="false" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="6" />
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="6" />
|
||||
<option name="BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES" value="1" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
||||
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
|
||||
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
||||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
|
@ -3,7 +3,11 @@ package info.nightscout.androidaps.dialogs
|
|||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
|
|
|
@ -14,8 +14,8 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
|||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.XdripCalibrations
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import kotlinx.android.synthetic.main.dialog_calibration.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_calibration, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
|||
import info.nightscout.androidaps.plugins.treatments.CarbsGenerator
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import kotlinx.android.synthetic.main.dialog_carbs.*
|
||||
import kotlinx.android.synthetic.main.notes.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import kotlinx.android.synthetic.main.dialog_carbs.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
@ -72,7 +72,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_carbs, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,14 @@ import info.nightscout.androidaps.db.CareportalEvent
|
|||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.Translator
|
||||
import kotlinx.android.synthetic.main.dialog_care.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import kotlinx.android.synthetic.main.notes.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import org.json.JSONObject
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
@ -49,7 +53,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_care, container, false)
|
||||
}
|
||||
|
||||
|
@ -73,6 +77,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
action_care_bg_layout.visibility = View.GONE
|
||||
actions_care_bgsource.visibility = View.GONE
|
||||
}
|
||||
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.fragment.app.DialogFragment
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
import kotlinx.android.synthetic.main.datetime.*
|
||||
import kotlinx.android.synthetic.main.notes.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
|
@ -42,7 +43,7 @@ abstract class DialogFragmentWithDate : DialogFragment() {
|
|||
savedInstanceState.putBoolean("eventTimeChanged", eventTimeChanged)
|
||||
}
|
||||
|
||||
fun onCreateView() {
|
||||
fun onCreateViewGeneral() {
|
||||
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
isCancelable = true
|
||||
|
@ -103,7 +104,7 @@ abstract class DialogFragmentWithDate : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
notes_layout?.visibility = if (SP.getBoolean(R.string.key_show_notes_entry_dialogs, false)) View.VISIBLE else View.GONE
|
||||
notes_layout?.visibility = SP.getBoolean(R.string.key_show_notes_entry_dialogs, false).toVisibility()
|
||||
|
||||
ok.setOnClickListener {
|
||||
synchronized(okClicked) {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
|
|
|
@ -8,9 +8,9 @@ import android.view.ViewGroup
|
|||
import com.google.common.base.Joiner
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
|
@ -31,7 +31,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_extendedbolus, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ import android.view.ViewGroup
|
|||
import com.google.common.base.Joiner
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import kotlinx.android.synthetic.main.dialog_fill.*
|
||||
|
@ -32,7 +32,7 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_fill, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.google.common.base.Joiner
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
|
@ -19,13 +20,12 @@ import info.nightscout.androidaps.db.TempTarget
|
|||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import kotlinx.android.synthetic.main.dialog_insulin.*
|
||||
import kotlinx.android.synthetic.main.notes.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import kotlinx.android.synthetic.main.dialog_insulin.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
|
@ -69,7 +69,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_insulin, container, false)
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
|
||||
overview_insulin_time_layout.visibility = View.GONE
|
||||
overview_insulin_record_only.setOnCheckedChangeListener { _, isChecked: Boolean ->
|
||||
overview_insulin_time_layout.visibility = if (isChecked) View.VISIBLE else View.GONE
|
||||
overview_insulin_time_layout.visibility = isChecked.toVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import kotlinx.android.synthetic.main.dialog_profileswitch.*
|
||||
import kotlinx.android.synthetic.main.notes.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import kotlinx.android.synthetic.main.dialog_profileswitch.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_profileswitch, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ import android.view.ViewGroup
|
|||
import com.google.common.base.Joiner
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
|
@ -35,7 +35,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_tempbasal, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,13 @@ import info.nightscout.androidaps.db.Source
|
|||
import info.nightscout.androidaps.db.TempTarget
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import kotlinx.android.synthetic.main.dialog_temptarget.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
||||
|
@ -32,7 +36,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_temptarget, container, false)
|
||||
}
|
||||
|
||||
|
@ -75,18 +79,22 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
defaultDuration = DefaultValueHelper.determineEatingSoonTTDuration().toDouble()
|
||||
defaultTarget = DefaultValueHelper.determineEatingSoonTT()
|
||||
}
|
||||
|
||||
MainApp.gs(R.string.activity) -> {
|
||||
defaultDuration = DefaultValueHelper.determineActivityTTDuration().toDouble()
|
||||
defaultTarget = DefaultValueHelper.determineActivityTT()
|
||||
}
|
||||
|
||||
MainApp.gs(R.string.hypo) -> {
|
||||
defaultDuration = DefaultValueHelper.determineHypoTTDuration().toDouble()
|
||||
defaultTarget = DefaultValueHelper.determineHypoTT()
|
||||
}
|
||||
|
||||
MainApp.gs(R.string.cancel) -> {
|
||||
defaultDuration = 0.0
|
||||
defaultTarget = 0.0
|
||||
}
|
||||
|
||||
else -> {
|
||||
defaultDuration = overview_temptarget_duration.value
|
||||
defaultTarget = overview_temptarget_temptarget.value
|
||||
|
|
|
@ -10,17 +10,21 @@ import android.view.ViewGroup
|
|||
import com.google.common.base.Joiner
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.SafeParse
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import kotlinx.android.synthetic.main.dialog_treatment.*
|
||||
import kotlinx.android.synthetic.main.okcancel.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
|
@ -56,7 +60,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
onCreateView()
|
||||
onCreateViewGeneral()
|
||||
return inflater.inflate(R.layout.dialog_treatment, container, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package info.nightscout.androidaps.dialogs
|
|||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
|
@ -75,8 +79,8 @@ class WizardDialog : DialogFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
loadCheckedStates()
|
||||
processCobCheckBox()
|
||||
treatments_wizard_sbcheckbox.visibility = if (SP.getBoolean(R.string.key_usesuperbolus, false)) View.VISIBLE else View.GONE
|
||||
treatments_wizard_notes_layout.visibility = if (SP.getBoolean(R.string.key_show_notes_entry_dialogs, false)) View.VISIBLE else View.GONE
|
||||
treatments_wizard_sbcheckbox.visibility = SP.getBoolean(R.string.key_usesuperbolus, false).toVisibility()
|
||||
treatments_wizard_notes_layout.visibility = SP.getBoolean(R.string.key_show_notes_entry_dialogs, false).toVisibility()
|
||||
|
||||
val maxCarbs = MainApp.getConstraintChecker().maxCarbsAllowed.value()
|
||||
val maxCorrection = MainApp.getConstraintChecker().maxBolusAllowed.value()
|
||||
|
@ -110,23 +114,23 @@ class WizardDialog : DialogFragment() {
|
|||
// cancel button
|
||||
cancel.setOnClickListener { dismiss() }
|
||||
// checkboxes
|
||||
treatments_wizard_bgcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_ttcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_cobcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_basaliobcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_bolusiobcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_bgtrendcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_sbcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) }
|
||||
treatments_wizard_bgcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_ttcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_cobcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_basaliobcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_bolusiobcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_bgtrendcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_sbcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
|
||||
val showCalc = SP.getBoolean(MainApp.gs(R.string.key_wizard_calculation_visible), false)
|
||||
treatments_wizard_delimiter.visibility = if (showCalc) View.VISIBLE else View.GONE
|
||||
treatments_wizard_resulttable.visibility = if (showCalc) View.VISIBLE else View.GONE
|
||||
treatments_wizard_delimiter.visibility = showCalc.toVisibility()
|
||||
treatments_wizard_resulttable.visibility = showCalc.toVisibility()
|
||||
treatments_wizard_calculationcheckbox.isChecked = showCalc
|
||||
treatments_wizard_calculationcheckbox.setOnCheckedChangeListener { _, isChecked ->
|
||||
run {
|
||||
SP.putBoolean(MainApp.gs(R.string.key_wizard_calculation_visible), isChecked)
|
||||
treatments_wizard_delimiter.visibility = if (isChecked) View.VISIBLE else View.GONE
|
||||
treatments_wizard_resulttable.visibility = if (isChecked) View.VISIBLE else View.GONE
|
||||
treatments_wizard_delimiter.visibility = isChecked.toVisibility()
|
||||
treatments_wizard_resulttable.visibility = isChecked.toVisibility()
|
||||
}
|
||||
}
|
||||
// profile spinner
|
||||
|
@ -159,7 +163,7 @@ class WizardDialog : DialogFragment() {
|
|||
disposable.clear()
|
||||
}
|
||||
|
||||
private fun onCheckedChanged(buttonView: CompoundButton) {
|
||||
private fun onCheckedChanged(buttonView: CompoundButton, ignored: Boolean) {
|
||||
saveCheckedStates()
|
||||
treatments_wizard_ttcheckbox.isEnabled = treatments_wizard_bgcheckbox.isChecked && TreatmentsPlugin.getPlugin().tempTargetFromHistory != null
|
||||
if (buttonView.id == treatments_wizard_cobcheckbox.id)
|
||||
|
@ -207,7 +211,6 @@ class WizardDialog : DialogFragment() {
|
|||
treatments_wizard_profile.adapter = adapter
|
||||
} ?: return
|
||||
|
||||
|
||||
val units = ProfileFunctions.getSystemUnits()
|
||||
treatments_wizard_bgunits.text = units
|
||||
if (units == Constants.MGDL)
|
||||
|
@ -236,7 +239,7 @@ class WizardDialog : DialogFragment() {
|
|||
|
||||
calculateInsulin()
|
||||
|
||||
treatments_wizard_percent_used.visibility = if (SP.getInt(R.string.key_boluswizard_percentage, 100) != 100) View.VISIBLE else View.GONE
|
||||
treatments_wizard_percent_used.visibility = (SP.getInt(R.string.key_boluswizard_percentage, 100) != 100).toVisibility()
|
||||
}
|
||||
|
||||
private fun calculateInsulin() {
|
||||
|
|
|
@ -2,7 +2,11 @@ package info.nightscout.androidaps.plugins.configBuilder
|
|||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioButton
|
||||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.events.EventRebuildTabs
|
||||
|
@ -10,6 +14,7 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
|||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.PasswordProtection
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
|
||||
class PluginViewHolder internal constructor(private val fragment: ConfigBuilderFragment,
|
||||
private val pluginType: PluginType,
|
||||
|
@ -56,8 +61,8 @@ class PluginViewHolder internal constructor(private val fragment: ConfigBuilderF
|
|||
}
|
||||
|
||||
fun update() {
|
||||
enabledExclusive.visibility = if (areMultipleSelectionsAllowed(pluginType)) View.GONE else View.VISIBLE
|
||||
enabledInclusive.visibility = if (areMultipleSelectionsAllowed(pluginType)) View.VISIBLE else View.GONE
|
||||
enabledExclusive.visibility = areMultipleSelectionsAllowed(pluginType).not().toVisibility()
|
||||
enabledInclusive.visibility = areMultipleSelectionsAllowed(pluginType).toVisibility()
|
||||
enabledExclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
|
@ -70,7 +75,7 @@ class PluginViewHolder internal constructor(private val fragment: ConfigBuilderF
|
|||
pluginDescription.text = plugin.description
|
||||
}
|
||||
pluginPreferences.visibility = if (plugin.preferencesId == -1 || !plugin.isEnabled(pluginType)) View.INVISIBLE else View.VISIBLE
|
||||
pluginVisibility.visibility = if (plugin.hasFragment()) View.VISIBLE else View.INVISIBLE
|
||||
pluginVisibility.visibility = plugin.hasFragment().toVisibility()
|
||||
pluginVisibility.isEnabled = !(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwaysVisible) && plugin.isEnabled(pluginType)
|
||||
pluginVisibility.isChecked = plugin.isFragmentVisible
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.SingleClickButton
|
||||
import info.nightscout.androidaps.utils.plusAssign
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.actions_fragment.*
|
||||
|
@ -205,8 +206,8 @@ class ActionsFragment : Fragment() {
|
|||
if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE
|
||||
else View.VISIBLE
|
||||
|
||||
actions_temptarget?.visibility = if (!Config.APS) View.GONE else View.VISIBLE
|
||||
actions_tddstats?.visibility = if (!pump.pumpDescription.supportsTDDs) View.GONE else View.VISIBLE
|
||||
actions_temptarget?.visibility = Config.APS.toVisibility()
|
||||
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||
activity?.let { activity ->
|
||||
CareportalFragment.updateAge(activity, careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
|
||||
}
|
||||
|
|
|
@ -79,15 +79,15 @@ class TreatmentsProfileSwitchFragment : Fragment() {
|
|||
fun updateGUI() =
|
||||
profileswitch_recyclerview?.swapAdapter(RecyclerProfileViewAdapter(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - T.days(30).msecs(),false)), false)
|
||||
|
||||
inner class RecyclerProfileViewAdapter(var profileSwitchList: List<ProfileSwitch>) : RecyclerView.Adapter<ProfileSwitchViewHolder>() {
|
||||
inner class RecyclerProfileViewAdapter(private var profileSwitchList: List<ProfileSwitch>) : RecyclerView.Adapter<ProfileSwitchViewHolder>() {
|
||||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ProfileSwitchViewHolder {
|
||||
return ProfileSwitchViewHolder(LayoutInflater.from(viewGroup.context).inflate(R.layout.treatments_profileswitch_item, viewGroup, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ProfileSwitchViewHolder, position: Int) {
|
||||
val profileSwitch = profileSwitchList[position]
|
||||
holder.ph.visibility = if (profileSwitch.source == Source.PUMP) View.VISIBLE else View.GONE
|
||||
holder.ns.visibility = if (NSUpload.isIdValid(profileSwitch._id)) View.VISIBLE else View.GONE
|
||||
holder.ph.visibility = (profileSwitch.source == Source.PUMP).toVisibility()
|
||||
holder.ns.visibility = NSUpload.isIdValid(profileSwitch._id).toVisibility()
|
||||
holder.date.text = DateUtil.dateAndTimeString(profileSwitch.date)
|
||||
if (!profileSwitch.isEndingEvent) {
|
||||
holder.duration.text = DecimalFormatter.to0Decimal(profileSwitch.durationInMinutes.toDouble()) + " " + MainApp.gs(R.string.unit_minute_short)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package info.nightscout.androidaps.utils
|
||||
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Created by adrian on 2019-12-20.
|
||||
*/
|
||||
|
||||
fun Boolean.toVisibility() = if (this) View.VISIBLE else View.GONE
|
||||
|
Loading…
Reference in a new issue