Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part #10: HiFi topic list on home screen #319

Merged
merged 15 commits into from
Nov 12, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ fun setBackgroundDrawable(view: View, @ColorInt colorRgb: Int) {
// The input color needs to have alpha channel prepended to it.
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt())
}

@BindingAdapter("app:bottomRoundedRectDrawableWithColor")
fun setBottomBackgroundDrawable(view: View, @ColorInt colorRgb: Int) {
view.setBackgroundResource(R.drawable.bottom_rounded_rect_background)
// The input color needs to have alpha channel prepended to it.
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomRightRadius="0dp"
android:bottomLeftRadius="12dp"
android:topLeftRadius="0dp"
android:topRightRadius="4dp"/>
<solid android:color="@color/oppiaPrimaryDark"/>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!-- https://stackoverflow.com/a/16161493/3689782 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
<solid android:color="@color/white"/>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="12dp"
android:viewportHeight="200" android:viewportWidth="200"
android:width="12dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M100,0.05a100,100 0,1 0,100 100A100,100 0,0 0,100 0.05ZM150,160.05h-100L50,140.05h100ZM83,120.05 L50,87.05 64,73.05 83,92.05 136,39.05 150,53.05Z"/>
</vector>
5 changes: 3 additions & 2 deletions app/src/main/res/layout/all_topics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
android:id="@+id/all_topics_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:layout_marginStart="4dp"
android:layout_marginTop="64dp"
android:layout_marginBottom="24dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="16dp"
android:fontFamily="sans-serif-medium"
android:text="@string/all_topics"
android:textColor="@color/oppiaPrimaryText"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/layout/home_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
android:layout_marginTop="16dp"
android:onClick="@{presenter::playExplorationButton}"
android:text="Play exploration"
android:visibility="visible" />
android:visibility="gone" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="36dp"
android:layout_marginEnd="24dp"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
android:layout_marginStart="24dp"
android:layout_marginBottom="24dp"
android:overScrollMode="never" />
</LinearLayout>
</layout>
51 changes: 30 additions & 21 deletions app/src/main/res/layout/promoted_story_card.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
Expand All @@ -13,43 +14,45 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp">

<TextView
android:id="@+id/recently_played_stories_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-medium"
android:text="@string/recently_played_stories"
android:textColor="@color/oppiaPrimaryText"
android:textStyle="bold"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/view_all_text_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/view_all_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_height="48dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="4dp"
android:fontFamily="sans-serif-medium"
android:onClick="@{viewModel::clickOnViewAll}"
android:padding="8dp"
android:text="@string/view_all"
android:textAllCaps="true"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/recently_played_stories_text_view"
android:textColor="@color/oppiaPrimaryDark"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/recently_played_stories_text_view" />
app:layout_constraintStart_toEndOf="@+id/recently_played_stories_text_view"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="4dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
android:onClick="@{viewModel::clickOnStoryTile}"
Expand All @@ -66,7 +69,7 @@
android:importantForAccessibility="no"
android:paddingStart="40dp"
android:paddingEnd="40dp"
android:scaleType="centerCrop"
android:scaleType="centerInside"
android:src="@{viewModel.promotedStoryObservable.get().lessonThumbnail.thumbnailGraphic}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -75,8 +78,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:background="@drawable/bottom_rounded_rect_white_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -90,17 +93,21 @@
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.promotedStoryObservable.get().nextChapterName}" />
android:fontFamily="sans-serif-medium"
android:text="@{viewModel.promotedStoryObservable.get().nextChapterName}"
android:textSize="18sp" />

<TextView
android:id="@+id/story_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="16dp"
android:fontFamily="sans-serif"
android:text="@{viewModel.promotedStoryObservable.get().storyName}"
android:textColor="@color/oppiaPrimaryText" />
android:textColor="@color/oppiaPrimaryText"
android:textSize="14sp" />

