From c85978e4e2f0653192a22353b2b1c12b586cfc47 Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+brayandso@users.noreply.github.com> Date: Sun, 22 Dec 2024 08:48:30 -0300 Subject: [PATCH] refactor: replace ConstraintLayouts in reviewer2.xml They were initially used because of the WIP nature of the reviewer, so they would be able to handle any design decisions Now that most of the reviewer is implemented, I don't see a need for using ConstraintLayouts anymore, so I am replacing them with LinearLayouts LinearLayouts are simpler to deal with, have less boilerplate, and make easier to preview changes. They also render faster --- .../ui/windows/reviewer/ReviewerFragment.kt | 4 +- AnkiDroid/src/main/res/layout/reviewer2.xml | 76 +++++++------------ AnkiDroid/src/main/res/values/dimens.xml | 3 + 3 files changed, 32 insertions(+), 51 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt index 5bcff6cce1d7..b4c62bd7972b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt @@ -27,11 +27,11 @@ import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager import android.webkit.WebView import android.widget.FrameLayout +import android.widget.LinearLayout import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.StringRes import androidx.appcompat.view.menu.SubMenuBuilder import androidx.appcompat.widget.ActionMenuView -import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.getSystemService import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat @@ -298,7 +298,7 @@ class ReviewerFragment : viewModel.onShowAnswer(typedAnswer = typedAnswer) } } - val answerButtonsLayout = view.findViewById(R.id.answer_buttons) + val answerButtonsLayout = view.findViewById(R.id.answer_buttons) // TODO add some kind of feedback/animation after tapping show answer or the answer buttons viewModel.showingAnswer.collectLatestIn(lifecycleScope) { shouldShowAnswer -> diff --git a/AnkiDroid/src/main/res/layout/reviewer2.xml b/AnkiDroid/src/main/res/layout/reviewer2.xml index 1db32c052a5a..4b4821bc5b96 100644 --- a/AnkiDroid/src/main/res/layout/reviewer2.xml +++ b/AnkiDroid/src/main/res/layout/reviewer2.xml @@ -9,23 +9,23 @@ android:fitsSystemWindows="true" tools:context=".ui.windows.reviewer.ReviewerFragment"> - + android:layout_marginBottom="4dp" + android:orientation="vertical"> + > @@ -71,29 +71,24 @@ android:id="@+id/webview_container" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginHorizontal="8dp" + android:layout_marginHorizontal="@dimen/reviewer_side_margin" android:layout_marginBottom="4dp" - app:layout_constraintTop_toBottomOf="@id/appbar" - app:layout_constraintBottom_toTopOf="@id/type_answer_container" - style="@style/CardView.ViewerStyle"> + style="@style/CardView.ViewerStyle" + android:layout_weight="1"> - + android:layout_height="match_parent"/> - - - - + - + \ No newline at end of file diff --git a/AnkiDroid/src/main/res/values/dimens.xml b/AnkiDroid/src/main/res/values/dimens.xml index f2972034785d..246a717470e1 100644 --- a/AnkiDroid/src/main/res/values/dimens.xml +++ b/AnkiDroid/src/main/res/values/dimens.xml @@ -33,4 +33,7 @@ 8dp 8dp 8dp + + 8dp + 3dp \ No newline at end of file