Skip to content

Commit

Permalink
Merge pull request #145 from KieronQuinn/release/2.1.1
Browse files Browse the repository at this point in the history
2.1.1
  • Loading branch information
KieronQuinn authored Feb 14, 2023
2 parents 66a30d9 + 94fffa4 commit 1f267b4
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 34 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ plugins {

apply plugin: 'com.google.android.gms.oss-licenses-plugin'

String DEFAULT_MANIFEST = "242:https://storage.googleapis.com/music-iq-db/updatable_ytm_db/20230129-030041/manifest.json"
String DEFAULT_MANIFEST = "243:https://storage.googleapis.com/music-iq-db/updatable_ytm_db/20230212-030106/manifest.json"

def tagName = '2.1'
def version = 210
def tagName = '2.1.1'
def version = 211

def getKeystoreProperties() {
def properties = new Properties()
Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 210,
"versionName": "2.1",
"versionCode": 211,
"versionName": "2.1.1",
"outputFile": "app-release.apk"
}
],
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.kieronquinn.app.ambientmusicmod">

<permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.Handler
import android.os.Looper
import android.os.Message
import android.os.PowerManager
import android.util.Log
import android.view.LayoutInflater
import android.view.WindowManager
import android.view.accessibility.AccessibilityEvent
Expand Down Expand Up @@ -62,7 +63,8 @@ class LockscreenOverlayAccessibilityService : LifecycleAccessibilityService() {
private val shizukuService by inject<ShizukuServiceRepository>()
private val accessibility by inject<AccessibilityRepository>()

private val accessibilityWindow = MutableStateFlow<AccessibilityWindow?>(null)
private val accessibilityWindowName = MutableStateFlow<CharSequence?>(null)
private val accessibilityWindowPackage = MutableStateFlow<String?>(null)
private val lockscreenOverlayState = MutableStateFlow<OverlayState?>(null)
private var currentBinding: OverlayBinding? = null

Expand Down Expand Up @@ -98,12 +100,13 @@ class LockscreenOverlayAccessibilityService : LifecycleAccessibilityService() {
*/
private val accessibilityWindowIsLockscreen = combine(
settings.lockscreenOverlayEnhanced.asFlow(),
accessibilityWindow,
accessibilityWindowName,
accessibilityWindowPackage,
systemUiPackage,
lockScreenText
) { enhanced, window, systemui, lockscreen ->
) { enhanced, windowName, windowPackage, systemui, lockscreen ->
if(!enhanced) return@combine true
window?.packageName == systemui && window.windowName == lockscreen
windowPackage == systemui && windowName == lockscreen
}

private val overlayState by lazy {
Expand Down Expand Up @@ -191,14 +194,37 @@ class LockscreenOverlayAccessibilityService : LifecycleAccessibilityService() {
}

override fun onAccessibilityEvent(event: AccessibilityEvent) {
if(event.packageName == BuildConfig.APPLICATION_ID) return //Prevent self-triggers
//Prevent self-trigger when adding overlay
if(event == null || event.packageName == BuildConfig.APPLICATION_ID) return
when (event.eventType) {
AccessibilityEvent.TYPE_WINDOWS_CHANGED -> {
onWindowsChange(event)
}
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED -> {
onWindowStateChange(event)
}
}
}

private fun onWindowsChange(event: AccessibilityEvent) {
//Get the window responsible for this change
val window = windows.firstOrNull { it.id == event.windowId } ?: return
//Get the package of the app responsible for adding the window
val packageName = window.root?.packageName ?: return
if(packageName == BuildConfig.APPLICATION_ID) return //Prevent self-trigger
//We only care if a window is being added
if(event.windowChanges == AccessibilityEvent.WINDOWS_CHANGE_ADDED){
lifecycleScope.launchWhenCreated {
accessibilityWindowPackage.emit(packageName.toString())
}
}
}

private fun onWindowStateChange(event: AccessibilityEvent) {
if(event.contentChangeTypes == AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED)
return //Prevent triggering for disappearing windows
lifecycleScope.launchWhenCreated {
accessibilityWindow.emit(
AccessibilityWindow(
event.packageName?.toString() ?: return@launchWhenCreated,
event.text?.firstOrNull() ?: return@launchWhenCreated
)
)
accessibilityWindowName.emit(event.text?.firstOrNull() ?: return@launchWhenCreated)
}
}

Expand Down Expand Up @@ -389,6 +415,4 @@ class LockscreenOverlayAccessibilityService : LifecycleAccessibilityService() {
return System.currentTimeMillis() < endTime
}

private data class AccessibilityWindow(val packageName: String, val windowName: CharSequence?)

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ abstract class BaseContainerFragment<V: ViewBinding>(inflate: (LayoutInflater, V
}

private fun BottomNavigationView.setupBottomNavigation() {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
context.getLegacyWorkaroundNavBarHeight()
} else 0
onApplyInsets { view, insets ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class NowPlayingFragment: BoundFragment<FragmentNowPlayingBinding>(FragmentNowPl

private fun setupFab() = with(binding.fabNowplayingRecognise){
backgroundTintList = ColorStateList.valueOf(monet.getPrimaryColor(context))
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
context.getLegacyWorkaroundNavBarHeight()
} else 0
onApplyInsets { _, insets ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SetupCountryPickerFragment: BoundFragment<FragmentSetupCountryPickerBindin

private fun setupInsets() {
val standardPadding = resources.getDimension(R.dimen.margin_16).toInt()
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
requireContext().getLegacyWorkaroundNavBarHeight()
} else 0
binding.setupCountryPickerControls.onApplyInsets { view, insets ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SetupDataUsageFragment: BoundFragment<FragmentSetupDataUsageBinding>(Fragm

private fun setupInsets() {
val standardPadding = resources.getDimension(R.dimen.margin_16).toInt()
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
requireContext().getLegacyWorkaroundNavBarHeight()
} else 0
binding.setupDataUsageControls.onApplyInsets { view, insets ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SetupPermissionsFragment: BoundFragment<FragmentSetupPermissionsBinding>(F

private fun setupInsets() {
val standardPadding = resources.getDimension(R.dimen.margin_16).toInt()
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
requireContext().getLegacyWorkaroundNavBarHeight()
} else 0
binding.setupPermissionsControls.onApplyInsets { view, insets ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kieronquinn.app.ambientmusicmod.utils.extensions

import android.content.Context
import android.os.Build
import android.view.View
import android.view.ViewGroup
import androidx.core.view.*
Expand All @@ -16,18 +17,24 @@ fun View.onApplyInsets(block: (view: View, insets: WindowInsetsCompat) -> Unit)
fun View.applyBottomNavigationInset(extraPadding: Float = 0f) {
val bottomNavHeight = resources.getDimension(R.dimen.bottom_nav_height).toInt()
updatePadding(bottom = bottomNavHeight + extraPadding.toInt())
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
context.getLegacyWorkaroundNavBarHeight()
} else 0
onApplyInsets { _, insets ->
val bottomInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.ime()).bottom + context.getLegacyWorkaroundNavBarHeight()
or WindowInsetsCompat.Type.ime()).bottom + legacyWorkaround
updatePadding(bottom = bottomInsets + bottomNavHeight + extraPadding.toInt())
}
}

fun View.applyBottomNavigationMargin(extraPadding: Float = 0f) {
val bottomNavHeight = resources.getDimension(R.dimen.bottom_nav_height_margins).toInt()
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
context.getLegacyWorkaroundNavBarHeight()
} else 0
onApplyInsets { _, insets ->
val bottomInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom +
context.getLegacyWorkaroundNavBarHeight()
legacyWorkaround
updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(bottom = bottomInsets + bottomNavHeight + extraPadding.toInt())
}
Expand All @@ -36,9 +43,12 @@ fun View.applyBottomNavigationMargin(extraPadding: Float = 0f) {

fun View.applyBottomNavigationMarginShort(extraPadding: Float = 0f) {
val bottomNavHeight = resources.getDimension(R.dimen.bottom_nav_height).toInt()
val legacyWorkaround = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
context.getLegacyWorkaroundNavBarHeight()
} else 0
onApplyInsets { _, insets ->
val bottomInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom +
context.getLegacyWorkaroundNavBarHeight()
legacyWorkaround
updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(bottom = bottomInsets + bottomNavHeight + extraPadding.toInt())
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion app/src/main/res/xml/accessibilityservice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagDefault|flagRetrieveInteractiveWindows"
android:canRetrieveWindowContent="true"
android:accessibilityEventTypes="typeWindowStateChanged"
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowsChanged"
android:settingsActivity="com.kieronquinn.app.ambientmusicmod.app.activities.MainActivity"
android:description="@string/accessibility_service_description" />
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
ext.nav_version = "2.5.3"
ext.protobufVersion = '0.8.17'
ext.shizuku_version = '12.1.0'
ext.refine_version = '3.1.1'
ext.refine_version = '4.1.0'
repositories {
google()
}
Expand All @@ -16,11 +16,11 @@ buildscript {
}

plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
id 'com.google.dagger.hilt.android' version '2.41' apply false
id 'dev.rikka.tools.refine' version '3.1.1' apply false
id 'dev.rikka.tools.refine' version '4.1.0' apply false
}

task clean(type: Delete) {
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun May 01 18:14:37 BST 2022
#Tue Feb 14 21:49:42 GMT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 1f267b4

Please sign in to comment.