Skip to content

Commit

Permalink
Fix #1687: ProfileChooser no longer crashes (#1689)
Browse files Browse the repository at this point in the history
* Working on having one module build with bazel

* All variables are consistent, missing line was added
  • Loading branch information
miaboloix committed Aug 21, 2020
1 parent 4442fbf commit 69c4484
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ProfileChooserFragmentPresenter @Inject constructor(
private lateinit var binding: ProfileChooserFragmentBinding
private val orientation = Resources.getSystem().configuration.orientation

val wasProfileEverBeenAddedValue = ObservableField<Boolean>(true)
val hasProfileEverBeenAddedValue = ObservableField<Boolean>(true)

private val chooserViewModel: ProfileChooserViewModel by lazy {
getProfileChooserViewModel()
Expand Down Expand Up @@ -104,7 +104,7 @@ class ProfileChooserFragmentPresenter @Inject constructor(
wasProfileEverBeenAdded.observe(
activity,
Observer<Boolean> {
wasProfileEverBeenAddedValue.set(it)
hasProfileEverBeenAddedValue.set(it)
val spanCount = if (it) {
activity.resources.getInteger(R.integer.profile_chooser_span_count)
} else {
Expand Down Expand Up @@ -170,6 +170,7 @@ class ProfileChooserFragmentPresenter @Inject constructor(
model: ProfileChooserUiModel
) {
binding.viewModel = model
binding.hasProfileEverBeenAddedValue = hasProfileEverBeenAddedValue
binding.profileChooserItem.setOnClickListener {
if (model.profile.pin.isEmpty()) {
profileManagementController.loginToProfile(model.profile.id).observe(
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout-land/profile_chooser_add_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<import type="android.view.View" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />
</data>

Expand All @@ -21,7 +21,7 @@
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:background="@color/oppiaProfileChooserDivider"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />

<LinearLayout
android:id="@+id/add_profile_item"
Expand All @@ -32,8 +32,8 @@
android:layout_marginBottom="24dp"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layoutMarginBottom="@{wasProfileEverBeenAddedValue ? @dimen/margin_20 : @dimen/margin_28}"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_24}">
app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/margin_20 : @dimen/margin_28}"
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_24}">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_add_button"
Expand All @@ -51,7 +51,7 @@
android:layout_gravity="center"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="@{wasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:text="@{hasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:textColor="@color/white"
android:textSize="14sp" />

Expand All @@ -65,7 +65,7 @@
android:text="@string/set_up_multiple_profiles_description"
android:textColor="@color/white"
android:textSize="12sp"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />
</LinearLayout>
</LinearLayout>
</layout>
8 changes: 4 additions & 4 deletions app/src/main/res/layout-land/profile_chooser_profile_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<import type="android.view.View" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />

<variable
Expand All @@ -35,8 +35,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layoutMarginBottom="@{wasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_28}"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_24}">
app:layoutMarginBottom="@{hasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_28}"
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_16 : @dimen/margin_24}">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_avatar_img"
Expand Down Expand Up @@ -91,7 +91,7 @@
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@color/oppiaProfileChooserDivider"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@+id/profile_chooser_item"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
Expand Down
28 changes: 14 additions & 14 deletions app/src/main/res/layout-sw600dp-land/profile_chooser_add_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
<import type="android.view.View" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />
</data>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_298}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_298}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_298}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_298}"
android:orientation="vertical">

<View
Expand All @@ -30,42 +30,42 @@
android:layout_height="0.5dp"
android:layout_marginBottom="40dp"
android:background="@color/oppiaProfileChooserDivider"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />

<LinearLayout
android:id="@+id/add_profile_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_0"
android:gravity="@{wasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}"
android:orientation="@{wasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}"
android:orientation="@{hasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
tools:ignore="RtlSymmetry">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_add_button"
android:layout_width="108dp"
android:layout_height="108dp"
android:src="@drawable/ic_add_profile"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_48 : @dimen/margin_0}"
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_48 : @dimen/margin_0}"
app:civ_border_color="@color/avatarBorder"
app:civ_border_width="1dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="@{wasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}"
android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}"
android:orientation="vertical"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_8 : @dimen/margin_0}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_32}">
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_8 : @dimen/margin_0}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_32}">

