Skip to content

Commit

Permalink
Target API 35
Browse files Browse the repository at this point in the history
This switches the UI layout to edge-to-edge wherever possible since API
35 now enforces it.

All other dependencies have also been updated.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
  • Loading branch information
chenxiaolong committed Sep 4, 2024
1 parent 952cf85 commit cb2dfb7
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 351 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
name: Build app
runs-on: ubuntu-latest
env:
androidApi: 34
androidArch: x86_64
steps:
- name: Check out repository
Expand Down Expand Up @@ -43,7 +42,9 @@ jobs:
id: get_version
shell: bash
run: |
sed -nr 's/^\s*(ndkVersion)\s*(=)\s"(.+)".*$/\1\2\3/p' \
sed -nr \
-e 's/^\s*(compileSdk)\s*(=)\s([0-9]+).*$/\1\2\3/p' \
-e 's/^\s*(ndkVersion)\s*(=)\s"(.+)".*$/\1\2\3/p' \
app/build.gradle.kts \
>> "${GITHUB_OUTPUT}"
Expand All @@ -60,13 +61,15 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.androidApi }}-${{ env.androidArch }}-${{ steps.get_version.outputs.ndkVersion }}
key: avd-${{ steps.get_version.outputs.compileSdk }}-${{ env.androidArch }}-${{ steps.get_version.outputs.ndkVersion }}

- name: Create AVD snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.androidApi }}
# TODO: Remove after Google publishes AOSP-based image.
target: google_apis
api-level: ${{ steps.get_version.outputs.compileSdk }}
arch: ${{ env.androidArch }}
ndk: ${{ steps.get_version.outputs.ndkVersion }}
force-avd-creation: false
Expand All @@ -77,7 +80,9 @@ jobs:
- name: Build and test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.androidApi }}
# TODO: Remove after Google publishes AOSP-based image.
target: google_apis
api-level: ${{ steps.get_version.outputs.compileSdk }}
arch: ${{ env.androidArch }}
ndk: ${{ steps.get_version.outputs.ndkVersion }}
force-avd-creation: false
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ val rcbridgeAar = rcbridgeDir.map { it.file("rcbridge.aar") }
android {
namespace = "com.chiller3.rsaf"

compileSdk = 34
buildToolsVersion = "34.0.0"
ndkVersion = "26.3.11579264"
compileSdk = 35
buildToolsVersion = "35.0.0"
ndkVersion = "27.0.12077973"

defaultConfig {
applicationId = "com.chiller3.rsaf"
minSdk = 28
targetSdk = 34
targetSdk = 35
versionCode = gitVersionCode
versionName = gitVersionName

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/chiller3/rsaf/RcloneProvider.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.chiller3.rsaf

import android.content.ContentResolver
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.AssetFileDescriptor
import android.database.Cursor
import android.database.MatrixCursor
import android.graphics.Point
import android.os.*
import android.os.CancellationSignal
import android.os.Handler
import android.os.HandlerThread
import android.os.ParcelFileDescriptor
import android.os.ProxyFileDescriptorCallback
import android.os.storage.StorageManager
import android.provider.DocumentsContract
import android.provider.DocumentsProvider
Expand Down Expand Up @@ -290,7 +295,10 @@ class RcloneProvider : DocumentsProvider(), SharedPreferences.OnSharedPreference

private fun revokeGrants(documentId: String) {
val uri = DocumentsContract.buildDocumentUri(BuildConfig.DOCUMENTS_AUTHORITY, documentId)
context!!.revokeUriPermission(uri, 0.inv())
context!!.revokeUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION and Intent.FLAG_GRANT_WRITE_URI_PERMISSION,
)
}

override fun onCreate(): Boolean {
Expand Down
28 changes: 26 additions & 2 deletions app/src/main/java/com/chiller3/rsaf/SettingsActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.chiller3.rsaf

import android.os.Bundle
import android.view.ViewGroup
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import com.chiller3.rsaf.databinding.SettingsActivityBinding

class SettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.settings_activity)

val binding = SettingsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)

val transaction = supportFragmentManager.beginTransaction()

Expand All @@ -23,6 +32,21 @@ class SettingsActivity : AppCompatActivity() {

transaction.commit()

setSupportActionBar(findViewById(R.id.toolbar))
ViewCompat.setOnApplyWindowInsetsListener(binding.toolbar) { v, windowInsets ->
val insets = windowInsets.getInsets(
WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.displayCutout()
)

v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
leftMargin = insets.left
topMargin = insets.top
rightMargin = insets.right
}

WindowInsetsCompat.CONSUMED
}

setSupportActionBar(binding.toolbar)
}
}
37 changes: 37 additions & 0 deletions app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import android.os.Environment
import android.provider.DocumentsContract
import android.provider.Settings
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.biometric.BiometricManager.Authenticators
import androidx.biometric.BiometricPrompt
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import androidx.fragment.app.FragmentResultListener
import androidx.fragment.app.clearFragmentResult
import androidx.fragment.app.viewModels
Expand All @@ -28,6 +33,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import androidx.preference.get
import androidx.preference.size
import androidx.recyclerview.widget.RecyclerView
import com.chiller3.rsaf.binding.rcbridge.Rcbridge
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -94,6 +100,37 @@ class SettingsFragment : PreferenceFragmentCompat(), FragmentResultListener,
}
}

override fun onCreateRecyclerView(
inflater: LayoutInflater,
parent: ViewGroup,
savedInstanceState: Bundle?
): RecyclerView {
val view = super.onCreateRecyclerView(inflater, parent, savedInstanceState)

view.clipToPadding = false

ViewCompat.setOnApplyWindowInsetsListener(view) { v, windowInsets ->
val insets = windowInsets.getInsets(
WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.displayCutout()
)

// This is a little bit ugly in landscape mode because the divider lines for categories
// extend into the inset area. However, it's worth applying the left/right padding here
// anyway because it allows the inset area to be used for scrolling instead of just
// being a useless dead zone.
v.updatePadding(
bottom = insets.bottom,
left = insets.left,
right = insets.right,
)

WindowInsetsCompat.CONSUMED
}

return view
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.preferences_root, rootKey)

Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<resources>
<style name="Theme.RSAF" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="windowActionModeOverlay">true</item>
<item name="switchPreferenceCompatStyle">@style/SwitchPreferenceCompat.Material3</item>
</style>
</resources>
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
activity-ktx = "1.9.0"
android-gradle-plugin = "8.5.1"
activity-ktx = "1.9.2"
android-gradle-plugin = "8.6.0"
appcompat = "1.7.0"
biometric = "1.1.0"
core-ktx = "1.13.1"
jgit = "6.10.0.202406032230-r"
espresso-core = "3.6.1"
fragment-ktx = "1.8.1"
fragment-ktx = "1.8.3"
junit = "1.2.1"
kotlin = "2.0.0"
material = "1.12.0"
Expand Down
Loading

0 comments on commit cb2dfb7

Please sign in to comment.