Skip to content

Commit

Permalink
Merge pull request #158 from KieronQuinn/release/2.6.5
Browse files Browse the repository at this point in the history
2.6.5
  • Loading branch information
KieronQuinn authored Jul 19, 2024
2 parents 6d69712 + 8640a9f commit 730cbf7
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 50 deletions.
32 changes: 16 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ plugins {
id 'com.google.android.gms.oss-licenses-plugin'
}

def tagName = '2.6.4'
def tagCode = 264
def tagName = '2.6.5'
def tagCode = 265

def getKeystoreProperties() {
def properties = new Properties()
Expand All @@ -29,12 +29,12 @@ def getKeystoreProperties() {
}

android {
compileSdk 34
compileSdk 35

defaultConfig {
applicationId "com.kieronquinn.app.pixellaunchermods"
minSdk 31
targetSdk 34
targetSdk 35
versionCode tagCode
versionName tagName

Expand Down Expand Up @@ -76,26 +76,26 @@ android {

dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"
implementation "androidx.lifecycle:lifecycle-service:2.7.0"
implementation "androidx.fragment:fragment-ktx:1.7.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.3"
implementation "androidx.lifecycle:lifecycle-service:2.8.3"
implementation "androidx.fragment:fragment-ktx:1.8.1"
implementation "androidx.activity:activity-ktx:1.9.0"
implementation "com.simplecityapps:recyclerview-fastscroll:2.0.1"
implementation 'me.zhanghai.android.appiconloader:appiconloader:1.3.1'
implementation 'me.zhanghai.android.appiconloader:appiconloader:1.5.0'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation "io.noties.markwon:core:4.6.2"
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.android.gms:play-services-oss-licenses:17.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
implementation 'com.squareup.retrofit2:converter-gson:2.11.0'

implementation "io.insert-koin:koin-android:3.5.3"
implementation "io.insert-koin:koin-android:3.5.6"
implementation files('libs/apksigner.jar')
implementation 'androidx.work:work-runtime-ktx:2.9.0'
compileOnly project(path: ':systemstubs')
Expand All @@ -111,7 +111,7 @@ dependencies {
implementation "com.github.topjohnwu.libsu:service:${libsuVersion}"

implementation 'com.github.graviton57:sqlite-android:1.0.1'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.code.gson:gson:2.11.0'

def room_version = "2.6.1"
implementation "androidx.room:room-runtime:$room_version"
Expand All @@ -123,6 +123,6 @@ dependencies {
implementation 'com.arasthel:spannedgridlayoutmanager:3.0.2'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
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": 264,
"versionName": "2.6.4",
"versionCode": 265,
"versionName": "2.6.5",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import android.content.Context
import android.content.Intent
import android.content.IntentSender
import android.os.Bundle
import android.util.Log
import android.util.SizeF
import androidx.activity.result.ActivityResultLauncher
import com.kieronquinn.app.pixellaunchermods.utils.extensions.dp
import com.kieronquinn.app.pixellaunchermods.utils.extensions.getIntentSenderForConfigureActivity
import com.kieronquinn.app.pixellaunchermods.utils.widget.LauncherProxyAppWidgetHost
import com.kieronquinn.app.pixellaunchermods.utils.widget.PreviewAppWidgetHost
Expand Down Expand Up @@ -88,15 +91,31 @@ class ProxyAppWidgetRepositoryImpl(
}
}

/**
* Rejects size bundles that would render the widget down to 0x0 (making it invisible)
*/
private fun AppWidgetHostView.updateAppWidgetOptionsIfValid(options: Bundle) {
if(options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) == 0) return
if(options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH) == 0) return
if(options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH) == 0) return
if(options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) == 0) return
updateAppWidgetOptions(options)
val sizes = ArrayList<SizeF>().apply {
val minWidth = options.getIntOrNull(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
?: return@apply
val minHeight = options.getIntOrNull(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
?: return@apply
val maxWidth = options.getIntOrNull(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
?: return@apply
val maxHeight = options.getIntOrNull(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
?: return@apply
add(SizeF(minWidth.dp.toFloat(), minHeight.dp.toFloat()))
add(SizeF(maxWidth.dp.toFloat(), maxHeight.dp.toFloat()))
}
Log.d("PA", "Setting size: $sizes from $options")
updateAppWidgetSize(Bundle.EMPTY, sizes)
}

private fun Bundle.getIntOrNull(key: String): Int? {
return getInt(key).takeIf { it >= 0 }
}

private fun Bundle.copy(to: Bundle, key: String) {
if(getInt(key) != 0) {
to.putInt(key, getInt(key))
}
}

override fun setListening(listening: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class PixelLauncherModsRootServiceImpl: IPixelLauncherModsRootService.Stub() {
)

private const val SEARCH_PROVIDER_SETTINGS_KEY = "SEARCH_PROVIDER_PACKAGE_NAME"
private const val SEARCH_PROVIDER_SETTINGS_KEY_VARIANT = "selected_search_engine"
}

private val context by lazy {
Expand Down Expand Up @@ -763,12 +764,21 @@ class PixelLauncherModsRootServiceImpl: IPixelLauncherModsRootService.Stub() {
}

override fun setSearchWidgetPackageEnabled(enabled: Boolean) {
val key: String
val table: String
if(Build.VERSION.SDK_INT >= 35) {
key = SEARCH_PROVIDER_SETTINGS_KEY_VARIANT
table = "secure"
}else{
key = SEARCH_PROVIDER_SETTINGS_KEY
table = "global"
}
if(enabled) {
//Set it to PLM package name so it uses our Proxy Widget
execRootCommand("settings put global $SEARCH_PROVIDER_SETTINGS_KEY ${BuildConfig.APPLICATION_ID}")
execRootCommand("settings put $table $key ${BuildConfig.APPLICATION_ID}")
}else{
//Delete to set it back to default (null)
execRootCommand("settings delete global $SEARCH_PROVIDER_SETTINGS_KEY")
execRootCommand("settings delete $table $key")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Root

interface ProvidesBack {
fun onBackPressed(): Boolean
fun interceptBack() = true
}

interface ProvidesTitle {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.kieronquinn.app.pixellaunchermods.ui.screens.container

import android.annotation.SuppressLint
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.MenuInflater
import android.view.View
import androidx.activity.addCallback
import androidx.activity.OnBackPressedCallback
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
Expand All @@ -17,7 +18,6 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.NavigationUI
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.elevation.ElevationOverlayProvider
import com.google.android.material.snackbar.Snackbar
import com.kieronquinn.app.pixellaunchermods.R
Expand All @@ -26,8 +26,26 @@ import com.kieronquinn.app.pixellaunchermods.components.navigation.setupWithNavi
import com.kieronquinn.app.pixellaunchermods.components.notifications.requestNotificationPermission
import com.kieronquinn.app.pixellaunchermods.databinding.FragmentContainerBinding
import com.kieronquinn.app.pixellaunchermods.repositories.RemoteAppsRepository
import com.kieronquinn.app.pixellaunchermods.ui.base.*
import com.kieronquinn.app.pixellaunchermods.utils.extensions.*
import com.kieronquinn.app.pixellaunchermods.ui.base.BackAvailable
import com.kieronquinn.app.pixellaunchermods.ui.base.BoundFragment
import com.kieronquinn.app.pixellaunchermods.ui.base.CanShowSnackbar
import com.kieronquinn.app.pixellaunchermods.ui.base.LockCollapsed
import com.kieronquinn.app.pixellaunchermods.ui.base.ProvidesBack
import com.kieronquinn.app.pixellaunchermods.ui.base.ProvidesOverflow
import com.kieronquinn.app.pixellaunchermods.ui.base.ProvidesTitle
import com.kieronquinn.app.pixellaunchermods.utils.extensions.awaitPost
import com.kieronquinn.app.pixellaunchermods.utils.extensions.collapsedState
import com.kieronquinn.app.pixellaunchermods.utils.extensions.getRememberedAppBarCollapsed
import com.kieronquinn.app.pixellaunchermods.utils.extensions.getTopFragment
import com.kieronquinn.app.pixellaunchermods.utils.extensions.onApplyInsets
import com.kieronquinn.app.pixellaunchermods.utils.extensions.onDestinationChanged
import com.kieronquinn.app.pixellaunchermods.utils.extensions.onNavDestinationSelected
import com.kieronquinn.app.pixellaunchermods.utils.extensions.onNavigationIconClicked
import com.kieronquinn.app.pixellaunchermods.utils.extensions.onSwipeDismissed
import com.kieronquinn.app.pixellaunchermods.utils.extensions.rememberAppBarCollapsed
import com.kieronquinn.app.pixellaunchermods.utils.extensions.setOnBackPressedCallback
import com.kieronquinn.app.pixellaunchermods.utils.extensions.setTypeface
import com.kieronquinn.app.pixellaunchermods.utils.extensions.whenResumed
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand Down Expand Up @@ -92,6 +110,11 @@ class ContainerFragment: BoundFragment<FragmentContainerBinding>(FragmentContain
setupApplyState()
setupUpdateSnackbar()
NavigationUI.setupWithNavController(binding.containerBottomNavigation, navController)
binding.containerBottomNavigation.setOnItemSelectedListener { item ->
//Clear the back stack back to the root, to prevent going back between tabs
navController.popBackStack(R.id.nav_graph_main, false)
navController.onNavDestinationSelected(item)
}
requireActivity().requestNotificationPermission()
}

Expand Down Expand Up @@ -138,34 +161,38 @@ class ContainerFragment: BoundFragment<FragmentContainerBinding>(FragmentContain
}
}

@SuppressLint("RestrictedApi")
private fun setupBack() {
val callback = requireActivity().onBackPressedDispatcher.addCallback(
this,
shouldBackDispatcherBeEnabled()
) {
(navHostFragment.getTopFragment() as? ProvidesBack)?.let {
if(it.onBackPressed()) return@addCallback
}
if(!navController.popBackStack()) {
requireActivity().finish()
val callback = object: OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
(navHostFragment.getTopFragment() as? ProvidesBack)?.let {
if(!it.interceptBack()) return@let
if(it.onBackPressed()) return
}
if(!navController.popBackStack()) {
requireActivity().finish()
}
}
}
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
navController.setOnBackPressedCallback(callback)
navController.enableOnBackPressed(shouldBackDispatcherBeEnabled())
navController.setOnBackPressedDispatcher(requireActivity().onBackPressedDispatcher)
whenResumed {
navController.onDestinationChanged().collect {
callback.isEnabled = shouldBackDispatcherBeEnabled()
navController.enableOnBackPressed(shouldBackDispatcherBeEnabled())
}
}
}

private fun shouldBackDispatcherBeEnabled(): Boolean {
val top = navHostFragment.getTopFragment()
return top is ProvidesBack || top !is Root
return top is ProvidesBack && top.interceptBack()
}

private fun setupAppBar() {
binding.containerAppBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
binding.containerAppBar.addOnOffsetChangedListener { appBarLayout, verticalOffset ->
binding.navHostFragment.updatePadding(bottom = appBarLayout.totalScrollRange + verticalOffset)
})
}
}

private fun setupApplyState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fun ActivityOptionsCompat.allowBackground() = apply {
}.get(this) as ActivityOptions
inner.apply {
pendingIntentBackgroundActivityStartMode = MODE_BACKGROUND_ACTIVITY_START_ALLOWED
pendingIntentCreatorBackgroundActivityStartMode = MODE_BACKGROUND_ACTIVITY_START_ALLOWED
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.kieronquinn.app.pixellaunchermods.utils.extensions

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow

Expand All @@ -19,4 +20,11 @@ fun Fragment.childBackStackTopFragment() = callbackFlow {
fun Fragment.getTopFragment(): Fragment? {
if(!isAdded) return null
return childFragmentManager.fragments.firstOrNull()
}

/**
* Helper for [LifecycleOwner].[whenResumed]
*/
fun Fragment.whenResumed(block: suspend CoroutineScope.() -> Unit) {
viewLifecycleOwner.whenResumed(block)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ package com.kieronquinn.app.pixellaunchermods.utils.extensions

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

fun Lifecycle.runOnDestroy(block: () -> Unit) {
addObserver(object: LifecycleObserver {
Expand All @@ -11,4 +17,12 @@ fun Lifecycle.runOnDestroy(block: () -> Unit) {
block()
}
})
}

fun LifecycleOwner.whenResumed(block: suspend CoroutineScope.() -> Unit): Job {
return lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
block()
}
}
}
Loading

0 comments on commit 730cbf7

Please sign in to comment.