Skip to content

Commit

Permalink
chore: switch line length to 120 (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester authored Feb 4, 2025
1 parent 40f19f2 commit b659dd9
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 195 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[*.{kt,kts}]
ktlint_code_style = android_studio

max_line_length = 120
ktlint_code_style = android_studio
ktlint_standard_spacing-between-declarations-with-annotations = disabled

# Prevent ktlint from aggressively wrapping code onto new lines
ktlint_standard_wrapping = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,16 @@ private val Context.corePreferencesStore: DataStore<CorePreferences> by dataStor
class DataStoreModule {
@Singleton
@Provides
fun provideQuickButtonPreferencesStore(
@ApplicationContext appContext: Context
): DataStore<QuickButtonPreferences> = appContext.quickButtonPreferencesStore
fun provideQuickButtonPreferencesStore(@ApplicationContext appContext: Context): DataStore<QuickButtonPreferences> =
appContext.quickButtonPreferencesStore

@Singleton
@Provides
fun provideUnlauncherAppsStore(
@ApplicationContext appContext: Context
): DataStore<UnlauncherApps> = appContext.unlauncherAppsStore
fun provideUnlauncherAppsStore(@ApplicationContext appContext: Context): DataStore<UnlauncherApps> =
appContext.unlauncherAppsStore

@Singleton
@Provides
fun provideCorePreferencesStore(
@ApplicationContext appContext: Context
): DataStore<CorePreferences> = appContext.corePreferencesStore
fun provideCorePreferencesStore(@ApplicationContext appContext: Context): DataStore<CorePreferences> =
appContext.corePreferencesStore
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@ private enum class SharedPrefButton(val key: String) {
RIGHT("quick_button_right")
}

private fun populateLeftButton(sharedPrefs: SharedPreferencesView) =
fun(currentData: QuickButtonPreferences) = when {
currentData.hasLeftButton() -> currentData
else -> sharedPrefs
.getInt(LEFT.key, QuickButtonIcon.IC_CALL.prefId)
.let { setLeftIconId(it)(currentData) }
}
private fun populateCenterButton(sharedPrefs: SharedPreferencesView) =
fun(currentData: QuickButtonPreferences) = when {
currentData.hasCenterButton() -> currentData
else -> sharedPrefs
.getInt(CENTER.key, QuickButtonIcon.IC_COG.prefId)
.let { setCenterIconId(it)(currentData) }
}
private fun populateRightButton(sharedPrefs: SharedPreferencesView) =
fun(currentData: QuickButtonPreferences) = when {
currentData.hasRightButton() -> currentData
else -> sharedPrefs
.getInt(RIGHT.key, QuickButtonIcon.IC_PHOTO_CAMERA.prefId)
.let { setRightIconId(it)(currentData) }
}
private fun populateLeftButton(sharedPrefs: SharedPreferencesView) = fun(currentData: QuickButtonPreferences) = when {
currentData.hasLeftButton() -> currentData
else -> sharedPrefs
.getInt(LEFT.key, QuickButtonIcon.IC_CALL.prefId)
.let { setLeftIconId(it)(currentData) }
}
private fun populateCenterButton(sharedPrefs: SharedPreferencesView) = fun(currentData: QuickButtonPreferences) = when {
currentData.hasCenterButton() -> currentData
else -> sharedPrefs
.getInt(CENTER.key, QuickButtonIcon.IC_COG.prefId)
.let { setCenterIconId(it)(currentData) }
}
private fun populateRightButton(sharedPrefs: SharedPreferencesView) = fun(currentData: QuickButtonPreferences) = when {
currentData.hasRightButton() -> currentData
else -> sharedPrefs
.getInt(RIGHT.key, QuickButtonIcon.IC_PHOTO_CAMERA.prefId)
.let { setRightIconId(it)(currentData) }
}

fun sharedPrefsMigration(context: Context) = SharedPreferencesMigration(
context,
Expand Down Expand Up @@ -73,19 +70,17 @@ private fun defaultRightButton(currentData: QuickButtonPreferences) =
}

object ToThreeQuickButtonsMigration : DataMigration<QuickButtonPreferences> {
override suspend fun shouldMigrate(currentData: QuickButtonPreferences): Boolean =
!getButtonPrefIds()
.containsAll(listOf(
currentData.leftButton.iconId,
currentData.centerButton.iconId,
currentData.rightButton.iconId
))
override suspend fun shouldMigrate(currentData: QuickButtonPreferences): Boolean = !getButtonPrefIds()
.containsAll(listOf(
currentData.leftButton.iconId,
currentData.centerButton.iconId,
currentData.rightButton.iconId
))

override suspend fun migrate(currentData: QuickButtonPreferences): QuickButtonPreferences =
currentData
.let(::defaultLeftButton)
.let(::defaultCenterButton)
.let(::defaultRightButton)
override suspend fun migrate(currentData: QuickButtonPreferences): QuickButtonPreferences = currentData
.let(::defaultLeftButton)
.let(::defaultCenterButton)
.let(::defaultRightButton)

override suspend fun cleanUp() {}
}
13 changes: 2 additions & 11 deletions app/src/main/java/com/sduduzog/slimlauncher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ class MainActivity :
}
}

