resolve deprecations

This commit is contained in:
Milos Kozak 2022-10-24 16:15:47 +02:00
parent fcd6c68773
commit c205e5f809
17 changed files with 62 additions and 28 deletions

View file

@ -407,6 +407,7 @@ class MainActivity : NoSplashAppCompatActivity() {
binding.mainPager.currentItem = 0 binding.mainPager.currentItem = 0
return return
} }
@Suppress("DEPRECATION")
super.onBackPressed() super.onBackPressed()
} }

View file

@ -72,6 +72,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
override fun onOptionsItemSelected(item: MenuItem): Boolean = override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) { when (item.itemId) {
android.R.id.home -> { android.R.id.home -> {
@Suppress("DEPRECATION")
onBackPressed() onBackPressed()
true true
} }

View file

@ -106,12 +106,14 @@ class OHLoginActivity : DaggerAppCompatActivity() {
override fun onBackPressed() { override fun onBackPressed() {
if (!viewModel.goBack()) { if (!viewModel.goBack()) {
@Suppress("DEPRECATION")
super.onBackPressed() super.onBackPressed()
} }
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean = override fun onOptionsItemSelected(item: MenuItem): Boolean =
if (item.itemId == android.R.id.home) { if (item.itemId == android.R.id.home) {
@Suppress("DEPRECATION")
onBackPressed() onBackPressed()
true true
} else { } else {

View file

@ -6,7 +6,6 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.os.Vibrator import android.os.Vibrator
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
@ -21,6 +20,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.comm.DataLayerListenerServiceWear import info.nightscout.androidaps.comm.DataLayerListenerServiceWear
import info.nightscout.androidaps.comm.IntentCancelNotification import info.nightscout.androidaps.comm.IntentCancelNotification
import info.nightscout.androidaps.comm.IntentWearToMobile import info.nightscout.androidaps.comm.IntentWearToMobile
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import kotlin.math.roundToInt import kotlin.math.roundToInt
class AcceptActivity : ViewSelectorActivity() { class AcceptActivity : ViewSelectorActivity() {
@ -51,7 +51,7 @@ class AcceptActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 2 override fun getColumnCount(arg0: Int): Int = 2
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionBolusPreCheck import info.nightscout.shared.weardata.EventData.ActionBolusPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -30,7 +30,7 @@ class BolusActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 2 override fun getColumnCount(arg0: Int): Int = 2
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -29,7 +29,7 @@ class CarbActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble() val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble() val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse.stringToDouble import info.nightscout.shared.SafeParse.stringToDouble
import info.nightscout.shared.SafeParse.stringToInt import info.nightscout.shared.SafeParse.stringToInt
import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck
@ -32,7 +32,7 @@ class ECarbActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 4 override fun getColumnCount(arg0: Int): Int = 4
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse.stringToDouble import info.nightscout.shared.SafeParse.stringToDouble
import info.nightscout.shared.weardata.EventData.ActionFillPreCheck import info.nightscout.shared.weardata.EventData.ActionFillPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -29,7 +29,7 @@ class FillActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 2 override fun getColumnCount(arg0: Int): Int = 2
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionProfileSwitchPreCheck import info.nightscout.shared.weardata.EventData.ActionProfileSwitchPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -39,7 +39,7 @@ class ProfileSwitchActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 3 override fun getColumnCount(arg0: Int): Int = 3
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionTempTargetPreCheck import info.nightscout.shared.weardata.EventData.ActionTempTargetPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -36,7 +36,7 @@ class TempTargetActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int { override fun getColumnCount(arg0: Int): Int {
return if (isSingleTarget) 3 else 4 return if (isSingleTarget) 3 else 4

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse.stringToDouble import info.nightscout.shared.SafeParse.stringToDouble
import info.nightscout.shared.SafeParse.stringToInt import info.nightscout.shared.SafeParse.stringToInt
import info.nightscout.shared.weardata.EventData.ActionBolusPreCheck import info.nightscout.shared.weardata.EventData.ActionBolusPreCheck
@ -32,7 +32,7 @@ class TreatmentActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = 3 override fun getColumnCount(arg0: Int): Int = 3
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1
@ -48,7 +48,7 @@ class TreatmentActivity : ViewSelectorActivity() {
0 -> { 0 -> {
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
val view = viewAdapter.root val view = viewAdapter.root
var initValue = stringToDouble(editInsulin?.editText?.text.toString(), 0.0) var initValue = stringToDouble(editInsulin?.editText?.text.toString(), 0.0)
val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0) val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0)
editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, maxBolus, stepValuesInsulin, DecimalFormat("#0.0"), false, getString(R.string.action_insulin)) editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, maxBolus, stepValuesInsulin, DecimalFormat("#0.0"), false, getString(R.string.action_insulin))
container.addView(view) container.addView(view)

View file

@ -4,17 +4,16 @@ package info.nightscout.androidaps.interaction.actions
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.DotsPageIndicator
import android.support.wearable.view.GridPagerAdapter
import android.support.wearable.view.GridViewPager import android.support.wearable.view.GridViewPager
import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.wear.widget.CurvedTextView import androidx.wear.widget.CurvedTextView
import dagger.android.DaggerActivity import dagger.android.DaggerActivity
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject import javax.inject.Inject
@ -27,14 +26,14 @@ open class ViewSelectorActivity : DaggerActivity() {
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
private var pager: GridViewPager? = null private var pager: GridViewPagerNonDeprecated? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.grid_layout) setContentView(R.layout.grid_layout)
setTitleBasedOnScreenShape() setTitleBasedOnScreenShape()
pager = findViewById(R.id.pager) pager = findViewById(R.id.pager)
val dotsPageIndicator: DotsPageIndicator = findViewById(R.id.page_indicator) val dotsPageIndicator: DotsPageIndicatorNonDeprecated = findViewById(R.id.page_indicator)
dotsPageIndicator.setPager(pager) dotsPageIndicator.setPager(pager)
pager?.setOnPageChangeListener(object : GridViewPager.OnPageChangeListener { pager?.setOnPageChangeListener(object : GridViewPager.OnPageChangeListener {
override fun onPageScrolled(row: Int, column: Int, rowOffset: Float, columnOffset: Float, rowOffsetPixels: Int, columnOffsetPixels: Int) { override fun onPageScrolled(row: Int, column: Int, rowOffset: Float, columnOffset: Float, rowOffsetPixels: Int, columnOffsetPixels: Int) {
@ -52,7 +51,7 @@ open class ViewSelectorActivity : DaggerActivity() {
}) })
} }
fun setAdapter(adapter: GridPagerAdapter?) { fun setAdapter(adapter: GridPagerAdapterNonDeprecated?) {
pager?.adapter = adapter pager?.adapter = adapter
} }

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions package info.nightscout.androidaps.interaction.actions
import android.os.Bundle import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionWizardPreCheck import info.nightscout.shared.weardata.EventData.ActionWizardPreCheck
import java.text.DecimalFormat import java.text.DecimalFormat
@ -32,7 +32,7 @@ class WizardActivity : ViewSelectorActivity() {
finish() finish()
} }
private inner class MyGridViewPagerAdapter : GridPagerAdapter() { private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = if (hasPercentage) 3 else 2 override fun getColumnCount(arg0: Int): Int = if (hasPercentage) 3 else 2
override fun getRowCount(): Int = 1 override fun getRowCount(): Int = 1

View file

@ -0,0 +1,11 @@
@file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated
import android.content.Context
import android.support.wearable.view.DotsPageIndicator
import android.util.AttributeSet
// This file does exist only to bypass deprecation warnings in generated code
class DotsPageIndicatorNonDeprecated @JvmOverloads constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : DotsPageIndicator(context, attrs, defStyleAttr)

View file

@ -0,0 +1,9 @@
@file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated
import android.support.wearable.view.GridPagerAdapter
// This file does exist only to bypass deprecation warnings in generated code
abstract class GridPagerAdapterNonDeprecated : GridPagerAdapter()

View file

@ -0,0 +1,11 @@
@file:Suppress("DEPRECATION")
package info.nightscout.androidaps.nondeprecated
import android.content.Context
import android.support.wearable.view.GridViewPager
import android.util.AttributeSet
// This file does exist only to bypass deprecation warnings in generated code
class GridViewPagerNonDeprecated @JvmOverloads constructor(context: Context?, attrs: AttributeSet? = null, defStyle: Int = 0) : GridViewPager(context, attrs, defStyle)

View file

@ -24,13 +24,13 @@
android:textSize="18sp" android:textSize="18sp"
tools:text="Title" /> tools:text="Title" />
<android.support.wearable.view.GridViewPager <info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated
android:id="@+id/pager" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:keepScreenOn="true" /> android:keepScreenOn="true" />
<android.support.wearable.view.DotsPageIndicator <info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated
android:id="@+id/page_indicator" android:id="@+id/page_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"