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

Commit 3e0c4fc1 authored by Georg Veichtlbauer's avatar Georg Veichtlbauer Committed by Michael Bestas
Browse files

ExactCalculator: Use MotionLayout to animate

Change-Id: Idd5745f37668f29adabfc429ba80fa313006b7fc
parent 41933793
Loading
Loading
Loading
Loading
+31 −10
Original line number Diff line number Diff line
@@ -3,20 +3,32 @@
    SPDX-FileCopyrightText: 2023 The LineageOS Project
    SPDX-License-Identifier: Apache-2.0
-->
<androidx.constraintlayout.widget.ConstraintLayout
<com.android.calculator2.DisplayMotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_calculator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    android:orientation="vertical"
    app:layoutDescription="@xml/activity_calculator_scene">

    <FrameLayout
        android:id="@+id/history_frame"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        android:id="@+id/display"
        layout="@layout/display_one_line"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@id/advanced_pad"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_display_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
@@ -24,8 +36,8 @@
        layout="@layout/advanced_pad"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/layout_vertical_guideline"
        app:layout_constraintHeight_percent="@dimen/layout_pads_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/display" />

@@ -34,16 +46,25 @@
        layout="@layout/input_pad"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_pads_ratio"
        app:layout_constraintStart_toEndOf="@id/layout_vertical_guideline"
        app:layout_constraintTop_toBottomOf="@id/display" />

    <FrameLayout
        android:id="@+id/animation_helper"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_pads_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/layout_vertical_guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.35" />
        app:layout_constraintGuide_percent="@dimen/layout_advanced_pad_ratio" />

</androidx.constraintlayout.widget.ConstraintLayout>
</com.android.calculator2.DisplayMotionLayout>
+38 −15
Original line number Diff line number Diff line
@@ -15,38 +15,61 @@
  limitations under the License.
  -->

<androidx.constraintlayout.widget.ConstraintLayout
<com.android.calculator2.DisplayMotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/linearLayout"
    android:id="@+id/main_calculator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    android:orientation="vertical"
    app:layoutDescription="@xml/activity_calculator_scene">

    <FrameLayout
        android:id="@+id/history_frame"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        android:id="@+id/display"
        layout="@layout/display_two_line"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/advanced_pad"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_display_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        android:id="@+id/advanced_pad"
        layout="@layout/advanced_pad"
        android:layout_width="match_parent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/input_pad"
        app:layout_constraintTop_toBottomOf="@id/display"
        app:layout_constraintVertical_weight="30" />
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_advanced_pad_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/display" />

    <include
        android:id="@+id/input_pad"
        layout="@layout/input_pad"
        android:layout_width="match_parent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_input_pad_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/advanced_pad" />

    <FrameLayout
        android:id="@+id/animation_helper"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/advanced_pad"
        app:layout_constraintVertical_weight="70" />
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="@dimen/layout_pads_ratio"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</com.android.calculator2.DisplayMotionLayout>
+0 −34
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2016 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<com.android.calculator2.DragLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drag_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/main_calculator"
        layout="@layout/activity_calculator" />

    <FrameLayout
        android:id="@+id/history_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible" />

</com.android.calculator2.DragLayout>
+1 −1
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@
        android:background="@color/display_background_color"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:nestedScrollingEnabled="false"
        android:paddingBottom="@dimen/history_divider_padding"
        android:visibility="invisible"
        app:layoutManager="LinearLayoutManager"
        app:reverseLayout="true" />

+12 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    SPDX-FileCopyrightText: 2023 The LineageOS Project
    SPDX-License-Identifier: Apache-2.0
-->
<resources>
    <!-- layout_display_ratio + layout_pads_ratio = 1 -->
    <item type="dimen" format="float" name="layout_display_ratio">0.4</item>
    <item type="dimen" format="float" name="layout_pads_ratio">0.6</item>

    <item type="dimen" format="float" name="layout_advanced_pad_ratio">0.33</item>
</resources>
Loading