From a520170c138838d3b22eec6a810f6b6d6ee4811f Mon Sep 17 00:00:00 2001 From: pecpaker Date: Tue, 13 Oct 2020 16:15:34 +0100 Subject: [PATCH 01/18] {{Fixes #1997:Optimise code in profile chooser fragment xml}} --- .idea/codeStyles/Project.xml | 3 +- .idea/codeStyles/codeStyleConfig.xml | 3 +- .../layout-land/profile_chooser_fragment.xml | 21 ++++------- .../profile_chooser_profile_view.xml | 17 +++------ .../profile_chooser_fragment.xml | 12 ++----- .../profile_chooser_fragment.xml | 15 +++----- .../profile_chooser_profile_view.xml | 17 +++------ .../res/layout/profile_chooser_fragment.xml | 17 +++------ .../layout/profile_chooser_profile_view.xml | 36 +++++++++---------- 9 files changed, 44 insertions(+), 97 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 66d46e74f0c..4f861030d47 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,5 +1,6 @@ + - + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 78ea4beff08..79ee123c2b2 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout-land/profile_chooser_fragment.xml b/app/src/main/res/layout-land/profile_chooser_fragment.xml index 722d7639a0d..595e923267a 100644 --- a/app/src/main/res/layout-land/profile_chooser_fragment.xml +++ b/app/src/main/res/layout-land/profile_chooser_fragment.xml @@ -39,30 +39,24 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -93,8 +87,8 @@ android:layout_height="96dp" android:background="@drawable/profile_chooser_gradient" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + android:textColor="@color/profileChooserGreyTextColor" /> + android:textColor="@color/white" /> diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_fragment.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_fragment.xml index 3f928a3ee05..6a6b5150706 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_fragment.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_fragment.xml @@ -44,15 +44,12 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -111,15 +108,12 @@ app:layout_constraintEnd_toEndOf="parent"> + android:textColor="@color/profileChooserGreyTextColor" /> - @@ -44,15 +43,12 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -111,15 +107,12 @@ app:layout_constraintEnd_toEndOf="parent"> + android:textColor="@color/profileChooserGreyTextColor" /> + android:textColor="@color/white" /> diff --git a/app/src/main/res/layout/profile_chooser_fragment.xml b/app/src/main/res/layout/profile_chooser_fragment.xml index dfcad6d878b..5f6cbc19f94 100644 --- a/app/src/main/res/layout/profile_chooser_fragment.xml +++ b/app/src/main/res/layout/profile_chooser_fragment.xml @@ -39,30 +39,24 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -106,15 +100,12 @@ app:layout_constraintEnd_toEndOf="parent"> + android:textColor="@color/profileChooserGreyTextColor" /> - + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_20dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}"> + android:textColor="@color/white" /> @@ -95,8 +89,10 @@ android:id="@+id/add_profile_divider_view" android:layout_width="match_parent" android:layout_height="0.5dp" - android:layout_marginTop="60dp" android:background="@color/oppiaProfileChooserDivider" - android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" /> - + android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> + From 5367b77872d6574138464b8ce764e05b4d7ff85a Mon Sep 17 00:00:00 2001 From: pecpaker Date: Tue, 13 Oct 2020 18:03:17 +0100 Subject: [PATCH 02/18] {{Fix #1997:Optimise code in profile_chooser_profile_view.xml}} --- .../profile_chooser_profile_view.xml | 4 ++-- .../profile_chooser_profile_view.xml | 19 +++++-------------- .../profile_chooser_profile_view.xml | 2 +- .../layout/profile_chooser_profile_view.xml | 4 ++-- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index 48ada102bdf..b2abc4cc5e7 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -45,7 +45,7 @@ android:layout_marginBottom="8dp" app:civ_border_color="@color/avatarBorder" app:civ_border_width="1dp" - profile:src="@{viewModel.profile.avatar}" /> + profile:src="@{viewModel.profile.avatar}"/> + app:layout_constraintTop_toTopOf="parent"/> diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index b29d78bdcf2..89304ebbbac 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -59,24 +59,18 @@ + android:textColor="@color/white"/> @@ -103,6 +94,6 @@ android:layout_height="0.5dp" android:layout_marginTop="40dp" android:background="@color/oppiaProfileChooserDivider" - android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" /> + android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"/> diff --git a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml index e128d45e8b0..20fe11d6a59 100644 --- a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml @@ -94,6 +94,6 @@ android:layout_height="0.5dp" android:layout_marginTop="72dp" android:background="@color/oppiaProfileChooserDivider" - android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" /> + android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"/> diff --git a/app/src/main/res/layout/profile_chooser_profile_view.xml b/app/src/main/res/layout/profile_chooser_profile_view.xml index f325850a49c..594520264d5 100644 --- a/app/src/main/res/layout/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout/profile_chooser_profile_view.xml @@ -46,7 +46,7 @@ android:layout_height="72dp" app:civ_border_color="@color/avatarBorder" app:civ_border_width="1dp" - profile:src="@{viewModel.profile.avatar}" /> + profile:src="@{viewModel.profile.avatar}"/> + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item"/> From b83140cee44d2f7d12f820101ba0da66347f5c36 Mon Sep 17 00:00:00 2001 From: pecpaker Date: Tue, 13 Oct 2020 18:07:21 +0100 Subject: [PATCH 03/18] {{Fix #1957:Optimise code in profile_chooser_profile_view.xml}} --- app/src/main/res/layout-land/profile_chooser_profile_view.xml | 2 +- .../res/layout-sw600dp-land/profile_chooser_profile_view.xml | 2 +- .../res/layout-sw600dp-port/profile_chooser_profile_view.xml | 2 +- app/src/main/res/layout/profile_chooser_profile_view.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index b2abc4cc5e7..56b0816eba9 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -64,7 +64,7 @@ android:textColor="@color/white" android:textStyle="italic" android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" - profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> + profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}"/> + type="org.oppia.android.app.model.ProfileChooserUiModel"/> + profile:src="@{viewModel.profile.avatar}"/> + android:visibility="@{viewModel.profile.isAdmin && hasProfileEverBeenAddedValue ? View.VISIBLE : View.GONE}"/> From a0a8ee913503694e9ff2554717ba2e140c095e1d Mon Sep 17 00:00:00 2001 From: pecpaker Date: Wed, 14 Oct 2020 16:36:59 +0100 Subject: [PATCH 04/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view.xml }} --- .idea/codeStyles/Project.xml | 1 - .idea/codeStyles/codeStyleConfig.xml | 1 + .../profile_chooser_profile_view.xml | 16 +++++++++++----- .../profile_chooser_profile_view.xml | 16 +++++++++++----- .../profile_chooser_profile_view.xml | 14 ++++++++++---- .../res/layout/profile_chooser_profile_view.xml | 17 ++++++++++++----- 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 4f861030d47..6be1663d998 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,6 +1,5 @@ - @@ -89,10 +95,11 @@ android:id="@+id/add_profile_divider_view" android:layout_width="match_parent" android:layout_height="0.5dp" + android:layout_marginTop="60dp" android:background="@color/oppiaProfileChooserDivider" android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item"/> + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> From 054871300da08ac3b7215ba1f40987c943a24d9b Mon Sep 17 00:00:00 2001 From: pecpaker Date: Fri, 16 Oct 2020 11:04:46 +0100 Subject: [PATCH 05/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view}} --- .../profile_chooser_profile_view.xml | 124 +++++++++--------- .../profile_chooser_profile_view.xml | 124 +++++++++--------- .../layout/profile_chooser_profile_view.xml | 110 ++++++++-------- 3 files changed, 179 insertions(+), 179 deletions(-) diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index 1a4f94f875d..32dfd8d926c 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -20,78 +20,75 @@ type="org.oppia.android.app.model.ProfileChooserUiModel" /> - + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + profile:ignore="RtlSymmetry"> + + + android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}" + android:orientation="vertical" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" + app:layout_constraintBottom_toBottomOf="@+id/profile_avatar_img" + app:layout_constraintStart_toEndOf="@+id/profile_avatar_img" + app:layout_constraintTop_toTopOf="parent"> - + - - - - - + android:layout_marginTop="4dp" + android:fontFamily="sans-serif-light" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="italic" + android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" + profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> - - + - + android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + diff --git a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml index 987f649d24b..306b1f4de40 100644 --- a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml @@ -20,78 +20,75 @@ type="org.oppia.android.app.model.ProfileChooserUiModel" /> - + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + profile:ignore="RtlSymmetry"> + + + android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}" + android:orientation="vertical" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" + app:layout_constraintBottom_toBottomOf="@+id/profile_avatar_img" + app:layout_constraintStart_toEndOf="@+id/profile_avatar_img" + app:layout_constraintTop_toTopOf="parent"> - + - - - - - + android:layout_marginTop="4dp" + android:fontFamily="sans-serif-light" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="italic" + android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" + profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> - - + - + android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + diff --git a/app/src/main/res/layout/profile_chooser_profile_view.xml b/app/src/main/res/layout/profile_chooser_profile_view.xml index a13e3c933c8..8b04b43141d 100644 --- a/app/src/main/res/layout/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout/profile_chooser_profile_view.xml @@ -21,74 +21,73 @@ + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/space_28dp}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/space_28dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + - + - + android:fontFamily="sans-serif-light" + android:textColor="@color/white" + android:textSize="12sp" + android:textStyle="italic" + android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" + profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> - - - - - - + + app:layout_constraintTop_toBottomOf="@+id/linearLayout3" /> From 18c6e7060e9e2072055e5542d8c00b28d56d9810 Mon Sep 17 00:00:00 2001 From: pecpaker Date: Fri, 16 Oct 2020 11:45:07 +0100 Subject: [PATCH 06/18] {{Fixes #2008: Optimise code in profile_choose_profile --- .../res/layout-sw600dp-land/profile_chooser_profile_view.xml | 2 +- .../res/layout-sw600dp-port/profile_chooser_profile_view.xml | 2 +- app/src/main/res/layout/profile_chooser_profile_view.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index 32dfd8d926c..1795875ac7d 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -22,7 +22,7 @@ Date: Fri, 16 Oct 2020 13:33:22 +0100 Subject: [PATCH 07/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view}} --- .../res/layout-sw600dp-port/profile_chooser_profile_view.xml | 2 +- app/src/main/res/layout/profile_chooser_profile_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml index f1f1b11bb69..3ec817d2d24 100644 --- a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml @@ -21,9 +21,9 @@ Date: Fri, 16 Oct 2020 21:51:30 +0100 Subject: [PATCH 08/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view}} --- .../profile_chooser_profile_view.xml | 113 +++++++++--------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index 0c372a1072c..a14902a99b7 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -21,66 +21,71 @@ + android:id="@+id/profile_chooser_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:gravity="center_horizontal" + android:orientation="vertical" + app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/space_28dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/space_24dp}" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + profile:src="@{viewModel.profile.avatar}" /> - - - + - + - - + Date: Sat, 17 Oct 2020 09:32:08 +0100 Subject: [PATCH 09/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view}} --- .idea/codeStyles/Project.xml | 2 +- .idea/codeStyles/codeStyleConfig.xml | 2 +- app/src/main/res/layout-land/profile_chooser_profile_view.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 6be1663d998..66d46e74f0c 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -161,4 +161,4 @@ - \ No newline at end of file + diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index b784ffe676e..78ea4beff08 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -3,4 +3,4 @@ From dcc636c9ecff41e93e73601e76256ef1c690b8fd Mon Sep 17 00:00:00 2001 From: pecpaker Date: Sat, 17 Oct 2020 12:17:08 +0100 Subject: [PATCH 11/18] {{Fixes #2008: Optimise code in profile_chooser_profile_view}} --- app/src/main/res/layout/profile_chooser_profile_view.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/profile_chooser_profile_view.xml b/app/src/main/res/layout/profile_chooser_profile_view.xml index 916bbb89a1f..6c60a2ad3e0 100644 --- a/app/src/main/res/layout/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout/profile_chooser_profile_view.xml @@ -41,7 +41,8 @@ app:civ_border_width="1dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - profile:src="@{viewModel.profile.avatar}" /> + profile:src="@{viewModel.profile.avatar}" + app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/profile_view_already_added_margin : @dimen/space_0dp}"/> Date: Fri, 23 Oct 2020 22:44:44 +0100 Subject: [PATCH 12/18] {{Fix #1957: Optimise code in profile_chooser_profile_view.xml}} --- .../profile_chooser_profile_view.xml | 26 ++-- .../profile_chooser_profile_view.xml | 130 +++++++++--------- .../profile_chooser_profile_view.xml | 124 +++++++++-------- .../layout/profile_chooser_profile_view.xml | 117 ++++++++-------- 4 files changed, 203 insertions(+), 194 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index c34ddc85328..4a89049fe4f 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -24,6 +24,8 @@ android:id="@+id/profile_chooser_item" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" android:gravity="center_horizontal" android:orientation="vertical" app:layout_constraintEnd_toEndOf="parent" @@ -34,9 +36,10 @@ android:id="@+id/profile_avatar_img" android:layout_width="72dp" android:layout_height="72dp" - android:layout_marginBottom="8dp" + android:layout_marginTop="@dimen/space_8dp" app:civ_border_color="@color/avatarBorder" app:civ_border_width="1dp" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" profile:src="@{viewModel.profile.avatar}" /> @@ -51,20 +54,21 @@ android:singleLine="false" android:text="@{viewModel.profile.name}" android:textColor="@color/white" - app:layout_constraintStart_toEndOf="@+id/profile_avatar_img" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintEnd_toEndOf="@+id/profile_avatar_img" + app:layout_constraintStart_toStartOf="@+id/profile_avatar_img" + app:layout_constraintTop_toBottomOf="@+id/profile_avatar_img" /> @@ -72,7 +76,7 @@ android:id="@+id/profile_is_admin_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/space_16dp" + android:layout_marginTop="@dimen/space_12dp" android:fontFamily="sans-serif-light" android:gravity="center" android:text="@string/profile_chooser_admin" @@ -80,21 +84,21 @@ android:textSize="12sp" android:textStyle="italic" android:visibility="@{viewModel.profile.isAdmin ? View.VISIBLE : View.GONE}" - app:layout_constraintStart_toStartOf="@+id/profile_last_visited" - app:layout_constraintTop_toBottomOf="@+id/profile_last_visited" /> + app:layout_constraintEnd_toEndOf="@+id/profile_name_text" + app:layout_constraintStart_toStartOf="@+id/profile_name_text" + app:layout_constraintTop_toBottomOf="@+id/profile_name_text" /> diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index 563cec49afa..3fc7a68c948 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -21,87 +21,91 @@ + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_298dp}" + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_298dp}" + app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_0dp}"> - + profile:ignore="RtlSymmetry"> - + - + - + + + + + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> + diff --git a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml index 3c470acc395..f7217a8e1b0 100644 --- a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml @@ -21,87 +21,89 @@ + app:layout_constraintTop_toTopOf="parent"> - + profile:ignore="RtlSymmetry"> - + - + - + + + + + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> diff --git a/app/src/main/res/layout/profile_chooser_profile_view.xml b/app/src/main/res/layout/profile_chooser_profile_view.xml index ece2b2fbd66..7c6701e65fd 100644 --- a/app/src/main/res/layout/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout/profile_chooser_profile_view.xml @@ -21,76 +21,75 @@ + + android:id="@+id/profile_avatar_img" + android:layout_width="72dp" + android:layout_height="72dp" + app:civ_border_color="@color/avatarBorder" + app:civ_border_width="1dp" + profile:src="@{viewModel.profile.avatar}" /> - + - + - + + + app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> From dd1627f936c2613bf68b80d658faf0f53de5ffd4 Mon Sep 17 00:00:00 2001 From: pecpaker Date: Tue, 27 Oct 2020 15:28:27 +0100 Subject: [PATCH 13/18] Margins updated --- .../profile_chooser_profile_view.xml | 6 ++++-- .../profile_chooser_profile_view.xml | 7 ++----- .../profile_chooser_profile_view.xml | 9 +++------ .../layout/profile_chooser_profile_view.xml | 20 +++++++++---------- ...xtInputEqualsRuleClassifierProviderTest.kt | 1 - 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index 4a89049fe4f..207c502d5a4 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -28,6 +28,8 @@ android:layout_marginEnd="16dp" android:gravity="center_horizontal" android:orientation="vertical" + app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/profile_view_already_added_margin : @dimen/space_28dp}" + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/space_24dp}" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -36,7 +38,7 @@ android:id="@+id/profile_avatar_img" android:layout_width="72dp" android:layout_height="72dp" - android:layout_marginTop="@dimen/space_8dp" + android:layout_marginBottom="@dimen/space_8dp" app:civ_border_color="@color/avatarBorder" app:civ_border_width="1dp" app:layout_constraintEnd_toEndOf="parent" @@ -76,8 +78,8 @@ android:id="@+id/profile_is_admin_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/space_12dp" android:fontFamily="sans-serif-light" + android:layout_marginTop="@dimen/space_0dp" android:gravity="center" android:text="@string/profile_chooser_admin" android:textColor="@color/white" diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index 3fc7a68c948..94b1c7eb56f 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -36,8 +36,8 @@ android:layout_height="wrap_content" android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}" android:orientation="@{hasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}" - app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" - app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/profile_view_not_added_margin}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/profile_view_not_added_margin}" app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -75,7 +75,6 @@ android:textSize="16sp" android:textStyle="italic" app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" - app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> @@ -83,7 +82,6 @@ android:id="@+id/profile_is_admin_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/space_4dp" android:fontFamily="sans-serif-light" android:text="@string/profile_chooser_admin" android:textColor="@color/white" @@ -91,7 +89,6 @@ android:textSize="16sp" android:textStyle="italic" app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" - app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" android:visibility="@{viewModel.profile.isAdmin && hasProfileEverBeenAddedValue ? View.VISIBLE : View.GONE}" /> diff --git a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml index f7217a8e1b0..ddc01692bd8 100644 --- a/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-port/profile_chooser_profile_view.xml @@ -36,8 +36,8 @@ android:layout_height="wrap_content" android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}" android:orientation="@{hasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}" - app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" - app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" + app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/profile_view_not_added_margin}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_16dp : @dimen/profile_view_not_added_margin}" app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_24dp}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -76,14 +76,12 @@ android:textStyle="italic" android:visibility="@{viewModel.profile.lastLoggedInTimestampMs > 0 ? View.VISIBLE : View.GONE}" app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" - app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" profile:lastVisited="@{viewModel.profile.lastLoggedInTimestampMs}" /> + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/space_32dp}" /> - - + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/space_8dp : @dimen/space_0dp}" /> + android:visibility="@{viewModel.profile.isAdmin && hasProfileEverBeenAddedValue ? View.VISIBLE : View.GONE}" + app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/space_0dp : @dimen/profile_view_already_added_margin}" /> Date: Thu, 29 Oct 2020 13:08:26 +0100 Subject: [PATCH 14/18] Other changes --- .../classify/InteractionObjectTestBuilder.kt | 7 ++ ...ceInputEqualsRuleClassifierProviderTest.kt | 39 ++++---- ...ioInputEqualsRuleClassifierProviderTest.kt | 73 ++++++++------ ...berOfTermsEqualToClassifierProviderTest.kt | 55 +++++------ ...tIsEquivalentRuleClassifierProviderTest.kt | 99 ++++++++++++------- 5 files changed, 154 insertions(+), 119 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt b/domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt index 5f78e3a7a20..2383b9971a1 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt @@ -3,6 +3,7 @@ package org.oppia.android.domain.classify import org.oppia.android.app.model.Fraction import org.oppia.android.app.model.InteractionObject import org.oppia.android.app.model.ListOfSetsOfHtmlStrings +import org.oppia.android.app.model.RatioExpression import org.oppia.android.app.model.StringList /** @@ -87,4 +88,10 @@ object InteractionObjectTestBuilder { fun createInt(value: Int): InteractionObject { return InteractionObject.newBuilder().setReal(value.toDouble()).build() } + + fun createRatio(value: List): InteractionObject { + return InteractionObject.newBuilder().setRatioExpression( + RatioExpression.newBuilder().addAllRatioComponent(value) + ).build() + } } diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt index d16871e25dc..11b567c70ca 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt @@ -9,7 +9,7 @@ import dagger.Component import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.InteractionObject +import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -23,9 +23,12 @@ import kotlin.test.fail @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MultipleChoiceInputEqualsRuleClassifierProviderTest { - private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0) - private val NON_NEGATIVE_VALUE_1 = createNonNegativeInt(value = 1) - private val STRING_VALUE_2 = createString(value = "test") + + private val NON_NEGATIVE_VALUE_TEST_0 = + InteractionObjectTestBuilder.createNonNegativeInt(value = 0) + private val NON_NEGATIVE_VALUE_TEST_1 = + InteractionObjectTestBuilder.createNonNegativeInt(value = 1) + private val STRING_VALUE_TEST = InteractionObjectTestBuilder.createString(value = "test") @Inject internal lateinit var multipleChoiceInputEqualsRuleClassifierProvider: @@ -42,10 +45,10 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { @Test fun testNonNegativeAnswer_nonNegativeInput_sameValue_bothValuesMatch() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) val matches = inputEqualsRuleClassifier.matches( - answer = NON_NEGATIVE_VALUE_0, + answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs ) @@ -54,10 +57,10 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { @Test fun testNonNegativeAnswer_nonNegativeInput_differentValue_bothValuesDoNotMatch() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) val matches = inputEqualsRuleClassifier.matches( - answer = NON_NEGATIVE_VALUE_1, + answer = NON_NEGATIVE_VALUE_TEST_1, inputs = inputs ) @@ -66,11 +69,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { @Test fun testNonNegativeAnswer_missingInput_throwsException() { - val inputs = mapOf("y" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_0) val exception = assertThrows(IllegalStateException::class) { inputEqualsRuleClassifier.matches( - answer = NON_NEGATIVE_VALUE_0, + answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs ) } @@ -82,11 +85,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { @Test fun testUnexpectedStringAnswer_nonNegativeIntInput_throwsException() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) val exception = assertThrows(IllegalStateException::class) { inputEqualsRuleClassifier.matches( - answer = STRING_VALUE_2, + answer = STRING_VALUE_TEST, inputs = inputs ) } @@ -98,11 +101,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { @Test fun testNonNegativeAnswer_stringInput_throwsException() { - val inputs = mapOf("x" to STRING_VALUE_2) + val inputs = mapOf("x" to STRING_VALUE_TEST) val exception = assertThrows(IllegalStateException::class) { inputEqualsRuleClassifier.matches( - answer = NON_NEGATIVE_VALUE_0, + answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs ) } @@ -112,14 +115,6 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { .contains("Expected input value to be of type NON_NEGATIVE_INT") } - private fun createNonNegativeInt(value: Int): InteractionObject { - return InteractionObject.newBuilder().setNonNegativeInt(value).build() - } - - private fun createString(value: String): InteractionObject { - return InteractionObject.newBuilder().setNormalizedString(value).build() - } - private fun setUpTestApplicationComponent() { DaggerMultipleChoiceInputEqualsRuleClassifierProviderTest_TestApplicationComponent.builder() .setApplication(ApplicationProvider.getApplicationContext()) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt index f94bb780e03..e26b4d04fd6 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt @@ -9,8 +9,7 @@ import dagger.Component import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.InteractionObject -import org.oppia.android.app.model.RatioExpression +import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,10 +24,23 @@ import kotlin.test.fail @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputEqualsRuleClassifierProviderTest { - private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0) - private val ITEM_RATIO_1 = listOf(1, 2, 3) - private val ITEM_RATIO_2 = listOf(2, 4, 6) - private val ITEM_RATIO_3 = listOf(2, 4, 6, 8) + + private val NON_NEGATIVE_VALUE_TEST_0 = + InteractionObjectTestBuilder.createNonNegativeInt( + value = 0 + ) + private val RATIO_VALUE_TEST_1_2_3 = + InteractionObjectTestBuilder.createRatio( + listOf(1, 2, 3) + ) + private val RATIO_VALUE_TEST_2_4_6 = + InteractionObjectTestBuilder.createRatio( + listOf(2, 4, 6) + ) + private val RATIO_VALUE_TEST_2_4_6_8 = + InteractionObjectTestBuilder.createRatio( + listOf(2, 4, 6, 8) + ) @Inject internal lateinit var ratioInputEqualsRuleClassifierProvider: @@ -38,43 +50,57 @@ class RatioInputEqualsRuleClassifierProviderTest { ratioInputEqualsRuleClassifierProvider.createRuleClassifier() } + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @Test fun testAnswer_testRatio_ratioSimplified_bothValuesMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_1)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_1_2_3) val matches = - equalsClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + equalsClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isTrue() } @Test fun testAnswer_testRatio_ratioNonSimplified_ratioSimplified_bothValuesDoNoMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_2)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6) val matches = - equalsClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + equalsClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isFalse() } @Test fun testAnswer_testRatio_ratio4Terms_ratio3Terms_bothValuesDoNoMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_3)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6_8) val matches = - equalsClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + equalsClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isFalse() } @Test fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) val exception = assertThrows(IllegalStateException::class) { equalsClassifierProvider.matches( - answer = createRatio(ITEM_RATIO_1), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -88,11 +114,11 @@ class RatioInputEqualsRuleClassifierProviderTest { @Test fun testAnswer_testRatio_missingInputX_throwsException() { - val inputs = mapOf("y" to createRatio(ITEM_RATIO_1)) + val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) val exception = assertThrows(IllegalStateException::class) { equalsClassifierProvider.matches( - answer = createRatio(ITEM_RATIO_1), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -102,21 +128,6 @@ class RatioInputEqualsRuleClassifierProviderTest { .contains("Expected classifier inputs to contain parameter with name 'x' but had: [y]") } - private fun createRatio(value: List): InteractionObject { - return InteractionObject.newBuilder().setRatioExpression( - RatioExpression.newBuilder().addAllRatioComponent(value) - ).build() - } - - private fun createNonNegativeInt(value: Int): InteractionObject { - return InteractionObject.newBuilder().setNonNegativeInt(value).build() - } - - @Before - fun setUp() { - setUpTestApplicationComponent() - } - private fun setUpTestApplicationComponent() { DaggerRatioInputEqualsRuleClassifierProviderTest_TestApplicationComponent .builder() diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt index 4999d584086..f88c2fe5452 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt @@ -9,8 +9,7 @@ import dagger.Component import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.InteractionObject -import org.oppia.android.app.model.RatioExpression +import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,9 +24,19 @@ import kotlin.test.fail @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { - private val NON_NEGATIVE_VALUE_3 = createNonNegativeInt(value = 3) - private val NON_NEGATIVE_VALUE_4 = createNonNegativeInt(value = 4) - private val RATIO_WITH_THREE_TERMS = listOf(1, 2, 3) + + private val NON_NEGATIVE_VALUE_TEST_3 = + InteractionObjectTestBuilder.createNonNegativeInt( + value = 3 + ) + private val NON_NEGATIVE_VALUE_TEST_4 = + InteractionObjectTestBuilder.createNonNegativeInt( + value = 4 + ) + private val RATIO_VALUE_TEST_1_2_3 = + InteractionObjectTestBuilder.createRatio( + listOf(1, 2, 3) + ) @Inject internal lateinit var ratioInputHasNumberOfTermsEqualToClassifierProvider: @@ -37,13 +46,18 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { ratioInputHasNumberOfTermsEqualToClassifierProvider.createRuleClassifier() } + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @Test fun testAnswer_withThreeTerms_expected3_matchesCorrectly() { - val inputs = mapOf("y" to NON_NEGATIVE_VALUE_3) + val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_3) val matches = hasNumberOfTermsEqualToClassifierProvider.matches( - answer = createRatio(RATIO_WITH_THREE_TERMS), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) @@ -52,11 +66,11 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { @Test fun testAnswer_withThreeTerms_expectedFour_doesNotMatch() { - val inputs = mapOf("y" to NON_NEGATIVE_VALUE_4) + val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_4) val matches = hasNumberOfTermsEqualToClassifierProvider.matches( - answer = createRatio(RATIO_WITH_THREE_TERMS), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) @@ -65,11 +79,11 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { @Test fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { - val inputs = mapOf("y" to createRatio(RATIO_WITH_THREE_TERMS)) + val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) val exception = assertThrows(IllegalStateException::class) { hasNumberOfTermsEqualToClassifierProvider.matches( - answer = createRatio(RATIO_WITH_THREE_TERMS), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -83,11 +97,11 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { @Test fun testAnswer_testRatio_missingInputY_throwsException() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_4) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4) val exception = assertThrows(IllegalStateException::class) { hasNumberOfTermsEqualToClassifierProvider.matches( - answer = createRatio(RATIO_WITH_THREE_TERMS), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -97,21 +111,6 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { .contains("Expected classifier inputs to contain parameter with name 'y' but had: [x]") } - private fun createRatio(value: List): InteractionObject { - return InteractionObject.newBuilder().setRatioExpression( - RatioExpression.newBuilder().addAllRatioComponent(value) - ).build() - } - - private fun createNonNegativeInt(value: Int): InteractionObject { - return InteractionObject.newBuilder().setNonNegativeInt(value).build() - } - - @Before - fun setUp() { - setUpTestApplicationComponent() - } - private fun setUpTestApplicationComponent() { DaggerRatioInputHasNumberOfTermsEqualToClassifierProviderTest_TestApplicationComponent .builder() diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt index 1ff04d31213..6940ad5f271 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt @@ -9,8 +9,7 @@ import dagger.Component import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.InteractionObject -import org.oppia.android.app.model.RatioExpression +import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,11 +24,27 @@ import kotlin.test.fail @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputIsEquivalentRuleClassifierProviderTest { - private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0) - private val ITEM_RATIO_1 = listOf(1, 2, 3) - private val ITEM_RATIO_2 = listOf(2, 4, 6) - private val ITEM_RATIO_3 = listOf(2, 4, 6, 8) - private val ITEM_RATIO_4 = listOf(2, 3, 5) + + private val NON_NEGATIVE_VALUE_TEST_0 = + InteractionObjectTestBuilder.createNonNegativeInt( + value = 0 + ) + private val RATIO_VALUE_TEST_1_2_3 = + InteractionObjectTestBuilder.createRatio( + listOf(1, 2, 3) + ) + private val RATIO_VALUE_TEST_2_4_6 = + InteractionObjectTestBuilder.createRatio( + listOf(2, 4, 6) + ) + private val RATIO_VALUE_TEST_2_4_6_8 = + InteractionObjectTestBuilder.createRatio( + listOf(2, 4, 6, 8) + ) + private val RATIO_VALUE_TEST_2_3_5 = + InteractionObjectTestBuilder.createRatio( + listOf(2, 3, 5) + ) @Inject internal lateinit var ratioInputIsEquivalentRuleClassifierProvider: @@ -39,73 +54,96 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { ratioInputIsEquivalentRuleClassifierProvider.createRuleClassifier() } + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @Test fun testAnswer_testRatio_ratioNonReduced_bothValuesMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_2)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_2), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_2_4_6, + inputs = inputs + ) assertThat(matches).isTrue() } @Test fun testAnswer_testRatio_ratioNonReduced_ratioReduced_bothValuesMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_2)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isTrue() } @Test fun testAnswer_testRatio_ratioReduced_bothValuesMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_1)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_1_2_3) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isTrue() } @Test fun testAnswer_testRatio_ratio1_ratio3_differentLengths_bothValuesDoNotMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_3)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6_8) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isFalse() } @Test fun testAnswer_testRatio_ratio1_ratio4_differentRatios_bothValuesDoNotMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_4)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_3_5) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isFalse() } @Test fun testAnswer_testRatio_ratio2NonReduced_ratio1Reduced_bothValuesMatch() { - val inputs = mapOf("x" to createRatio(ITEM_RATIO_2)) + val inputs = mapOf("x" to RATIO_VALUE_TEST_2_4_6) val matches = - isEquivalentClassifierProvider.matches(answer = createRatio(ITEM_RATIO_1), inputs = inputs) + isEquivalentClassifierProvider.matches( + answer = RATIO_VALUE_TEST_1_2_3, + inputs = inputs + ) assertThat(matches).isTrue() } @Test fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { - val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) + val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) val exception = assertThrows(IllegalStateException::class) { isEquivalentClassifierProvider.matches( - answer = createRatio(ITEM_RATIO_1), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -119,11 +157,11 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { @Test fun testAnswer_testRatio_missingInputX_throwsException() { - val inputs = mapOf("y" to createRatio(ITEM_RATIO_1)) + val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) val exception = assertThrows(IllegalStateException::class) { isEquivalentClassifierProvider.matches( - answer = createRatio(ITEM_RATIO_1), + answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs ) } @@ -133,21 +171,6 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { .contains("Expected classifier inputs to contain parameter with name 'x' but had: [y]") } - private fun createRatio(value: List): InteractionObject { - return InteractionObject.newBuilder().setRatioExpression( - RatioExpression.newBuilder().addAllRatioComponent(value) - ).build() - } - - private fun createNonNegativeInt(value: Int): InteractionObject { - return InteractionObject.newBuilder().setNonNegativeInt(value).build() - } - - @Before - fun setUp() { - setUpTestApplicationComponent() - } - private fun setUpTestApplicationComponent() { DaggerRatioInputIsEquivalentRuleClassifierProviderTest_TestApplicationComponent .builder() From 1d9d7eb9720526948653f199d06702e9af5f1b06 Mon Sep 17 00:00:00 2001 From: peculiaruc Date: Thu, 29 Oct 2020 13:33:08 +0100 Subject: [PATCH 15/18] Other changes --- .../NumberWithUnitsInputIsEqualToRuleClassifierProviderTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsInputIsEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsInputIsEqualToRuleClassifierProviderTest.kt index 2a596a432a8..d15e6f9063a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsInputIsEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsInputIsEqualToRuleClassifierProviderTest.kt @@ -8,5 +8,4 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) -class NumberWithUnitsInputIsEqualToRuleClassifierProviderTest { -} +class NumberWithUnitsInputIsEqualToRuleClassifierProviderTest From 4b4376c1d2183b430e69c4b687c2806f20e396db Mon Sep 17 00:00:00 2001 From: peculiaruc Date: Thu, 29 Oct 2020 16:48:26 +0100 Subject: [PATCH 16/18] Fixed Margins --- .../main/res/layout-land/profile_chooser_profile_view.xml | 6 +++--- .../layout-sw600dp-land/profile_chooser_profile_view.xml | 2 +- .../layout-sw600dp-port/profile_chooser_profile_view.xml | 2 +- app/src/main/res/layout/profile_chooser_profile_view.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/layout-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-land/profile_chooser_profile_view.xml index 207c502d5a4..55462bd3135 100644 --- a/app/src/main/res/layout-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-land/profile_chooser_profile_view.xml @@ -38,7 +38,7 @@ android:id="@+id/profile_avatar_img" android:layout_width="72dp" android:layout_height="72dp" - android:layout_marginBottom="@dimen/space_8dp" + android:layout_marginBottom="@dimen/previous_button_exploration_view_margin_bottom" app:civ_border_color="@color/avatarBorder" app:civ_border_width="1dp" app:layout_constraintEnd_toEndOf="parent" @@ -49,7 +49,7 @@ + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/profile_view_already_added_description_parent_margin_top : @dimen/space_0dp}" /> + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/profile_view_already_added_description_parent_margin_top : @dimen/space_0dp}" /> + app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/profile_view_already_added_description_parent_margin_top : @dimen/space_0dp}" /> Date: Fri, 30 Oct 2020 09:06:37 +0100 Subject: [PATCH 17/18] Fixed Margins --- .../res/layout-sw600dp-land/profile_chooser_profile_view.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml index 42b823358aa..afe9a35ffd2 100644 --- a/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml +++ b/app/src/main/res/layout-sw600dp-land/profile_chooser_profile_view.xml @@ -105,4 +105,3 @@ app:layout_constraintTop_toBottomOf="@+id/profile_chooser_item" /> - From 7f868229899bd30852fb686f4b74d2fb8e8f3b70 Mon Sep 17 00:00:00 2001 From: peculiaruc Date: Fri, 30 Oct 2020 10:00:29 +0100 Subject: [PATCH 18/18] Fixed Margins --- .../rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt index 874346e04e0..d166bb8a787 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt @@ -74,6 +74,7 @@ class TextInputEqualsRuleClassifierProviderTest { val matches = inputEqualsRuleClassifier.matches(answer = STRING_VALUE_TEST_UPPERCASE, inputs = inputs) + assertThat(matches).isTrue() }