Skip to content

Commit

Permalink
Update: Fix NL to fit A14-QPR1
Browse files Browse the repository at this point in the history
  • Loading branch information
machiav3lli committed Dec 18, 2023
1 parent 4e9ea4b commit e129211
Show file tree
Hide file tree
Showing 47 changed files with 124 additions and 145 deletions.
4 changes: 2 additions & 2 deletions Omega/src/com/saggitt/omega/DeviceProfileOverrides.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import com.android.launcher3.util.MainThreadInitializedObject
import com.saggitt.omega.preferences.NeoPrefs

class DeviceProfileOverrides(context: Context) {
private val prefs by lazy { Utilities.getOmegaPrefs(context) }
private val prefs by lazy { Utilities.getNeoPrefs(context) }

private val predefinedGrids = InvariantDeviceProfile.parseAllGridOptions(context)
private val predefinedGrids = InvariantDeviceProfile.parseAllDefinedGridOptions(context)
.map { option ->
val gridInfo = DBGridInfo(
numHotseatIcons = option.numHotseatIcons,
Expand Down
19 changes: 4 additions & 15 deletions Omega/src/com/saggitt/omega/NeoLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ import androidx.core.app.ActivityOptionsCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.setViewTreeLifecycleOwner
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import com.android.launcher3.AppFilter
import com.android.launcher3.Launcher
import com.android.launcher3.LauncherAppState
import com.android.launcher3.LauncherRootView
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.model.data.AppInfo
Expand Down Expand Up @@ -82,18 +79,18 @@ import kotlinx.coroutines.launch
import java.util.stream.Stream

class NeoLauncher : Launcher(), LifecycleOwner, SavedStateRegistryOwner,
ActivityResultRegistryOwner, ThemeManager.ThemeableActivity {
ActivityResultRegistryOwner, ThemeManager.ThemeableActivity {

override var currentTheme = 0
override var currentAccent = 0
private lateinit var themeOverride: ThemeOverride
private val themeSet: ThemeOverride.ThemeSet get() = ThemeOverride.Settings()

val prefs: NeoPrefs by lazy { Utilities.getOmegaPrefs(this) }
val prefs: NeoPrefs by lazy { Utilities.getNeoPrefs(this) }
val gestureController by lazy { GestureController(this) }
val background by lazy { findViewById<OmegaBackgroundView>(R.id.omega_background)!! }
val dummyView by lazy { findViewById<View>(R.id.dummy_view)!! }
val optionsView by lazy { findViewById<OptionsPopupView>(R.id.options_view)!! }
val optionsView by lazy { findViewById<OptionsPopupView<Launcher>>(R.id.options_view)!! }
private val prefCallback = PreferencesChangeCallback(this)

val hiddenApps = ArrayList<AppInfo>()
Expand Down Expand Up @@ -338,14 +335,6 @@ class NeoLauncher : Launcher(), LifecycleOwner, SavedStateRegistryOwner,
}
}

override fun setupViews() {
super.setupViews()
findViewById<LauncherRootView>(R.id.launcher).also {
it.setViewTreeLifecycleOwner(this)
it.setViewTreeSavedStateRegistryOwner(this)
}
}

fun recreateIfNotScheduled() {
if (sRestartFlags == 0) {
recreate()
Expand All @@ -354,7 +343,7 @@ class NeoLauncher : Launcher(), LifecycleOwner, SavedStateRegistryOwner,

private fun restartIfPending() {
when {
sRestartFlags and FLAG_RESTART != 0 -> neoApp.restart(false)
sRestartFlags and FLAG_RESTART != 0 -> neoApp.restart(false)
sRestartFlags and FLAG_RECREATE != 0 -> {
sRestartFlags = 0
recreate()
Expand Down
3 changes: 1 addition & 2 deletions Omega/src/com/saggitt/omega/OptionsState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class OptionsState(id: Int) :
val scaledHeight = scale * ws.normalChildHeight
val shrunkTop = (insets.top + grid.dropTargetBarSizePx).toFloat()
val shrunkBottom = (ws.measuredHeight - insets.bottom
- grid.workspacePadding.bottom
- grid.workspaceSpringLoadedBottomSpace).toFloat()
- grid.workspacePadding.bottom).toFloat()
val totalShrunkSpace = shrunkBottom - shrunkTop

val desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2
Expand Down
4 changes: 2 additions & 2 deletions Omega/src/com/saggitt/omega/allapps/AllAppsPagesController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class AllAppsPagesController<T : BaseDraggingActivity>(
return holders.toTypedArray()
}

fun registerIconContainers(allAppsStore: AllAppsStore) {
fun registerIconContainers(allAppsStore: AllAppsStore<T>) {
//holders.forEach { allAppsStore.registerIconContainer(it.mRecyclerView) }
}

fun unregisterIconContainers(allAppsStore: AllAppsStore) {
fun unregisterIconContainers(allAppsStore: AllAppsStore<T>) {
//holders.forEach { allAppsStore.unregisterIconContainer(it.mRecyclerView) }
}

Expand Down
2 changes: 1 addition & 1 deletion Omega/src/com/saggitt/omega/allapps/AllAppsTabItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AllAppsTabItem(context: Context, attrs: AttributeSet) :
private var mIsRtl = false

private val mArgbEvaluator: ArgbEvaluator = ArgbEvaluator()
val prefs: NeoPrefs = Utilities.getOmegaPrefs(context)
val prefs: NeoPrefs = Utilities.getNeoPrefs(context)
val launcher: Launcher = Launcher.getLauncher(context)

init {
Expand Down
7 changes: 4 additions & 3 deletions Omega/src/com/saggitt/omega/allapps/AllAppsTabsController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.saggitt.omega.allapps

import android.view.View
import android.view.ViewGroup
import com.android.launcher3.BaseDraggingActivity
import com.android.launcher3.allapps.ActivityAllAppsContainerView
import com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.MAIN
import com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.WORK
Expand All @@ -11,7 +12,7 @@ import com.saggitt.omega.util.forEachChildIndexed

typealias AdapterHolders = List<ActivityAllAppsContainerView<*>.AdapterHolder>

class AllAppsTabsController(
class AllAppsTabsController<T : BaseDraggingActivity>(
val tabs: AllAppsTabs,
private val container: ActivityAllAppsContainerView<*>,
) {
Expand Down Expand Up @@ -46,11 +47,11 @@ class AllAppsTabsController(
tabs.reloadTabs()
}

fun registerIconContainers(allAppsStore: AllAppsStore) {
fun registerIconContainers(allAppsStore: AllAppsStore<T>) {
holders.forEach { allAppsStore.registerIconContainer(it.mRecyclerView) }
}

fun unregisterIconContainers(allAppsStore: AllAppsStore) {
fun unregisterIconContainers(allAppsStore: AllAppsStore<T>) {
holders.forEach { allAppsStore.unregisterIconContainer(it.mRecyclerView) }
}

Expand Down
2 changes: 1 addition & 1 deletion Omega/src/com/saggitt/omega/allapps/AllAppsTabsLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import java.util.function.Consumer

class AllAppsTabsLayout(context: Context, attrs: AttributeSet) :
PersonalWorkSlidingTabStrip(context, attrs) {
val prefs: NeoPrefs = Utilities.getOmegaPrefs(context)
val prefs: NeoPrefs = Utilities.getNeoPrefs(context)
val launcher: Launcher = Launcher.getLauncher(context)
private val selectedPage: MutableState<Int> = mutableIntStateOf(0)

Expand Down
4 changes: 2 additions & 2 deletions Omega/src/com/saggitt/omega/allapps/CustomAppFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class CustomAppFilter(private val mContext: Context) : OmegaAppFilter(mContext)
}

private fun getHiddenApps(context: Context): MutableSet<String> {
return HashSet(Utilities.getOmegaPrefs(context).drawerHiddenAppSet.getValue())
return HashSet(Utilities.getNeoPrefs(context).drawerHiddenAppSet.getValue())
}

fun setHiddenApps(context: Context, hiddenApps: Set<String>?) {
Utilities.getOmegaPrefs(context).drawerHiddenAppSet.setValue(hiddenApps!!)
Utilities.getNeoPrefs(context).drawerHiddenAppSet.setValue(hiddenApps!!)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package com.saggitt.omega.allapps.search
import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.util.TypedValue
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -61,12 +60,10 @@ import coil.compose.rememberAsyncImagePainter
import com.android.launcher3.ExtendedEditText
import com.android.launcher3.Insettable
import com.android.launcher3.R
import com.android.launcher3.ResourceUtils
import com.android.launcher3.allapps.ActivityAllAppsContainerView
import com.android.launcher3.allapps.BaseAllAppsAdapter
import com.android.launcher3.allapps.SearchUiManager
import com.android.launcher3.allapps.search.AllAppsSearchBarController
import com.android.launcher3.graphics.IconShape
import com.android.launcher3.search.SearchCallback
import com.saggitt.omega.compose.icons.Phosphor
import com.saggitt.omega.compose.icons.phosphor.Nut
Expand Down Expand Up @@ -112,11 +109,7 @@ open class ComposeSearchLayout(context: Context, attrs: AttributeSet? = null) :

var radius by remember { mutableFloatStateOf(0f) }
val radiusPrefs = prefs.searchBarRadius.get().collectAsState(initial = 0f)
radius = if (radiusPrefs.value < 0) {
getCornerRadius()
} else {
radiusPrefs.value
}
radius = radiusPrefs.value.coerceAtLeast(8f)

var textFieldValue by query

Expand Down Expand Up @@ -229,12 +222,6 @@ open class ComposeSearchLayout(context: Context, attrs: AttributeSet? = null) :
}
}

private fun getCornerRadius(): Float {
val defaultRadius = ResourceUtils.pxFromDp(100f, resources.displayMetrics).toFloat()
val edgeRadius: TypedValue? = IconShape.getShape().getAttrValue(R.attr.qsbEdgeRadius)
return edgeRadius?.getDimension(context.resources.displayMetrics) ?: defaultRadius
}

private fun onQueryChanged(query: String) {
if (query.isEmpty()) {
searchAlgorithm.cancel(true)
Expand Down Expand Up @@ -278,10 +265,6 @@ open class ComposeSearchLayout(context: Context, attrs: AttributeSet? = null) :

override fun getEditText(): ExtendedEditText? = null

override fun hideSoftwareKeyboard() {
keyboardController?.hide()
}

override fun onSearchResult(
query: String?,
items: ArrayList<BaseAllAppsAdapter.AdapterItem>?,
Expand Down
24 changes: 12 additions & 12 deletions Omega/src/com/saggitt/omega/blur/BlurScrimView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.animation.Interpolator
import androidx.core.graphics.ColorUtils
import com.android.app.animation.Interpolators.ACCELERATE
import com.android.app.animation.Interpolators.ACCELERATE_2
import com.android.app.animation.Interpolators.LINEAR
import com.android.launcher3.LauncherState.BACKGROUND_APP
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.anim.Interpolators.ACCEL
import com.android.launcher3.anim.Interpolators.ACCEL_2
import com.android.launcher3.anim.Interpolators.LINEAR
import com.android.launcher3.util.SystemUiController
import com.android.launcher3.util.Themes
import com.android.launcher3.views.ScrimView
Expand All @@ -42,7 +42,7 @@ import com.saggitt.omega.util.runOnMainThread
import kotlin.math.roundToInt

class BlurScrimView(context: Context, attrs: AttributeSet?) : ScrimView(context, attrs),
BlurWallpaperProvider.Listener {
BlurWallpaperProvider.Listener {
private val prefs = NeoPrefs.getInstance(context)
private var drawerOpacity = prefs.drawerBackgroundOpacity.getValue()
private var radius = prefs.profileBlurRadius.getValue()
Expand Down Expand Up @@ -76,16 +76,16 @@ class BlurScrimView(context: Context, attrs: AttributeSet?) : ScrimView(context,
private var mProgress = 1f
private var mShelfColor = 0
private var fullBlurProgress = 0f
private var mBeforeMidProgressColorInterpolator: Interpolator = ACCEL
private var mAfterMidProgressColorInterpolator: Interpolator = ACCEL
private var mBeforeMidProgressColorInterpolator: Interpolator = ACCELERATE
private var mAfterMidProgressColorInterpolator: Interpolator = ACCELERATE

// Mid point where the alpha changes
private var mMidAlpha = 0
private var mMidProgress = 0f
override fun updateSysUiColors() {
val threshold = STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD
val forceChange = visibility == VISIBLE &&
alpha > threshold && Color.alpha(mBackgroundColor) / (255f * drawerOpacity) > threshold
alpha > threshold && Color.alpha(backgroundColor) / (255f * drawerOpacity) > threshold
with(systemUiController) {
if (forceChange) {
updateUiState(SystemUiController.UI_STATE_SCRIM_VIEW, !isScrimDark)
Expand Down Expand Up @@ -117,12 +117,12 @@ class BlurScrimView(context: Context, attrs: AttributeSet?) : ScrimView(context,

private fun updateColors() {
val alpha = when {
useFlatColor -> ((1 - mProgress) * 255).toInt()
mProgress >= fullBlurProgress -> (255 * ACCEL_2.getInterpolation(
useFlatColor -> ((1 - mProgress) * 255).toInt()
mProgress >= fullBlurProgress -> (255 * ACCELERATE_2.getInterpolation(
0f.coerceAtLeast(1 - mProgress) / (1 - fullBlurProgress)
)).roundToInt()

else -> 255
else -> 255
}
blurDrawable?.alpha = alpha

Expand All @@ -139,13 +139,13 @@ class BlurScrimView(context: Context, attrs: AttributeSet?) : ScrimView(context,

private fun getColorForProgress(progress: Float): Int {
val interpolatedProgress: Float = when {
progress >= 1 -> progress
progress >= 1 -> progress
progress >= mMidProgress -> Utilities.mapToRange(
progress, mMidProgress, 1f, mMidProgress, 1f,
mBeforeMidProgressColorInterpolator
)

else -> Utilities.mapToRange(
else -> Utilities.mapToRange(
progress, 0f, mMidProgress, 0f, mMidProgress, mAfterMidProgressColorInterpolator
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import com.android.app.animation.Interpolators
import com.android.launcher3.Launcher
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.anim.Interpolators
import com.android.launcher3.anim.PendingAnimation
import com.android.launcher3.util.SystemUiController
import com.android.launcher3.util.Themes
Expand All @@ -44,7 +44,7 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
private val container = ComposeView(context)
private val mLauncher = Launcher.getLauncher(context)
private var imeShift = 0f
private var _hintCloseProgress = mutableStateOf(0f)
private var _hintCloseProgress = mutableFloatStateOf(0f)
private val hintCloseProgress get() = _hintCloseProgress.value
var hintCloseDistance = 0f
private set
Expand All @@ -68,7 +68,7 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
bottom = 50.dp,
start = 0.dp,
end = 0.dp
)
),
) {
container.setContent {
OmegaAppTheme {
Expand All @@ -89,17 +89,17 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
}

private fun animateOpen(animate: Boolean) {
if (mIsOpen || mOpenCloseAnimator.isRunning) {
if (mIsOpen || mOpenCloseAnimation.animationPlayer.isRunning) {
return
}
mIsOpen = true
setupNavBarColor()
mOpenCloseAnimator.setValues(
mOpenCloseAnimation.animationPlayer.setValues(
PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)
)
mOpenCloseAnimator.interpolator = Interpolators.FAST_OUT_SLOW_IN
if (!animate) mOpenCloseAnimator.duration = 0
mOpenCloseAnimator.start()
mOpenCloseAnimation.animationPlayer.interpolator = Interpolators.FAST_OUT_SLOW_IN
if (!animate) mOpenCloseAnimation.animationPlayer.duration = 0
mOpenCloseAnimation.animationPlayer.start()
}

private fun setupNavBarColor() {
Expand All @@ -126,15 +126,15 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
override fun addHintCloseAnim(
distanceToMove: Float,
interpolator: Interpolator,
target: PendingAnimation
target: PendingAnimation,
) {
super.addHintCloseAnim(distanceToMove, interpolator, target)
hintCloseDistance = distanceToMove
target.setFloat(this, HINT_CLOSE_PROGRESS, 1f, interpolator)
}

private fun updateContentShift() {
if (!Utilities.getOmegaPrefs(context).showDebugInfo.getValue()) {
if (!Utilities.getNeoPrefs(context).showDebugInfo.getValue()) {
mContent.translationY = mTranslationShift * mContent.height + imeShift
}
}
Expand All @@ -147,7 +147,7 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
@Composable
private fun ContentWrapper(
contentPaddings: PaddingValues = PaddingValues(all = 0.dp),
content: @Composable ComposeBottomSheet.() -> Unit
content: @Composable ComposeBottomSheet.() -> Unit,
) {
val imePaddings = WindowInsets.ime
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
Expand Down Expand Up @@ -189,7 +189,7 @@ class ComposeBottomSheet(context: Context, attrs: AttributeSet? = null) :
fun show(
context: Context,
animate: Boolean = true,
content: @Composable ComposeBottomSheet.() -> Unit
content: @Composable ComposeBottomSheet.() -> Unit,
) {
val bottomSheet = ComposeBottomSheet(context)
bottomSheet.setContent(content)
Expand Down
Loading

0 comments on commit e129211

Please sign in to comment.