Skip to content

Commit

Permalink
Spotless 7.0.0 (LawnchairLauncher#5138)
Browse files Browse the repository at this point in the history
* Update plugin com.diffplug.spotless to v7

* Fix styles

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Goooler <[email protected]>
  • Loading branch information
renovate[bot] and Goooler authored Jan 7, 2025
1 parent 66928cc commit 3398fce
Show file tree
Hide file tree
Showing 123 changed files with 1,065 additions and 1,563 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id 'app.cash.licensee' version "1.12.0"
id 'dev.rikka.tools.refine' version "4.4.0"
id 'org.gradle.android.cache-fix' version '3.0.1'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.diffplug.spotless' version '7.0.0'
}


Expand Down
36 changes: 15 additions & 21 deletions lawnchair/src/app/lawnchair/BlankActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,34 +135,28 @@ class BlankActivity : ComponentActivity() {
)
}

suspend fun startBlankActivityForResult(activity: Activity, targetIntent: Intent): ActivityResult {
return start(activity, targetIntent, Bundle.EMPTY)
}
suspend fun startBlankActivityForResult(activity: Activity, targetIntent: Intent): ActivityResult = start(activity, targetIntent, Bundle.EMPTY)

private suspend fun start(activity: Activity, targetIntent: Intent, extras: Bundle): ActivityResult {
return suspendCancellableCoroutine { continuation ->
val intent = Intent(activity, BlankActivity::class.java)
.putExtras(extras)
.putExtra("intent", targetIntent)
val resultReceiver = createResultReceiver {
if (continuation.isActive) {
continuation.resume(it)
}
private suspend fun start(activity: Activity, targetIntent: Intent, extras: Bundle): ActivityResult = suspendCancellableCoroutine { continuation ->
val intent = Intent(activity, BlankActivity::class.java)
.putExtras(extras)
.putExtra("intent", targetIntent)
val resultReceiver = createResultReceiver {
if (continuation.isActive) {
continuation.resume(it)
}
activity.startActivity(intent.putExtra("callback", resultReceiver))
}
activity.startActivity(intent.putExtra("callback", resultReceiver))
}

private fun createResultReceiver(callback: (ActivityResult) -> Unit): ResultReceiver {
return object : ResultReceiver(Handler(Looper.myLooper()!!)) {
private fun createResultReceiver(callback: (ActivityResult) -> Unit): ResultReceiver = object : ResultReceiver(Handler(Looper.myLooper()!!)) {

override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
val data = Intent()
if (resultData != null) {
data.putExtras(resultData)
}
callback(ActivityResult(resultCode, data))
override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
val data = Intent()
if (resultData != null) {
data.putExtras(resultData)
}
callback(ActivityResult(resultCode, data))
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions lawnchair/src/app/lawnchair/DeviceProfileOverrides.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ class DeviceProfileOverrides(context: Context) : SafeCloseable {
prefs.hotseatColumns.set(gridInfo.numHotseatColumns)
}

fun getOverrides(defaultGrid: InvariantDeviceProfile.GridOption) =
Options(
prefs = prefs,
prefs2 = preferenceManager2,
defaultGrid = defaultGrid,
)
fun getOverrides(defaultGrid: InvariantDeviceProfile.GridOption) = Options(
prefs = prefs,
prefs2 = preferenceManager2,
defaultGrid = defaultGrid,
)

fun getTextFactors() = TextFactors(preferenceManager2)
override fun close() {
Expand Down
25 changes: 9 additions & 16 deletions lawnchair/src/app/lawnchair/FeedBridge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,19 @@ class FeedBridge(private val context: Context) {
}
}

private fun customBridgeOrNull(customPackage: String = prefs.feedProvider.get()): CustomBridgeInfo? {
return if (customPackage.isNotBlank()) {
val bridge = CustomBridgeInfo(customPackage)
if (bridge.isAvailable()) bridge else null
} else {
null
}
private fun customBridgeOrNull(customPackage: String = prefs.feedProvider.get()): CustomBridgeInfo? = if (customPackage.isNotBlank()) {
val bridge = CustomBridgeInfo(customPackage)
if (bridge.isAvailable()) bridge else null
} else {
null
}

private fun customBridgeAvailable() = customBridgeOrNull()?.isAvailable() == true

fun isInstalled(): Boolean {
return customBridgeAvailable() || !shouldUseFeed || bridgePackages.any { it.isAvailable() }
}
fun isInstalled(): Boolean = customBridgeAvailable() || !shouldUseFeed || bridgePackages.any { it.isAvailable() }

fun resolveSmartspace(): String {
return bridgePackages.firstOrNull { it.supportsSmartspace }?.packageName
?: "com.google.android.googlequicksearchbox"
}
fun resolveSmartspace(): String = bridgePackages.firstOrNull { it.supportsSmartspace }?.packageName
?: "com.google.android.googlequicksearchbox"

open inner class BridgeInfo(val packageName: String, signatureHashRes: Int) {
protected open val signatureHash =
Expand Down Expand Up @@ -141,8 +135,7 @@ class FeedBridge(private val context: Context) {
}
}

private inner class PixelBridgeInfo(packageName: String, signatureHashRes: Int) :
BridgeInfo(packageName, signatureHashRes) {
private inner class PixelBridgeInfo(packageName: String, signatureHashRes: Int) : BridgeInfo(packageName, signatureHashRes) {
override val supportsSmartspace get() = isAvailable()
}

Expand Down
7 changes: 2 additions & 5 deletions lawnchair/src/app/lawnchair/HeadlessWidgetsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ class HeadlessWidgetsManager(private val context: Context) : SafeCloseable {
context: Context,
appWidgetId: Int,
appWidget: AppWidgetProviderInfo?,
): AppWidgetHostView {
return HeadlessAppWidgetHostView(context)
}
): AppWidgetHostView = HeadlessAppWidgetHostView(context)
}

@SuppressLint("ViewConstructor")
private class HeadlessAppWidgetHostView(context: Context) :
AppWidgetHostView(context) {
private class HeadlessAppWidgetHostView(context: Context) : AppWidgetHostView(context) {

var updateCallback: ((view: AppWidgetHostView) -> Unit)? = null

Expand Down
19 changes: 7 additions & 12 deletions lawnchair/src/app/lawnchair/LawnchairApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ class LawnchairApp : Application() {
}
}

private fun getJournalFile(file: File): File =
File(file.parentFile, "${file.name}-journal")
private fun getJournalFile(file: File): File = File(file.parentFile, "${file.name}-journal")

private fun getSystemUiBoolean(resName: String, fallback: Boolean): Boolean {
val systemUiPackage = "com.android.systemui"
Expand Down Expand Up @@ -210,13 +209,11 @@ class LawnchairApp : Application() {

fun isAccessibilityServiceBound(): Boolean = accessibilityService != null

fun performGlobalAction(action: Int): Boolean {
return accessibilityService?.performGlobalAction(action) ?: run {
Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.let(::startActivity)
false
}
fun performGlobalAction(action: Int): Boolean = accessibilityService?.performGlobalAction(action) ?: run {
Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.let(::startActivity)
false
}

companion object {
Expand Down Expand Up @@ -266,9 +263,7 @@ class LawnchairApp : Application() {
}
}

fun getUriForFile(context: Context, file: File): Uri {
return FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.fileprovider", file)
}
fun getUriForFile(context: Context, file: File): Uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.fileprovider", file)
}
}

Expand Down
4 changes: 1 addition & 3 deletions lawnchair/src/app/lawnchair/LawnchairAppWidgetHostView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class LawnchairAppWidgetHostView @JvmOverloads constructor(
return super.getErrorView()
}

private fun getEmptyView(): View {
return View(context)
}
private fun getEmptyView(): View = View(context)

companion object {

Expand Down
23 changes: 10 additions & 13 deletions lawnchair/src/app/lawnchair/LawnchairLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,13 @@ class LawnchairLauncher : QuickstepLauncher() {
out.add(SearchBarStateHandler(this))
}

override fun getSupportedShortcuts(): Stream<SystemShortcut.Factory<*>> =
override fun getSupportedShortcuts(): Stream<SystemShortcut.Factory<*>> = Stream.concat(
super.getSupportedShortcuts(),
Stream.concat(
super.getSupportedShortcuts(),
Stream.concat(
Stream.of(LawnchairShortcut.UNINSTALL, LawnchairShortcut.CUSTOMIZE),
if (LawnchairApp.isRecentsEnabled) Stream.of(LawnchairShortcut.PAUSE_APPS) else Stream.empty(),
),
)
Stream.of(LawnchairShortcut.UNINSTALL, LawnchairShortcut.CUSTOMIZE),
if (LawnchairApp.isRecentsEnabled) Stream.of(LawnchairShortcut.PAUSE_APPS) else Stream.empty(),
),
)

override fun updateTheme() {
if (themeProvider.colorScheme != colorScheme) {
Expand Down Expand Up @@ -333,12 +332,10 @@ class LawnchairLauncher : QuickstepLauncher() {
return ActivityOptionsWrapper(options, callbacks)
}

override fun getActivityLaunchOptions(v: View?, item: ItemInfo?): ActivityOptionsWrapper {
return runCatching {
super.getActivityLaunchOptions(v, item)
}.getOrElse {
getActivityLaunchOptionsDefault(v)
}
override fun getActivityLaunchOptions(v: View?, item: ItemInfo?): ActivityOptionsWrapper = runCatching {
super.getActivityLaunchOptions(v, item)
}.getOrElse {
getActivityLaunchOptionsDefault(v)
}

private fun getActivityLaunchOptionsDefault(v: View?): ActivityOptionsWrapper {
Expand Down
8 changes: 4 additions & 4 deletions lawnchair/src/app/lawnchair/LawnchairLayoutFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import com.android.launcher3.BubbleTextView
import com.android.launcher3.util.SafeCloseable
import com.android.launcher3.views.DoubleShadowBubbleTextView

class LawnchairLayoutFactory(context: Context) : LayoutInflater.Factory2, SafeCloseable {
class LawnchairLayoutFactory(context: Context) :
LayoutInflater.Factory2,
SafeCloseable {

private val fontManager by lazy { FontManager.INSTANCE.get(context) }
private val constructorMap = mapOf<String, (Context, AttributeSet) -> View>(
Expand All @@ -34,9 +36,7 @@ class LawnchairLayoutFactory(context: Context) : LayoutInflater.Factory2, SafeCl
return view
}

override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
return onCreateView(null, name, context, attrs)
}
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? = onCreateView(null, name, context, attrs)

override fun close() {
TODO("Not yet implemented")
Expand Down
3 changes: 1 addition & 2 deletions lawnchair/src/app/lawnchair/SearchBarStateHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import com.patrykmichalik.opto.core.onEach
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

class SearchBarStateHandler(private val launcher: LawnchairLauncher) :
StateManager.StateHandler<LauncherState> {
class SearchBarStateHandler(private val launcher: LawnchairLauncher) : StateManager.StateHandler<LauncherState> {

private val coroutineScope = CoroutineScope(Dispatchers.IO)
private val preferenceManager2 = PreferenceManager2.getInstance(launcher)
Expand Down
10 changes: 5 additions & 5 deletions lawnchair/src/app/lawnchair/allapps/AllAppsSearchInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ class AllAppsSearchInput(context: Context, attrs: AttributeSet?) :
val inputLowerCase = inputString.lowercase(Locale.getDefault())
val focusedLowerCase = focusedResultTitle.lowercase(Locale.getDefault())
if (canShowHint &&
inputLowerCase.isNotEmpty() && focusedLowerCase.isNotEmpty() &&
inputLowerCase.isNotEmpty() &&
focusedLowerCase.isNotEmpty() &&
focusedLowerCase.matches(Regex("^[\\x00-\\x7F]*$")) &&
focusedLowerCase.startsWith(inputLowerCase)
) {
Expand Down Expand Up @@ -285,7 +286,8 @@ class AllAppsSearchInput(context: Context, attrs: AttributeSet?) :
if (!searchBarController.isSearchFieldFocused && event.action == KeyEvent.ACTION_DOWN) {
val unicodeChar = event.unicodeChar
val isKeyNotWhitespace = unicodeChar > 0 &&
!Character.isWhitespace(unicodeChar) && !Character.isSpaceChar(unicodeChar)
!Character.isWhitespace(unicodeChar) &&
!Character.isSpaceChar(unicodeChar)
if (isKeyNotWhitespace) {
val gotKey = TextKeyListener.getInstance().onKeyDown(input, searchQueryBuilder, event.keyCode, event)
if (gotKey && searchQueryBuilder.isNotEmpty()) {
Expand Down Expand Up @@ -357,9 +359,7 @@ class AllAppsSearchInput(context: Context, attrs: AttributeSet?) :
}
}

override fun getBackgroundVisibility(): Boolean {
return bgVisible
}
override fun getBackgroundVisibility(): Boolean = bgVisible

private fun updateBgAlpha() {
val fraction = bgAlphaAnimator.animatedFraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import android.util.AttributeSet
import app.lawnchair.search.LawnchairSearchUiDelegate
import com.android.launcher3.allapps.LauncherAllAppsContainerView

class SearchContainerView(context: Context?, attrs: AttributeSet?) :
LauncherAllAppsContainerView(context, attrs) {
class SearchContainerView(context: Context?, attrs: AttributeSet?) : LauncherAllAppsContainerView(context, attrs) {

override fun createSearchUiDelegate() = LawnchairSearchUiDelegate(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import com.android.launcher3.R
import com.android.launcher3.views.BubbleTextHolder

class SearchResultIconRow(context: Context, attrs: AttributeSet?) :
LinearLayout(context, attrs), SearchResultView, BubbleTextHolder {
LinearLayout(context, attrs),
SearchResultView,
BubbleTextHolder {

private var isSmall = false
private lateinit var icon: SearchResultIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import com.android.launcher3.DeviceProfile
import com.android.launcher3.R

class SearchResultRightLeftIcon(context: Context, attrs: AttributeSet?) :
LinearLayout(context, attrs), SearchResultView {
LinearLayout(context, attrs),
SearchResultView {

private val launcher = context.launcher
private var grid: DeviceProfile = launcher.deviceProfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import app.lawnchair.theme.color.tokens.ColorTokens
import com.android.launcher3.R

class SearchResultText(context: Context, attrs: AttributeSet?) :
LinearLayout(context, attrs), SearchResultView {
LinearLayout(context, attrs),
SearchResultView {

private val launcher = context.launcher
private lateinit var title: TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ sealed interface SearchResultView {
return flags
}

fun hasFlag(flags: Int, flag: Int): Boolean {
return (flags and flag) != 0
}
fun hasFlag(flags: Int, flag: Int): Boolean = (flags and flag) != 0

fun shouldHandleClick(targetCompat: SearchTargetCompat): Boolean {
val packageName = targetCompat.packageName
Expand Down
Loading

0 comments on commit 3398fce

Please sign in to comment.