Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b558b4f authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Translate and Scale the status area with the large weather clock

This is intended to better position smartspace when using the weather
clock on certain devices, but does this by adjusting the entire
status area. In practice this is fine as smartspace is the only child
view that's rendered in this case.

Bug: 283308908
Test: Manually checked on several device
Change-Id: I75378c6a2732f8486eef49b91a1c24caed002f1a
Merged-In: I75378c6a2732f8486eef49b91a1c24caed002f1a
parent 765c65d9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@

    <!-- Not quite optimal but needed to translate these items as a group. The
         NotificationIconContainer has its own logic for translation. -->
    <LinearLayout
    <com.android.keyguard.KeyguardStatusAreaView
        android:id="@+id/keyguard_status_area"
        android:orientation="vertical"
        android:layout_width="match_parent"
@@ -63,5 +63,5 @@
          android:paddingStart="@dimen/below_clock_padding_start_icons"
          android:visibility="invisible"
          />
    </LinearLayout>
    </com.android.keyguard.KeyguardStatusAreaView>
</com.android.keyguard.KeyguardClockSwitch>
+1 −1
Original line number Diff line number Diff line
@@ -16,5 +16,5 @@
  -->
<resources>
     <!-- Invisibility to use for the date & weather view when it is disabled by a clock -->
    <integer name="keyguard_date_weather_view_invisibility">8</integer>
    <integer name="keyguard_date_weather_view_invisibility">4</integer>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -148,4 +148,9 @@
    <dimen name="default_dot_diameter">34dp</dimen>
    <dimen name="default_dot_spacing">0dp</dimen>

    <!-- Weather clock smartspace scaling to apply for the weather clock -->
    <item name="weather_clock_smartspace_scale" type="dimen" format="float">1.0</item>
    <dimen name="weather_clock_smartspace_translateX">0dp</dimen>
    <dimen name="weather_clock_smartspace_translateY">0dp</dimen>

</resources>
+14 −0
Original line number Diff line number Diff line
@@ -17,4 +17,18 @@

<resources>
    <item type="id" name="header_footer_views_added_tag_key" />

    <!-- animation channels for keyguard status area -->
    <item type="id" name="translate_x_clock_design_animator_tag" />
    <item type="id" name="translate_x_clock_design_animator_start_tag" />
    <item type="id" name="translate_x_clock_design_animator_end_tag" />
    <item type="id" name="translate_x_aod_animator_tag" />
    <item type="id" name="translate_x_aod_animator_start_tag" />
    <item type="id" name="translate_x_aod_animator_end_tag" />
    <item type="id" name="translate_y_clock_size_animator_tag" />
    <item type="id" name="translate_y_clock_size_animator_start_tag" />
    <item type="id" name="translate_y_clock_size_animator_end_tag" />
    <item type="id" name="translate_y_clock_design_animator_tag" />
    <item type="id" name="translate_y_clock_design_animator_start_tag" />
    <item type="id" name="translate_y_clock_design_animator_end_tag" />
</resources>
+10 −5
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ class UnfoldConstantTranslateAnimator(
            } else {
                1
            }
        viewsToTranslate.forEach { (view, direction) ->
            view.get()?.translationX = xTrans * direction.multiplier * rtlMultiplier
        viewsToTranslate.forEach { (view, direction, func) ->
            view.get()?.let { func(it, xTrans * direction.multiplier * rtlMultiplier) }
        }
    }

@@ -77,7 +77,7 @@ class UnfoldConstantTranslateAnimator(
                .filter { it.shouldBeAnimated() }
                .mapNotNull {
                    parent.findViewById<View>(it.viewId)?.let { view ->
                        ViewToTranslate(WeakReference(view), it.direction)
                        ViewToTranslate(WeakReference(view), it.direction, it.translateFunc)
                    }
                }
                .toList()
@@ -91,14 +91,19 @@ class UnfoldConstantTranslateAnimator(
    data class ViewIdToTranslate(
        val viewId: Int,
        val direction: Direction,
        val shouldBeAnimated: () -> Boolean = { true }
        val shouldBeAnimated: () -> Boolean = { true },
        val translateFunc: (View, Float) -> Unit = { view, value -> view.translationX = value },
    )

    /**
     * Represents a view whose animation process is in-progress. It should be immutable because the
     * started animation should be completed.
     */
    private data class ViewToTranslate(val view: WeakReference<View>, val direction: Direction)
    private data class ViewToTranslate(
        val view: WeakReference<View>,
        val direction: Direction,
        val translateFunc: (View, Float) -> Unit,
    )

    /** Direction of the animation. */
    enum class Direction(val multiplier: Float) {
Loading