<TextView
android:id="@+id/topic_name_text_view"
Expand All @@ -111,6 +118,8 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:textSize="14sp"
android:fontFamily="sans-serif-light"
android:text="@{viewModel.promotedStoryObservable.get().topicName}"
android:textAllCaps="true" />
</LinearLayout>
Expand Down
72 changes: 51 additions & 21 deletions app/src/main/res/layout/topic_summary_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
Expand All @@ -10,59 +11,88 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
android:layout_width="140dp"
android:layout_width="match_parent"
android:layout_height="160dp"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
android:layout_margin="10dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="20dp"
android:elevation="4dp"
app:roundedRectDrawableWithColor="@{viewModel.backgroundColor}"
android:clickable="true"
android:focusable="true"
android:onClick="@{viewModel::clickOnSummaryTile}">

<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@{viewModel.topicSummary.topicThumbnail.thumbnailGraphic}"
android:scaleType="centerCrop"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="20dp"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="90dp"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
android:importantForAccessibility="no"
app:layout_constraintTop_toTopOf="parent"
android:scaleType="centerInside"
android:src="@{viewModel.topicSummary.topicThumbnail.thumbnailGraphic}"
app:layout_constraintBottom_toTopOf="@+id/bottom_topic_bar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/topic_downloaded_indication_text_view"
android:layout_width="120dp"
android:layout_height="24dp"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:maxLines="1"
android:visibility="gone"
android:background="@drawable/bottom_left_rounded_rect_primary_background"
android:drawableRight="@drawable/ic_available_offline_icon_white_12dp"
android:text="@string/downloaded"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_topic_bar" />
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageView" />

<FrameLayout
android:id="@+id/bottom_topic_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@{viewModel.darkerBackgroundOverlayColor}"
app:bottomRoundedRectDrawableWithColor="@{viewModel.darkerBackgroundOverlayColor}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

<TextView
android:id="@+id/topic_name_text_view"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.name}"
android:textColor="@color/white"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:layout_margin="8dp"
android:maxLines="2"
android:minLines="2"
android:ellipsize="end"
android:gravity="top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/bottom_topic_bar" />

<TextView
android:id="@+id/lesson_count_text_view"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="@{@plurals/lesson_count(viewModel.canonicalStoryCount, viewModel.canonicalStoryCount)}"
android:layout_margin="8dp"
android:fontFamily="sans-serif-light"
android:textStyle="italic"
android:text="@{@plurals/lesson_count(viewModel.canonicalStoryCount, viewModel.canonicalStoryCount)}"
android:textColor="@color/white_80"
android:textSize="14sp"
android:layout_margin="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/bottom_topic_bar" />
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="@+id/bottom_topic_bar"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
19 changes: 15 additions & 4 deletions app/src/main/res/layout/welcome.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
Expand All @@ -17,17 +18,27 @@
android:id="@+id/welcome_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
android:textSize="20sp"
android:fontFamily="sans-serif"
android:text="@{viewModel.isAppAlreadyOpened().get() ? @string/welcome_back_text : @string/welcome_text}"
android:textColor="@color/oppiaPrimaryText"
android:textSize="24sp"
android:textStyle="bold"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<View
android:layout_width="170dp"
android:layout_height="4dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:background="#E76F51"
veena14cs marked this conversation as resolved.
Show resolved Hide resolved
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/welcome_text_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<color name="oppiaStrokeBlack">#CC333333</color>
<!-- BASIC COLORS -->
<color name="white">#FFFFFF</color>
<color name="white_80">#CCFFFFFF</color>
<color name="black">#000000</color>
<!-- AUDIO COMPONENT -->
<color name="audioComponentBackground">@color/oppiaDarkBlue</color>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<string name="go_to_previous_page">Go to previous page.</string>
<string name="continue_playing_activity">Continue playing</string>
<string name="topic_downloaded">Topic Downloaded</string>
<string name="downloaded">Downloaded</string>
<plurals name="chapter_count">
<item quantity="one">
1 Chapter
Expand Down