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
return
}
@Suppress("DEPRECATION")
super.onBackPressed()
}

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions
import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck
import java.text.DecimalFormat
@ -29,7 +29,7 @@ class CarbActivity : ViewSelectorActivity() {
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 increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,17 +4,16 @@ package info.nightscout.androidaps.interaction.actions
import android.content.Context
import android.os.Bundle
import android.support.wearable.view.DotsPageIndicator
import android.support.wearable.view.GridPagerAdapter
import android.support.wearable.view.GridViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.wear.widget.CurvedTextView
import dagger.android.DaggerActivity
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.shared.sharedPreferences.SP
import javax.inject.Inject
@ -27,14 +26,14 @@ open class ViewSelectorActivity : DaggerActivity() {
@Inject lateinit var sp: SP
@Inject lateinit var rxBus: RxBus
private var pager: GridViewPager? = null
private var pager: GridViewPagerNonDeprecated? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.grid_layout)
setTitleBasedOnScreenShape()
pager = findViewById(R.id.pager)
val dotsPageIndicator: DotsPageIndicator = findViewById(R.id.page_indicator)
val dotsPageIndicator: DotsPageIndicatorNonDeprecated = findViewById(R.id.page_indicator)
dotsPageIndicator.setPager(pager)
pager?.setOnPageChangeListener(object : GridViewPager.OnPageChangeListener {
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
}

View file

@ -3,7 +3,6 @@
package info.nightscout.androidaps.interaction.actions
import android.os.Bundle
import android.support.wearable.view.GridPagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -12,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventWearToMobile
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
import info.nightscout.androidaps.nondeprecated.GridPagerAdapterNonDeprecated
import info.nightscout.shared.SafeParse
import info.nightscout.shared.weardata.EventData.ActionWizardPreCheck
import java.text.DecimalFormat
@ -32,7 +32,7 @@ class WizardActivity : ViewSelectorActivity() {
finish()
}
private inner class MyGridViewPagerAdapter : GridPagerAdapter() {
private inner class MyGridViewPagerAdapter : GridPagerAdapterNonDeprecated() {
override fun getColumnCount(arg0: Int): Int = if (hasPercentage) 3 else 2
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"
tools:text="Title" />
<android.support.wearable.view.GridViewPager
<info.nightscout.androidaps.nondeprecated.GridViewPagerNonDeprecated
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true" />
<android.support.wearable.view.DotsPageIndicator
<info.nightscout.androidaps.nondeprecated.DotsPageIndicatorNonDeprecated
android:id="@+id/page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"