override fun onApplyThemeResource(
theme: Resources.Theme?,
@StyleRes resid: Int,
first: Boolean
) {
override fun onApplyThemeResource(theme: Resources.Theme?, @StyleRes resid: Int, first: Boolean) {
super.onApplyThemeResource(theme, resid, first)
// This function is called too early in the lifecycle for normal injection so we do it the hard way
val factory = EntryPointAccessors.fromActivity(this, WallpaperManagerFactory::class.java)
Expand Down Expand Up @@ -222,12 +218,7 @@ class MainActivity :
}
}

override fun onFling(
e1: MotionEvent?,
e2: MotionEvent,
velocityX: Float,
velocityY: Float
): Boolean {
override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
val homeView = findViewById<MotionLayout>(R.id.home_fragment)
if (homeView != null) {
val homeScreen = homeView.constraintSetIds[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class AppDrawerAdapter(
}
}

fun getFirstApp(): UnlauncherApp =
filteredApps.filterIsInstance<AppDrawerRow.Item>().first().app
fun getFirstApp(): UnlauncherApp = filteredApps.filterIsInstance<AppDrawerRow.Item>().first().app

override fun getItemViewType(position: Int): Int = filteredApps[position].rowType.ordinal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ data class App(
val userSerial: Long
) {
companion object {
fun from(homeApp: HomeApp) =
App(homeApp.appName, homeApp.packageName, homeApp.activityName, homeApp.userSerial)
fun from(homeApp: HomeApp) = App(homeApp.appName, homeApp.packageName, homeApp.activityName, homeApp.userSerial)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ class UnlauncherAppsMigrations {

abstract class UnlauncherAppsMigration(private val version: Int) :
DataMigration<UnlauncherApps> {
override suspend fun shouldMigrate(currentData: UnlauncherApps): Boolean =
currentData.version < version
override suspend fun shouldMigrate(currentData: UnlauncherApps): Boolean = currentData.version < version

override suspend fun cleanUp() {}

fun updateVersion(builder: UnlauncherApps.Builder): UnlauncherApps =
builder.setVersion(version).build()
fun updateVersion(builder: UnlauncherApps.Builder): UnlauncherApps = builder.setVersion(version).build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,10 @@ class UnlauncherAppsRepository @Inject constructor(
}
}

private fun findApp(
unlauncherApps: List<UnlauncherApp>,
packageName: String,
className: String
): UnlauncherApp? = unlauncherApps.firstOrNull { app ->
packageName == app.packageName && className == app.className
}
private fun findApp(unlauncherApps: List<UnlauncherApp>, packageName: String, className: String): UnlauncherApp? =
unlauncherApps.firstOrNull { app ->
packageName == app.packageName && className == app.className
}
}

fun sortAppsAlphabetically(unlauncherAppsBuilder: UnlauncherApps.Builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import com.jkuester.unlauncher.datastore.proto.CorePreferences
class CorePreferencesMigrations {
fun get(): List<DataMigration<CorePreferences>> = listOf(
object : DataMigration<CorePreferences> {
override suspend fun shouldMigrate(currentData: CorePreferences) =
!currentData.hasClockType()
override suspend fun shouldMigrate(currentData: CorePreferences) = !currentData.hasClockType()
override suspend fun migrate(currentData: CorePreferences) =
currentData.toBuilder().setClockType(ClockType.digital).build()
override suspend fun cleanUp() {}
},
object : DataMigration<CorePreferences> {
override suspend fun shouldMigrate(currentData: CorePreferences) =
!currentData.hasShowSearchBar()
override suspend fun shouldMigrate(currentData: CorePreferences) = !currentData.hasShowSearchBar()
override suspend fun migrate(currentData: CorePreferences) =
currentData.toBuilder().setShowSearchBar(true).build()
override suspend fun cleanUp() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ChooseSearchBarPositionDialog : DialogFragment() {
}

companion object {
fun getSearchBarPositionChooser(): ChooseSearchBarPositionDialog =
ChooseSearchBarPositionDialog()
fun getSearchBarPositionChooser(): ChooseSearchBarPositionDialog = ChooseSearchBarPositionDialog()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ class RenameAppDisplayNameDialog : DialogFragment() {
}

companion object {
fun getInstance(
app: UnlauncherApp,
unlauncherAppsRepo: UnlauncherAppsRepository
): RenameAppDisplayNameDialog = RenameAppDisplayNameDialog().apply {
this.app = app
this.unlauncherAppsRepo = unlauncherAppsRepo
}
fun getInstance(app: UnlauncherApp, unlauncherAppsRepo: UnlauncherAppsRepository): RenameAppDisplayNameDialog =
RenameAppDisplayNameDialog().apply {
this.app = app
this.unlauncherAppsRepo = unlauncherAppsRepo
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ class HomeFragment :
uninstallAppLauncher = registerForActivityResult(StartActivityForResult()) { refreshApps() }
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = if (corePreferencesRepo.get().searchBarPosition == SearchBarPosition.bottom) {
HomeFragmentBottomBinding.inflate(layoutInflater, container, false).root
} else {
HomeFragmentDefaultBinding.inflate(layoutInflater, container, false).root
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
if (corePreferencesRepo.get().searchBarPosition == SearchBarPosition.bottom) {
HomeFragmentBottomBinding.inflate(layoutInflater, container, false).root
} else {
HomeFragmentDefaultBinding.inflate(layoutInflater, container, false).root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down Expand Up @@ -334,20 +331,11 @@ class HomeFragment :
// do nothing
}

override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
endId: Int
) {
override fun onTransitionStarted(motionLayout: MotionLayout?, startId: Int, endId: Int) {
// do nothing
}

override fun onTransitionChange(
motionLayout: MotionLayout?,
startId: Int,
endId: Int,
progress: Float
) {
override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float) {
// do nothing
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ class AddAppFragment :

private val viewModel: AddAppViewModel by viewModels()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.add_app_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.add_app_fragment, container, false)

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ class CustomiseAppsFragment :

private val viewModel: CustomiseAppsViewModel by viewModels()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.customise_apps_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.customise_apps_fragment, container, false)

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -95,18 +92,12 @@ class CustomiseAppsFragment :
)
}

override fun clearView(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder
) {
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
super.clearView(recyclerView, viewHolder)
listener.onViewIdle()
}

override fun getMovementFlags(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder
): Int {
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN
val swipeFlags = 0
return makeMovementFlags(dragFlags, swipeFlags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ class CustomizeAppDrawerAppListFragment : BaseFragment() {
requireView()
).customizeAppDrawerFragment

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.customize_app_drawer_app_list_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.customize_app_drawer_app_list_fragment, container, false)

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ class CustomizeAppDrawerFragment : BaseFragment() {
requireView()
).customizeAppDrawerFragment

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.customize_app_drawer_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.customize_app_drawer_fragment, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -48,9 +45,7 @@ class CustomizeAppDrawerFragment : BaseFragment() {
setupHeadingSwitch(customiseAppDrawerFragment)
}

private fun setupSearchFieldOptionsButton(
customiseAppDrawerFragment: CustomizeAppDrawerFragmentBinding
) {
private fun setupSearchFieldOptionsButton(customiseAppDrawerFragment: CustomizeAppDrawerFragmentBinding) {
customiseAppDrawerFragment.customizeAppDrawerFragmentSearchOptions.setOnClickListener(
Navigation.createNavigateOnClickListener(
R.id.action_customiseAppDrawerFragment_to_customizeSearchFieldFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ class CustomizeQuickButtonsFragment : BaseFragment() {
requireView()
).customizeQuickButtonsFragment

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.customize_quick_buttons_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.customize_quick_buttons_fragment, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Loading

0 comments on commit b659dd9

Please sign in to comment.