Skip to content

Commit 3d3a55c

Browse files
authored
update both target and compile skd to api 35 #ANDROID-15972 (#22)
* update both target and compile skd to api 35 #ANDROID-15972 * fix on back pressed #ANDROID-15972
1 parent ad32ab7 commit 3d3a55c

File tree

7 files changed

+70
-30
lines changed

7 files changed

+70
-30
lines changed

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdk 34
7+
compileSdk 35
88

99
defaultConfig {
1010
applicationId "com.telefonica.androidlogger.app"
1111
minSdkVersion 21
12-
targetSdkVersion 34
12+
targetSdkVersion 35
1313
versionCode 1
1414
versionName "1.0.0"
1515

@@ -32,6 +32,7 @@ android {
3232
}
3333

3434
dependencies {
35+
implementation libs.androidx.activity
3536
implementation libs.androidx.appcompat
3637
implementation project(':library')
3738
}

app/src/main/java/com/telefonica/androidlogger/app/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.telefonica.androidlogger.app
33
import android.os.Bundle
44
import android.util.Log
55
import android.widget.Button
6+
import androidx.activity.enableEdgeToEdge
67
import androidx.appcompat.app.AppCompatActivity
78
import com.telefonica.androidlogger.domain.LogPriority
89
import com.telefonica.androidlogger.domain.log
@@ -13,6 +14,7 @@ import kotlin.random.nextInt
1314
class MainActivity : AppCompatActivity() {
1415

1516
override fun onCreate(savedInstanceState: Bundle?) {
17+
enableEdgeToEdge()
1618
super.onCreate(savedInstanceState)
1719
setContentView(R.layout.activity_main)
1820
setupViews()

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
[versions]
2-
android-gradle-plugin = "8.7.2"
2+
activity = "1.10.1"
3+
android-gradle-plugin = "8.7.3"
34
junit = "4.13.2"
4-
kotlin = "1.9.21"
5+
kotlin = "2.1.10"
56
androidx-lifecycle = "2.2.0"
6-
material = "1.9.0"
7+
material = "1.12.0"
78
elviswhew-xlog = "1.11.1"
89
okio = "3.9.1"
910

1011
[libraries]
12+
androidx-activity = { module = "androidx.activity:activity", version.ref = "activity" }
1113
androidx-annotation = { module = "androidx.annotation:annotation", version = "1.9.1" }
1214
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" }
1315
androidx-lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "androidx-lifecycle" }

library/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ plugins{
44
}
55

66
android {
7-
compileSdk 34
7+
compileSdk 35
88

99
defaultConfig {
1010
minSdkVersion 21
11-
targetSdkVersion 34
11+
targetSdkVersion 35
1212
}
1313

1414
flavorDimensions "loggerMode"
@@ -37,6 +37,7 @@ android {
3737
dependencies {
3838
//noinspection GradleDependency
3939
implementation libs.org.jetbrains.kotlin
40+
implementation libs.androidx.activity
4041
implementation libs.androidx.annotation
4142
enabledImplementation libs.com.google.android.material
4243
enabledImplementation libs.androidx.lifecycle.extensions

library/src/enabled/java/com/telefonica/androidlogger/ui/AppLoggerActivity.kt

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ import android.view.ViewGroup
1818
import android.widget.CompoundButton
1919
import android.widget.TextView
2020
import android.widget.Toast
21+
import androidx.activity.SystemBarStyle
22+
import androidx.activity.enableEdgeToEdge
2123
import androidx.annotation.AttrRes
2224
import androidx.annotation.ColorInt
2325
import androidx.appcompat.app.AppCompatActivity
2426
import androidx.appcompat.widget.SearchView
27+
import androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
28+
import androidx.core.view.WindowInsetsCompat
29+
import androidx.core.view.isVisible
30+
import androidx.core.view.updatePadding
2531
import androidx.lifecycle.Observer
2632
import androidx.lifecycle.ViewModelProvider
2733
import androidx.recyclerview.widget.DefaultItemAnimator
@@ -56,6 +62,10 @@ class AppLoggerActivity : AppCompatActivity() {
5662
private var shareAllLogsCallback: TaskCallback<Uri>? = null
5763

5864
override fun onCreate(savedInstanceState: Bundle?) {
65+
enableEdgeToEdge(
66+
statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT),
67+
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT),
68+
)
5969
super.onCreate(savedInstanceState)
6070

6171
setContentView(R.layout.activity_app_logger)
@@ -69,13 +79,16 @@ class AppLoggerActivity : AppCompatActivity() {
6979
initToolbar()
7080
initLogsList()
7181
initFiltersView()
82+
setOnBackPressed()
83+
setWindowsInsets()
7284

7385
viewModel.getFilteredLogs().observe(this@AppLoggerActivity, Observer {
7486
adapter.onDataModified(it)
7587
if (automaticScrollEnabled) {
7688
recyclerView.post { scrollToBottom() }
7789
}
7890
})
91+
7992
}
8093

8194
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@@ -129,14 +142,18 @@ class AppLoggerActivity : AppCompatActivity() {
129142
else -> super.onOptionsItemSelected(item)
130143
}
131144

132-
override fun onBackPressed() {
133-
searchView?.let {
134-
if (!it.isIconified) {
135-
it.isIconified = true
136-
return
145+
private fun setOnBackPressed() {
146+
onBackPressedDispatcher.addCallback(this, object : androidx.activity.OnBackPressedCallback(true) {
147+
override fun handleOnBackPressed() {
148+
searchView?.let {
149+
if (!it.isIconified) {
150+
it.isIconified = true
151+
return
152+
}
153+
}
154+
finish()
137155
}
138-
}
139-
super.onBackPressed()
156+
})
140157
}
141158

142159
override fun onDestroy() {
@@ -275,7 +292,7 @@ class AppLoggerActivity : AppCompatActivity() {
275292
}
276293

277294
private fun toggleCategoryFilter() {
278-
if (filtersView.visibility == View.VISIBLE) {
295+
if (filtersView.isVisible) {
279296
filtersView.visibility = View.GONE
280297
} else {
281298
filtersView.visibility = View.VISIBLE
@@ -325,8 +342,25 @@ class AppLoggerActivity : AppCompatActivity() {
325342
}, null)
326343
startActivity(shareIntent)
327344
}
345+
346+
private fun setWindowsInsets() {
347+
setOnApplyWindowInsetsListener(recyclerView) { v, windowInsets ->
348+
val bars = windowInsets.getInsets(
349+
WindowInsetsCompat.Type.systemBars()
350+
or WindowInsetsCompat.Type.displayCutout()
351+
)
352+
v.updatePadding(
353+
top = v.paddingTop,
354+
left = bars.left,
355+
right = bars.right,
356+
bottom = bars.bottom,
357+
)
358+
WindowInsetsCompat.CONSUMED
359+
}
360+
}
328361
}
329362

363+
330364
private const val EXTRA_CATEGORIES_NAMES = "extra_categories_names"
331365

332366
@JvmOverloads

library/src/enabled/java/com/telefonica/androidlogger/ui/livedata/FilterableLiveData.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.os.Handler
44
import android.os.Looper
55
import androidx.lifecycle.LiveData
66
import androidx.lifecycle.MediatorLiveData
7-
import androidx.lifecycle.Transformations
7+
import androidx.lifecycle.map
88

99
internal class FilterableLiveData<T>(
1010
source: LiveData<T>,
@@ -62,5 +62,4 @@ internal fun <T> LiveData<T>.throttle(duration: Long = 1000L): LiveData<T> = Med
6262
}
6363
}
6464

65-
internal fun <From, To> LiveData<From>.map(mapFunc: (From) -> To): LiveData<To> =
66-
Transformations.map(this, mapFunc)
65+
internal fun <From, To> LiveData<From>.map(mapFunc: (From) -> To): LiveData<To> = map(mapFunc)

library/src/enabled/res/layout/activity_app_logger.xml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<FrameLayout
2+
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
android:id="@+id/container"
6+
android:orientation="vertical"
57
android:layout_width="match_parent"
68
android:layout_height="match_parent">
79

8-
<androidx.recyclerview.widget.RecyclerView
9-
android:id="@+id/recyclerView"
10-
android:layout_width="match_parent"
11-
android:layout_height="match_parent"
12-
android:layout_marginTop="?attr/actionBarSize"
13-
android:scrollbars="vertical"/>
14-
1510
<com.google.android.material.appbar.AppBarLayout
1611
android:layout_width="match_parent"
17-
android:layout_gravity="top"
18-
android:animateLayoutChanges="true"
19-
android:layout_height="wrap_content">
12+
android:layout_height="wrap_content"
13+
android:fitsSystemWindows="true">
2014

2115
<androidx.appcompat.widget.Toolbar
2216
android:id="@+id/toolbar"
@@ -72,4 +66,11 @@
7266

7367
</com.google.android.material.appbar.AppBarLayout>
7468

75-
</FrameLayout>
69+
<androidx.recyclerview.widget.RecyclerView
70+
android:id="@+id/recyclerView"
71+
android:layout_width="match_parent"
72+
android:layout_height="match_parent"
73+
android:clipToPadding="false"
74+
android:scrollbars="vertical" />
75+
76+
</LinearLayout>

0 commit comments

Comments
 (0)