Skip to content

Commit

Permalink
updated dependencies; fixed deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sal0max committed Jun 19, 2021
1 parent fd00e57 commit 49b8586
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ dependencies {
kapt "androidx.room:room-compiler:$room_version"

// SupportLibs
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.3.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class CalculatorActivity : BaseActivity() {
true
} else {
val intent = Intent(this, BillingActivity().javaClass)
startActivityForResult(intent, 1)
startActivity(intent)
false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.text.TextWatcher
import android.view.Menu
import android.view.MenuItem
import android.widget.EditText
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.ViewModelProvider
import de.salomax.ndx.R
import de.salomax.ndx.data.Filter
Expand Down Expand Up @@ -70,8 +71,8 @@ class FilterEditorActivity : BaseActivity() {
binding.factor.onlyGreaterEqualOne()

binding.btnCalibrator.setOnClickListener {
val intent = Intent(this, CalibratorActivity().javaClass)
startActivityForResult(intent, 1)
val intent = Intent(this, CalibratorActivity().javaClass)
calibratorActivityWithResult.launch(intent)
}

// title bar
Expand All @@ -83,6 +84,13 @@ class FilterEditorActivity : BaseActivity() {
}
}

private val calibratorActivityWithResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
val data: Intent? = result.data
if (result.resultCode == Activity.RESULT_OK && data != null && data.hasExtra("FACTOR")) {
init(data.getIntExtra("FACTOR", 1))
}
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
Expand Down Expand Up @@ -115,14 +123,6 @@ class FilterEditorActivity : BaseActivity() {
}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 1 && resultCode == Activity.RESULT_OK
&& data != null && data.hasExtra("FACTOR")) {
init(data.getIntExtra("FACTOR", 1))
}
}

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.salomax.ndx.ui.filterpouch
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
Expand All @@ -25,10 +26,6 @@ class FilterPouchActivity : BaseActivity() {

private val filterAdapter: FilterAdapter = FilterAdapter(this)

companion object {
private const val ARG_EDIT = 1
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -40,7 +37,7 @@ class FilterPouchActivity : BaseActivity() {
filterAdapter.onClick = {
val intent = Intent(this, FilterEditorActivity().javaClass)
intent.putExtra(FilterEditorActivity.ARG_FILTER, it)
startActivityForResult(intent, ARG_EDIT)
filterEditorActivityWithResult.launch(intent)
}
binding.list.apply {
layoutManager = LinearLayoutManager(context)
Expand All @@ -56,7 +53,7 @@ class FilterPouchActivity : BaseActivity() {
startActivity(intent)
} else {
val intent = Intent(this, BillingActivity().javaClass)
startActivityForResult(intent, 1)
startActivity(intent)
}
}

Expand All @@ -71,20 +68,20 @@ class FilterPouchActivity : BaseActivity() {
viewModel.filters.observe(this, { filterAdapter.setFilters(it) })
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
private val filterEditorActivityWithResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
val data: Intent? = result.data
// filter got deleted: show undo
if (requestCode == ARG_EDIT && resultCode == Activity.RESULT_OK && data != null) {
if (result.resultCode == Activity.RESULT_OK && data != null) {
val filter = data.getParcelableExtra<Filter>("FILTER")!!
Snackbar.make(binding.list, getString(R.string.filterDeleted, filter.name), 5_000) // 5s
.setAction(R.string.undo) { viewModel.insert(filter) }
.show()
.setAction(R.string.undo) { viewModel.insert(filter) }
.show()
}
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class PreferenceFragment : PreferenceFragmentCompat(),
.startActivities()
} else {
val intent = Intent(context, BillingActivity().javaClass)
startActivityForResult(intent, 1)
startActivity(intent)
return false
}
}
Expand All @@ -143,7 +143,7 @@ class PreferenceFragment : PreferenceFragmentCompat(),
when (preference) {
donatePreference -> {
val intent = Intent(context, BillingActivity().javaClass)
startActivityForResult(intent, 1)
startActivity(intent)
}
aboutPreference -> {
val fragment = ChangelogDialog()
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.0'
ext.kotlin_version = '1.5.10'
repositories {
google()
mavenCentral()
}
dependencies {
// android
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:4.2.1'
// kotlin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down

0 comments on commit 49b8586

Please sign in to comment.