<TextView
android:id="@+id/add_profile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="@{wasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:text="@{hasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:textColor="@color/white"
android:textSize="20sp" />

Expand All @@ -80,7 +80,7 @@
android:text="@string/set_up_multiple_profiles_description"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
type="org.oppia.app.profile.ProfileChooserViewModel" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />
</data>

Expand Down Expand Up @@ -79,17 +79,17 @@
android:fadingEdgeLength="72dp"
android:orientation="vertical"
android:overScrollMode="never"
android:paddingBottom="@{wasProfileEverBeenAddedValue ? @dimen/padding_224 : @dimen/bottom_white_space}"
android:paddingBottom="@{hasProfileEverBeenAddedValue ? @dimen/padding_224 : @dimen/bottom_white_space}"
android:requiresFadingEdge="vertical"
android:scrollbars="none"
app:data="@{viewModel.profiles}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/profile_select_text"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_84}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}" />
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_84}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

Expand Down
28 changes: 14 additions & 14 deletions app/src/main/res/layout-sw600dp-port/profile_chooser_add_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
<import type="android.view.View" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />
</data>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_170}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_170}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_170}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_170}"
android:orientation="vertical">

<View
Expand All @@ -30,42 +30,42 @@
android:layout_height="0.5dp"
android:layout_marginBottom="72dp"
android:background="@color/oppiaProfileChooserDivider"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}" />

<LinearLayout
android:id="@+id/add_profile_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_0"
android:gravity="@{wasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}"
android:orientation="@{wasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER}"
android:orientation="@{hasProfileEverBeenAddedValue ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_24}"
tools:ignore="RtlSymmetry">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_add_button"
android:layout_width="108dp"
android:layout_height="108dp"
android:src="@drawable/ic_add_profile"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_48 : @dimen/margin_0}"
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_48 : @dimen/margin_0}"
app:civ_border_color="@color/avatarBorder"
app:civ_border_width="1dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="@{wasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}"
android:gravity="@{hasProfileEverBeenAddedValue ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL}"
android:orientation="vertical"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_8 : @dimen/margin_0}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_32}">
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_8 : @dimen/margin_0}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_0 : @dimen/margin_32}">

<TextView
android:id="@+id/add_profile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="@{wasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:text="@{hasProfileEverBeenAddedValue ? @string/profile_chooser_add : @string/set_up_multiple_profiles}"
android:textColor="@color/white"
android:textSize="20sp" />

Expand All @@ -80,7 +80,7 @@
android:text="@string/set_up_multiple_profiles_description"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="@{wasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
android:visibility="@{hasProfileEverBeenAddedValue ? View.GONE : View.VISIBLE}"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
type="org.oppia.app.profile.ProfileChooserViewModel" />

<variable
name="wasProfileEverBeenAddedValue"
name="hasProfileEverBeenAddedValue"
type="androidx.databinding.ObservableField&lt;Boolean&gt;" />
</data>

Expand Down Expand Up @@ -79,17 +79,17 @@
android:fadingEdgeLength="72dp"
android:orientation="vertical"
android:overScrollMode="never"
android:paddingBottom="@{wasProfileEverBeenAddedValue ? @dimen/padding_224 : @dimen/bottom_white_space}"
android:paddingBottom="@{hasProfileEverBeenAddedValue ? @dimen/padding_224 : @dimen/bottom_white_space}"
android:requiresFadingEdge="vertical"
android:scrollbars="none"
app:data="@{viewModel.profiles}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/profile_select_text"
app:layoutMarginTop="@{wasProfileEverBeenAddedValue ? @dimen/margin_24 : @dimen/margin_124}"
app:layoutMarginEnd="@{wasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}"
app:layoutMarginStart="@{wasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}" />
app:layoutMarginTop="@{hasProfileEverBeenAddedValue ? @dimen/margin_24 : @dimen/margin_124}"
app:layoutMarginEnd="@{hasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}"
app:layoutMarginStart="@{hasProfileEverBeenAddedValue ? @dimen/margin_72 : @dimen/margin_0}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

Expand Down
Loading

0 comments on commit 69c4484

Please sign in to comment.