Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: smartspacer padding #5204

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lawnchair/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<dimen name="enhanced_smartspace_icon_margin">6dp</dimen>
<dimen name="enhanced_smartspace_icon_size">20dp</dimen>
<dimen name="enhanced_smartspace_margin_start_launcher">0dp</dimen>
<dimen name="enhanced_smartspace_padding_start">16dp</dimen>
<dimen name="enhanced_smartspace_padding_top">16dp</dimen>
<dimen name="enhanced_smartspace_secondary_card_corner_radius">28dp</dimen>
<dimen name="enhanced_smartspace_secondary_card_end_margin">1dp</dimen>
Expand Down
12 changes: 6 additions & 6 deletions lawnchair/src/app/lawnchair/smartspace/SmartspacerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import android.graphics.Rect
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View
import androidx.viewpager.widget.ViewPager
import app.lawnchair.LawnchairLauncher
import app.lawnchair.launcher
import app.lawnchair.launcherNullable
import app.lawnchair.preferences2.PreferenceManager2
import app.lawnchair.preferences2.subscribeBlocking
import app.lawnchair.ui.preferences.PreferenceActivity
Expand All @@ -27,6 +27,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

class SmartspacerView(context: Context, attrs: AttributeSet?) : BcSmartspaceView(context, attrs) {
private lateinit var viewPager: ViewPager
private val prefs2 = PreferenceManager2.getInstance(context)
private val coroutineScope = CoroutineScope(Dispatchers.Default)
private var targetCount = 5
Expand Down Expand Up @@ -69,11 +70,10 @@ class SmartspacerView(context: Context, attrs: AttributeSet?) : BcSmartspaceView
}
}

override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) {
val ctx = LawnchairLauncher.instance?.launcherNullable
val dp = ctx?.deviceProfile
val leftPadding = dp?.widgetPadding?.left ?: (left + 16)
super.setPadding(leftPadding, top, right, bottom)
override fun onFinishInflate() {
super.onFinishInflate()
viewPager = findViewById<ViewPager>(SmartspacerR.id.smartspace_card_pager)!!
viewPager.setLayoutParams(LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.UNSPECIFIED_GRAVITY))
}

override val config = SmartspaceConfig(
Expand Down
4 changes: 3 additions & 1 deletion res/layout/smartspace_smartspacer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/enhanced_smartspace_margin_start_launcher">
android:clipChildren="false"
android:clipToPadding="false"
android:paddingStart="@dimen/enhanced_smartspace_padding_start">

<androidx.viewpager.widget.ViewPager
android:id="@+id/smartspace_card_pager"
Expand Down
Loading